Message:
The following issue has been closed.
Resolver: fabrizio giustina
Date: Tue, 5 Oct 2004 2:24 PM
fix committed to cvs, thanks.
---------------------------------------------------------------------
View the issue:
http://jira.codehaus.org/browse/DISPL-12
Here is an overview of the issue:
---------------------------------------------------------------------
Key: DISPL-12
Summary: Algorithm in org.displaytag.util.ParamEncoder is bogus
Type: Bug
Status: Closed
Priority: Minor
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: DisplayTag
Components:
Tag Library
Fix Fors:
1.0 RC2
Versions:
1.0 RC1
Assignee: fabrizio giustina
Reporter: fabrizio giustina
Created: Wed, 22 Sep 2004 8:32 AM
Updated: Tue, 5 Oct 2004 2:24 PM
Description:
====
imported from sf tracker
id 990011
http://sourceforge.net/tracker/index.php?func=detail&group_id=73068&atid=536613&aid=990011
====
The algorithm used in the ParamEncoder-class produces
easily colliding keys, e.g. "option" and "answer".
If there isn't a reason to exchange hashes between
different JRE:s (let the difference be vendor or version),
why not use the hashCode() provided by
java.lang.String? The hash is cached as well, which
might help interned Strings.
If you wan't to keep the hash backwards compat, I
suggest you use a better algo, for example the one
described by Joshua Bloch (copy-paste from my patched
class):
// Joshua Bloch, Effective Java, p. 38-39
int checkSum = 17;
for (int j = 0; j < charArray.length; j++)
{
checkSum = 37 * checkSum + (int) charArray[j];
}
// keep it positive
checkSum &= 0x7fffffff;
The downside of this algo is the length of the hash, but it
may be controlled with the number 37: lower primes yeild
less length. Other option is to let less bits through the
and-mask.
Questions/comments are welcome, my mailname is villeja
and the domain is avoltus.com. Combine those =).
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel