-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Fedora 38
- Java version: 17.0.7
- version(s): proto-google-cloud-pubsub-v1-1.105.17.jar
Steps to reproduce
- 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.
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.