hash codes should not be treated as unique

Bug #649805 reported by Jesper Blomquist
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
New
Undecided
Unassigned

Bug Description

In TemplateLoader the hash code of a VirutalFile's relative path is
used as the key of the "templates" hash map.
Hash codes should newer be considered unique and this cache is
therefore subject to key collisions.
The effect of a collision will be that the wrong template is returned
by the cache.

Consider the following files which will will have the same hash code:
VirtualFile f = VirtualFile.open("Application/CDEa.html");
VirtualFile f2 = VirtualFile.open("Application/CDFB.html");

System.out.println((f.relativePath().hashCode()+"").replace("-",
"M"));
System.out.println((f2.relativePath().hashCode()+"").replace("-",
"M")); //produces the same output as the row above!

My suggestion is simply to drop the "hashCode()+"").replace("-", "M")"
part and use the relative path as key for the "templates" cache.

I don´t say that this is a huge problem, but hey, will this be hard to
track down if it occurs...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.