This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 434cef97eedab06676f6454075ceb36637695bdd Author: Mark Thomas <[email protected]> AuthorDate: Wed Oct 6 13:53:50 2021 +0100 Different solution for isThreadSafe=false --- java/org/apache/jasper/compiler/Generator.java | 17 ++++++++++++----- .../org/apache/jasper/resources/LocalStrings.properties | 1 + webapps/docs/changelog.xml | 7 +++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index 2872e01..7688b20 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -56,6 +56,8 @@ import org.apache.jasper.TrimSpacesOption; import org.apache.jasper.compiler.Node.ChildInfoBase; import org.apache.jasper.compiler.Node.NamedAttribute; import org.apache.jasper.runtime.JspRuntimeLibrary; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; import org.xml.sax.Attributes; /** @@ -81,6 +83,8 @@ import org.xml.sax.Attributes; class Generator { + private final Log log = LogFactory.getLog(Generator.class); // must not be static + private static final Class<?>[] OBJECT_CLASS = { Object.class }; private static final Pattern PRE_TAG_PATTERN = Pattern.compile("(?s).*(<pre>|</pre>).*"); @@ -740,10 +744,6 @@ class Generator { out.printin(" implements org.apache.jasper.runtime.JspSourceDependent,"); out.println(); out.printin(" org.apache.jasper.runtime.JspSourceImports"); - if (!pageInfo.isThreadSafe()) { - out.println(","); - out.printin(" jakarta.servlet.SingleThreadModel"); - } out.println(","); out.printin(" org.apache.jasper.runtime.JspSourceDirectives"); out.println(" {"); @@ -762,7 +762,14 @@ class Generator { genPreambleMethods(); // Now the service method - out.printin("public void "); + if (pageInfo.isThreadSafe()) { + out.printin("public void "); + } else { + // This is unlikely to perform well. + out.printin("public synchronized void "); + // As required by JSP 3.1, log a warning + log.warn(Localizer.getMessage("jsp.warning.isThreadSafe", ctxt.getJspFile())); + } out.print(serviceMethodName); out.println("(final jakarta.servlet.http.HttpServletRequest request, final jakarta.servlet.http.HttpServletResponse response)"); out.pushIndent(); diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 3a0f990..7677f03 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -289,6 +289,7 @@ jsp.warning.enablePooling=Warning: Invalid value for the initParam enablePooling jsp.warning.engineOptionsClass=Failed to load engine options class [{0}] jsp.warning.fork=Warning: Invalid value for the initParam fork. Will use the default value of "true" jsp.warning.genchararray=Warning: Invalid value for the initParam genStringAsCharArray. Will use the default value of "false" +jsp.warning.isThreadSafe=Warning: The "isThreadSafe" page directive attribute used in [{0}] has been deprecated and will be removed in version 4.0 of the JSP specification jsp.warning.jspIdleTimeout=Warning: Invalid value for the initParam jspIdleTimeout. Will use the default value of "-1" jsp.warning.keepgen=Warning: Invalid value for the initParam keepgenerated. Will use the default value of "false" jsp.warning.loadSmap=Unable to load SMAP data for class [{0}] diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 8759d10..e0a9205 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -122,6 +122,13 @@ to align Tomcat with recent updates in the Jakarta EL specification project. (markt) </update> + <fix> + Implement an alternative solution to support the JSP page directive + attribute <code>isThreadSafe</code> now that the + <code>SingleThreadModel</code> interface has been removed from the + Servlet API. The new approach synchronizes the <code>service()</code> + method. + </fix> </changelog> </subsection> <subsection name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
