Bug 61065 - ImportHandler is using the wrong key to cache resolved classes
Summary: ImportHandler is using the wrong key to cache resolved classes
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: EL (show other bugs)
Version: 8.0.17
Hardware: All All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-03 16:05 UTC by jagoba
Modified: 2017-05-03 21:03 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jagoba 2017-05-03 16:05:07 UTC
The method resolveClass from ImportHandler class uses a Map to cache the classes it resolves using their simple name as key.

  Class<?> result = clazzes.get(name);

It has two methods to resolve a class. 
If we use the package name to import our class (my.package.*), it stores it in the cache using the simple name (correct):

  clazzes.put(name, result);
  // http://svn.apache.org/viewvc/tomcat/tc8.0.x/tags/TOMCAT_8_0_16/java/javax/el/ImportHandler.java?revision=1680308&view=markup#l180

But when we import the class in the jsp (my.package.Class), it stores it using its full class name (incorrect):

  clazzes.put(className, clazz);
  // http://svn.apache.org/viewvc/tomcat/tc8.0.x/tags/TOMCAT_8_0_16/java/javax/el/ImportHandler.java?revision=1680308&view=markup#l160

Classes resolved like this are always a miss in the cache.

So, when importing packages (<%@ page import="my.package.*" %>) the cache will work as expected.
But if we import the class (<%@ page import="my.package.Class" %>) we will always get a miss on the cache.

You can find this problem in versions 8.0.16 and up.
Comment 1 Violeta Georgieva 2017-05-03 21:03:14 UTC
Hi,

Thanks for the report.
The fix was committed in:
- trunk for 9.0.0.M21 onwards
- 8.5.x for 8.5.15 onwards
- 8.0.x for 8.0.44 onwards

Regards,
Violeta