Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubSub Awkward implementation of SubscriptionName::equals #1928

Closed
HozahAled opened this issue Aug 9, 2023 · 2 comments · Fixed by #1927
Closed

PubSub Awkward implementation of SubscriptionName::equals #1928

HozahAled opened this issue Aug 9, 2023 · 2 comments · Fixed by #1927
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@HozahAled
Copy link

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.

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Aug 9, 2023
@maitrimangal
Copy link
Member

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

@maitrimangal maitrimangal added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Aug 16, 2023
@blakeli0 blakeli0 transferred this issue from googleapis/java-pubsub Aug 17, 2023
@blakeli0
Copy link
Collaborator

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

@blakeli0 blakeli0 added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants