Boon, Son of a gun! I'm feeling like a dumb ass now. Well this settles it. I should have read the manual on this one. Ok I'll go put my head in the sand now.
> -----Original Message----- > From: Boon Hian Tek [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 19, 2004 2:04 AM > To: Avalon Developers List > Subject: Re: [OT] Bug in NIO > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Alex, > > Alex Karasulu wrote: > | I think I found a bug in NIO but I'm seeing double right now > | after chasing it for so long. The bug has to do with a simple > | hashCode function - nothing really to do with the core operations > | of the API. > | > | I was wondering if others can look at this junit testcase I have here > | and perhaps even run it to confirm that I'm not smoking crack. > | I this really a bug? > | > | The test is simply this here: > | > | public void testBufferHashing() throws Exception > | { > | HashMap l_map = new HashMap() ; > | > | for( int ii = 0; ii < 10; ii++ ) > | { > | ByteBuffer l_buf = ByteBuffer.allocateDirect( 4096 ) ; > | l_map.put( l_buf, new Integer( ii ) ) ; > | } > | > | assertTrue( l_map.size() == 10 ) ; > | } > | > | Seems like there's a hashCode problem with the direct buffer. > | > | Thanks in advance, > | Alex > > "Because buffer hash codes are content-dependent, it is inadvisable to > use buffers as keys in hash maps or similar data structures unless it is > known that their contents will not change." > > http://java.sun.com/j2se/1.4.2/docs/api/java/nio/ByteBuffer.html#hashCode( > ) > > The equals method evaluate two empty buffers as equals. > > I don't think this is a bug. > > My 2 cents. > > Boon > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.3 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFANF/iNJFBtmCH2hIRAtTbAKCHvROEHkxHkkumZMwqaawDG0NRXgCfcpiO > J9WOcMrA/inmDpD0X2M6hJQ= > =BCf5 > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
