Bug 61065

Summary: ImportHandler is using the wrong key to cache resolved classes
Product: Tomcat 8 Reporter: jagoba
Component: ELAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.0.17   
Target Milestone: ----   
Hardware: All   
OS: All   

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