Bug 64965

Summary: IllegalStateException is thrown in JspContextWrapper.findAttribute()
Product: Tomcat 9 Reporter: Andreas Bergander <andreas.bergander>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Severity: minor    
Priority: P2    
Version: 9.0.40   
Target Milestone: -----   
Hardware: All   
OS: All   

Description Andreas Bergander 2020-12-08 15:03:59 UTC
We get an IllegalStateException from JspContextWrapper.findAttribute() in our logs every now and then due to the session being invalid while resolving EL variables.

In PageContextImpl.findAttribute() this exception is caught. But the exception is not caught in JspContextWrapper.findAttribute(). Shouldn't the same error handling be applied to JspContextWrapper? And according to the javadoc in JspContext the findAttribute method should not throw IllegalStateException. Or is there a reason for not catching that exception?

In PageContextImpl.findAttribute():

try {
	o = session.getAttribute(name);
} catch(IllegalStateException ise) {
	// Session has been invalidated.
	// Ignore and fall through to application scope.

In JspContextWrapper.findAttribute():

if (getSession() != null) {
	o = rootJspCtxt.getAttribute(name, SESSION_SCOPE);
Comment 1 Remy Maucherat 2020-12-08 15:20:27 UTC
I read all the javadoc and verified and I agree with this.
Comment 2 Remy Maucherat 2020-12-08 15:35:28 UTC
This will be fixed in Tomcat 10.0.1, 9.0.42, 8.5.62 and 7.0.108. Thanks.