We use a JSP that is included at several points to inject data into pages. At the moment the whole content is commented out. Tomcat 8.5 (production environment) ignores that page, respectively generates no output as expected. Tomcat 9.0.1 (development environment) throws an IllegalstateException. This is caused by a change in SmapStratum, which previously returned null on getString() if lineData was null, now it throws an unhandled exception. Reproduction: Create an "empty" JSP or one containing only JSP comments and using trimDirectiveWhitespaces="true": <%@ page pageEncoding="UTF-8" contentType="text/html; charset=utf-8" language="java" import="java.util.Vector" errorPage="" trimDirectiveWhitespaces="true" %> <%-- This is a comment --%> Result: java.lang.IllegalStateException at org.apache.jasper.compiler.SmapStratum.getSmapStringInternal(SmapStratum.java:318) at org.apache.jasper.compiler.SmapStratum.getSmapString(SmapStratum.java:304) at org.apache.jasper.compiler.SmapUtil.installSmap(SmapUtil.java:145) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:473) [...] Expected result: an empty page
Sorry, of course lineData is not null at that point, it is the empty array causing the exception being thrown. // print our StratumSection, FileSection, and LineSections if (fileNameList.size() == 0 || lineData.size() == 0) { throw new IllegalStateException(); }
So this was done during the (major) 49176 enhancement in r1800201. Switching back to returning null will likely cause some NPEs in some cases, but this used to be the case before from what I can see.
Going back to the SMAP spec, it is legal for there to be zero LineInfo lines so the lineData.size() == 0 test can be removed. I'll double-check the rest of the spec while I am at it.
Thanks for the report. This has been fixed for 9.0.2 onwards.