February 01, 2004

Don't use joscar's ByteBlocks as HashMap keys

This is only a warning to anyone using joscar. There's a pretty dumb bug I just found in joscar 0.9.3 and maybe earlier where ByteBlock's hashCode method will loop infinitely for all blocks whose length is under 128 bytes. This means ByteBlocks should not be used in HashSets or HashMaps, or anything else that uses hash codes.

If you want to fix the bug yourself, you should just have to change the call to Math.min to Math.max in ByteBlock's hashCode method.

If you want a patched joscar-0.9.3-bin.jar instead of fixing it yourself, let me know, and I can give it to you.

The bug happened because I used Math.min where I should've used Math.max. The Math.min and Math.max methods confuse me. I always think that if I use Math.min(1, x), the minimum returned value will be 1, like it's enforcing a minimum value for x.

I'm not saying they should be renamed, or anything, because I think I'm probably one of few people that mixes them up. I can't even imagine what they would be renamed to, except maybe something silly like minOfTwo and maxOfTwo.

Closing paragraph.

Posted by keith at February 1, 2004 10:20 PM | TrackBack
Comments

My friend told me about your web site and I really enjoyed it. Very nicely done. Very interesting!

カジノ

Posted by: カジノ at June 20, 2004 11:42 AM

Thank you, I just wanted to give a greeting and tell you I like your website.

diamond online casinos (online casino)

Posted by: diamond online casinos (online casino) at June 20, 2004 11:42 AM

congrats mate! Fine job and fine site!

grants

Posted by: grants at June 22, 2004 03:54 PM

Great site! Keep it running!

オンラインカジノ

Posted by: オンラインカジノ at June 22, 2004 03:55 PM

congrats mate! Fine job and fine site!

gold online casino (online casinos)

Posted by: gold online casino (online casinos) at June 22, 2004 03:56 PM

Hello! Super work performed. Top PAGE, further so!

free business grants

Posted by: free business grants at July 30, 2004 03:00 AM

I search for blog like this long time.You website is very good!I will come next time!

best online casinos

Posted by: best online casinos at August 1, 2004 06:15 AM

I search for blog like this long time.You website is very good!I will come next time!

best online casinos

Posted by: best online casinos at August 1, 2004 06:15 AM

Thank you, I just wanted to give a greeting and tell you I like your website.

best online casinos

Posted by: best online casinos at August 3, 2004 04:24 AM

Your site is very good.

best online casinos

Posted by: best online casinos at August 7, 2004 01:41 AM

I have always looked for a possibility to find information as quick as I can. Now there is the internet. And I really appreciate people like you who take their chance in such an excellent way to give an impression on certain topics. Thanks for having me here.

online casino

Posted by: online casino at August 13, 2004 12:33 PM

Very informed and interesting comments! Greetings.

internet casino

Posted by: internet casino at August 13, 2004 12:33 PM

great page...im sure i'll come back...best regards

internet casino

Posted by: internet casino at August 16, 2004 09:42 AM

How old is this post?

Posted by: Julieanne at August 17, 2004 03:33 PM

Tramadol is a generic pain relief medication, Buy Tramadol http://www.buy--tramadol.com

Posted by: buy tramadol at August 23, 2004 11:00 PM
Post a comment