You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/10/07 09:25:11 UTC

[tomcat] branch main updated (1a43053 -> 0b3c99c)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 1a43053  Refactor JNI out of bean classes
     new ac0e3d6  Revert "Remove test for STM JSP"
     new 434cef9  Different solution for isThreadSafe=false
     new 0b3c99c  Add Eclipse IDE generated equals and hashCode implementations.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/jakarta/servlet/http/Cookie.java              | 52 ++++++++++++++++++++++
 java/org/apache/jasper/compiler/Generator.java     | 17 ++++---
 .../jasper/resources/LocalStrings.properties       |  1 +
 test/org/apache/jasper/compiler/TestGenerator.java |  5 +++
 .../generator/single-threaded.jsp}                 |  2 +-
 webapps/docs/changelog.xml                         |  7 +++
 6 files changed, 78 insertions(+), 6 deletions(-)
 copy test/webapp/{bug5nnnn/bug56612.jsp => jsp/generator/single-threaded.jsp} (96%)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 03/03: Add Eclipse IDE generated equals and hashCode implementations.

Posted by ma...@apache.org.
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 0b3c99c4e9c4cdce91a969430b01750291c86c1f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 7 10:23:37 2021 +0100

    Add Eclipse IDE generated equals and hashCode implementations.
    
    Aligns with Jakarta Servlet API
---
 java/jakarta/servlet/http/Cookie.java | 52 +++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/java/jakarta/servlet/http/Cookie.java b/java/jakarta/servlet/http/Cookie.java
index 85d67b7..de184f2 100644
--- a/java/jakarta/servlet/http/Cookie.java
+++ b/java/jakarta/servlet/http/Cookie.java
@@ -544,6 +544,58 @@ public class Cookie implements Cloneable, Serializable {
             return Collections.unmodifiableMap(attributes);
         }
     }
+
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((attributes == null) ? 0 : attributes.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + version;
+        return result;
+    }
+
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        Cookie other = (Cookie) obj;
+        if (attributes == null) {
+            if (other.attributes != null) {
+                return false;
+            }
+        } else if (!attributes.equals(other.attributes)) {
+            return false;
+        }
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (value == null) {
+            if (other.value != null) {
+                return false;
+            }
+        } else if (!value.equals(other.value)) {
+            return false;
+        }
+        if (version != other.version) {
+            return false;
+        }
+        return true;
+    }
 }
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/03: Revert "Remove test for STM JSP"

Posted by ma...@apache.org.
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 ac0e3d6dc95ec61ade20bfc34839aa369812dcbf
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Oct 6 13:39:26 2021 +0100

    Revert "Remove test for STM JSP"
    
    This reverts commit d96e0fc444f3ba0a484632318184c0fcc4353664.
---
 test/org/apache/jasper/compiler/TestGenerator.java |  5 +++++
 test/webapp/jsp/generator/single-threaded.jsp      | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/test/org/apache/jasper/compiler/TestGenerator.java b/test/org/apache/jasper/compiler/TestGenerator.java
index 65fb6d6..baeb808 100644
--- a/test/org/apache/jasper/compiler/TestGenerator.java
+++ b/test/org/apache/jasper/compiler/TestGenerator.java
@@ -720,6 +720,11 @@ public class TestGenerator extends TomcatBaseTest {
     }
 
     @Test
+    public void testSingleThreaded() throws Exception {
+        doTestJsp("single-threaded.jsp");
+    }
+
+    @Test
     public void testXpoweredBy() throws Exception {
         doTestJsp("x-powered-by.jsp");
     }
diff --git a/test/webapp/jsp/generator/single-threaded.jsp b/test/webapp/jsp/generator/single-threaded.jsp
new file mode 100644
index 0000000..371ec50
--- /dev/null
+++ b/test/webapp/jsp/generator/single-threaded.jsp
@@ -0,0 +1,17 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ page isThreadSafe="false" %>
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/03: Different solution for isThreadSafe=false

Posted by ma...@apache.org.
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 <ma...@apache.org>
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org