Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.
This repository was archived by the owner on May 14, 2026. It is now read-only.

PubSub Awkward implementation of SubscriptionName::equals #1928

Description

@HozahAled

Environment details

  1. Fedora 38
  2. Java version: 17.0.7
  3. version(s): proto-google-cloud-pubsub-v1-1.105.17.jar

Steps to reproduce

  1. Compare SubscriptionName to an object of another type

Code example

import com.google.pubsub.v1.SubscriptionName
import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.shouldBe

class PubSub:WordSpec({

    "equals" should{
        "not except when compared to an object of another class"{
            SubscriptionName.newBuilder().setSubscription("foo").setProject("bar").build().equals("foo") shouldBe false
        }
    }
})

Any additional information below

I'd imagine

if (o != null || getClass() == o.getClass()) {
https://github.com/googleapis/java-pubsub/blob/main/proto-google-cloud-pubsub-v1/src/main/java/com/google/pubsub/v1/SubscriptionName.java#L140

Should be replaced with

if (o != null && getClass() == o.getClass()) {

Though not an explicit breach of Object.equals' contract, I wouldn't expect any Object.equals override to throw an exception.

Activity

  1. maitrimangal commented on Aug 15, 2023

    @maitrimangal

    Hi this code is actually autogenerated so I will not be able to change this code. Talking internally about this.

  2. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 16, 2023
  3. blakeli0 commented on Aug 17, 2023

    @blakeli0
    Contributor

    Transferring to sdk-platform-java repo because the code is generated by ResourceNameHelperClassComposer

  4. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions