• Bug
  • Status: Closed
  • 1 Critical
  • Resolution: Cannot Reproduce
  • asi
  • Reporter: tgautier
  • March 26, 2007
  • 0
  • Watchers: 0
  • June 04, 2007
  • May 31, 2007

Description

I wrote a class that overrode the hashcode method and used this class as keys for a ConcurrentHashMap.

I remember getting an NPE that appeared to be in DSO code.

I am putting this bug in as a placeholder for now - when I get a chance I will try to write some code to repro it.

Comments

Fiona OShea 2007-04-10

Can you test overriding hashcode?

Taylor Gautier 2007-04-10

I think the code was something like:

public class Foo { Object a = new Object(); Object b = new Object();

public int hashcode() { return a.hashcode(); } }

Hung Huynh 2007-04-10

We have a test ConcurrentHashMapTestApp that does this and it works fine.

Saravanan Subbiah 2007-04-10

ConcurrentHashMapTestApp doesnt do exactly this. I am assigning it to Antonio for investigation.

Saravanan Subbiah 2007-04-10

Can you give the test code ? I am not sure why an NPE will be thrown. According to Antonio, a NPE is thrown since the test program assumes that it gets back a value.

For example,

Foo f1 = new Foo(); concurrentMap.put(f1, new Value()); Foo f2 = new Foo(); Value value = (Value) concurrentMap.get(f2); print(value.toString());

The above code will throw NPE because the get() wont return the right value. This is true even in regular JAVA since a.hashcode() will return different value in f1 and f2.

If this is the case, it is not a bug and this issue can be closed.

Fiona OShea 2007-05-31

Did not see this again.