Status: New
Owner: liuj...@google.com
Labels: Type-Defect Priority-Medium

New issue 594 by jdicami...@google.com: Java generated message builder implementations do not implement equals()
http://code.google.com/p/protobuf/issues/detail?id=594

Summary
The Java generated message (proto) classes implement equals() and hashCode() as one would expect (if the java_generate_equals_and_hash option is true). But the Builder class implementations do not provide equals() or hashCode() methods. They rely on the default java.lang.Object versions of those methods, which are inconsistent with the proto versions.

This is really counter-intuitive, and should either be fixed or at least documented somewhere.


What steps will reproduce the problem?
Person.Builder b1 = Person.newBuilder().setName("Commander Jeffrey Sinclair"); Person.Builder b2 = Person.newBuilder().setName("Commander Jeffrey Sinclair");

if (b1.equals(b2) == b1.build().equals(b2.build())) {
  System.out.println(" Builder and Message equals() are the same. ");
} else {
  System.out.println(" Not the same. ");
}


What is the expected output? What do you see instead?
Expected:
  Builder and Message equals() are the same.

Actual:
  Not the same.


What version of the product are you using? On what operating system?
Not sure. 2.4 or 2.5, I think.
Java 7.
On Linux.


Please provide any additional information below.


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to