Issue 627 in google-gson: LazilyParsedNumber does not implement eqals and hashCode methods

10 views
Skip to first unread message

googl...@googlecode.com

unread,
Feb 4, 2015, 7:06:29 AM2/4/15
to google-gson...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 627 by vrab...@gmail.com: LazilyParsedNumber does not implement
eqals and hashCode methods
https://code.google.com/p/google-gson/issues/detail?id=627

test case to reproduce the issue

package com.google.gson.internal;

import junit.framework.TestCase;

public class LazilyParsedNumberTest extends TestCase {

public void testHashCode(){
LazilyParsedNumber n1 = new LazilyParsedNumber("1");
LazilyParsedNumber n1Another = new LazilyParsedNumber("1");
assertEquals(n1.hashCode(), n1Another.hashCode());
}

public void testEquals(){
LazilyParsedNumber n1 = new LazilyParsedNumber("1");
LazilyParsedNumber n1Another = new LazilyParsedNumber("1");
assertTrue(n1.equals(n1Another));
}


What is the expected output? What do you see instead?
Any class should implement hashCode and equals when implementing Number
interface.

What version of the product are you using? On what operating system?
2.3

Please provide any additional information below.
https://code.google.com/p/google-gson/issues/detail?id=523
Similar one.

I could work on these, but first I would like to know if there was any
reason you decided not to implement these methods?

--
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

googl...@googlecode.com

unread,
Feb 12, 2015, 12:31:44 PM2/12/15
to google-gson...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 627 by inder123: LazilyParsedNumber does not implement
This was an oversight. We should fix this. Thanks for the bug report and a
nicely written test.

googl...@googlecode.com

unread,
Feb 13, 2015, 3:18:50 AM2/13/15
to google-gson...@googlegroups.com

Comment #2 on issue 627 by vrab...@gmail.com: LazilyParsedNumber does not
Thanks.
Do you have any plans with the 523?

I am not sure what the comment in the 523 bug report means.

Do you try implement equals to behave like in javascript?
1.0 == 1

In this case implementing equals and hashCode to fulfill the java contract
would need more work than just ask IDE to generate equals and hashCode
methods.
Reply all
Reply to author
Forward
0 new messages