[Bug 68092] Failed to connect database after upgrading to tomcat-8.5.94 in linux
https://bz.apache.org/bugzilla/show_bug.cgi?id=68092 --- Comment #3 from hongying --- Thanks Mark, it does work after upgrading to tomcat-8.5.95. Ignore the file size issue, it's normal now. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 67927] TLSCertificateReloadListener triggers race condition (?) in OpenSSL code which causes the JVM to die
https://bz.apache.org/bugzilla/show_bug.cgi?id=67927 Matafagafo changed: What|Removed |Added CC||matafag...@yahoo.com -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68068] Hotspot in Ast*Nodes: itable method calls
https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 Mark Thomas changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #4 from Mark Thomas --- Fixed in: - 11.0.x for 11.0.0-M14 onwards - 10.1.x for 10.1.16 onwards - 9.0.x for 9.0.83 onwards - 8.5.x for 8.5.96 onwards -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Fix BZ 68068 - El performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 66eadfeb92 Fix BZ 68068 - El performance improvement 66eadfeb92 is described below commit 66eadfeb9274cc545ae614c83991d7e7dbf41bd7 Author: Mark Thomas AuthorDate: Tue Nov 7 16:50:08 2023 + Fix BZ 68068 - El performance improvement https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- java/org/apache/el/parser/SimpleNode.java | 18 -- webapps/docs/changelog.xml| 8 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index 4b66cd7925..d222161525 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -33,9 +33,15 @@ import org.apache.el.util.MessageFactory; * @author Jacob Hookom [ja...@hookom.net] */ public abstract class SimpleNode extends ELSupport implements Node { -protected Node parent; -protected Node[] children; +/* + * Uses SimpleNode rather than Node for performance. + * + * See https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 + */ +protected SimpleNode parent; + +protected SimpleNode[] children; protected final int id; @@ -57,7 +63,7 @@ public abstract class SimpleNode extends ELSupport implements Node { @Override public void jjtSetParent(Node n) { -parent = n; +parent = (SimpleNode) n; } @Override @@ -68,13 +74,13 @@ public abstract class SimpleNode extends ELSupport implements Node { @Override public void jjtAddChild(Node n, int i) { if (children == null) { -children = new Node[i + 1]; +children = new SimpleNode[i + 1]; } else if (i >= children.length) { -Node c[] = new Node[i + 1]; +SimpleNode c[] = new SimpleNode[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } -children[i] = n; +children[i] = (SimpleNode) n; } @Override diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index cfcd1e0815..6c4c2c5835 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -194,6 +194,14 @@ + + + +68068: Performance improvement for EL. Based on a suggestion +by John Engebretson. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 9.0.x updated: Fix BZ 68068 - El performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new eb41f61af5 Fix BZ 68068 - El performance improvement eb41f61af5 is described below commit eb41f61af56593d657b6e764c07f40dad4377e2a Author: Mark Thomas AuthorDate: Tue Nov 7 16:50:08 2023 + Fix BZ 68068 - El performance improvement https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- java/org/apache/el/parser/SimpleNode.java | 18 -- webapps/docs/changelog.xml| 8 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index 4b66cd7925..d222161525 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -33,9 +33,15 @@ import org.apache.el.util.MessageFactory; * @author Jacob Hookom [ja...@hookom.net] */ public abstract class SimpleNode extends ELSupport implements Node { -protected Node parent; -protected Node[] children; +/* + * Uses SimpleNode rather than Node for performance. + * + * See https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 + */ +protected SimpleNode parent; + +protected SimpleNode[] children; protected final int id; @@ -57,7 +63,7 @@ public abstract class SimpleNode extends ELSupport implements Node { @Override public void jjtSetParent(Node n) { -parent = n; +parent = (SimpleNode) n; } @Override @@ -68,13 +74,13 @@ public abstract class SimpleNode extends ELSupport implements Node { @Override public void jjtAddChild(Node n, int i) { if (children == null) { -children = new Node[i + 1]; +children = new SimpleNode[i + 1]; } else if (i >= children.length) { -Node c[] = new Node[i + 1]; +SimpleNode c[] = new SimpleNode[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } -children[i] = n; +children[i] = (SimpleNode) n; } @Override diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9fb10cba4e..9762815b93 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -194,6 +194,14 @@ + + + +68068: Performance improvement for EL. Based on a suggestion +by John Engebretson. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 10.1.x updated: Fix BZ 68068 - El performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 79217efc47 Fix BZ 68068 - El performance improvement 79217efc47 is described below commit 79217efc47d723c254873da23728d4bd2eb63d5a Author: Mark Thomas AuthorDate: Tue Nov 7 16:50:08 2023 + Fix BZ 68068 - El performance improvement https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- java/org/apache/el/parser/SimpleNode.java | 18 -- webapps/docs/changelog.xml| 8 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index a69851577f..cb8b2ad80d 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -33,9 +33,15 @@ import org.apache.el.util.MessageFactory; * @author Jacob Hookom [ja...@hookom.net] */ public abstract class SimpleNode implements Node { -protected Node parent; -protected Node[] children; +/* + * Uses SimpleNode rather than Node for performance. + * + * See https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 + */ +protected SimpleNode parent; + +protected SimpleNode[] children; protected final int id; @@ -57,7 +63,7 @@ public abstract class SimpleNode implements Node { @Override public void jjtSetParent(Node n) { -parent = n; +parent = (SimpleNode) n; } @Override @@ -68,13 +74,13 @@ public abstract class SimpleNode implements Node { @Override public void jjtAddChild(Node n, int i) { if (children == null) { -children = new Node[i + 1]; +children = new SimpleNode[i + 1]; } else if (i >= children.length) { -Node c[] = new Node[i + 1]; +SimpleNode c[] = new SimpleNode[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } -children[i] = n; +children[i] = (SimpleNode) n; } @Override diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 6131f6bf49..12ea5e547c 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -189,6 +189,14 @@ + + + +68068: Performance improvement for EL. Based on a suggestion +by John Engebretson. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch main updated: Fix BZ 68068 - El performance improvement
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 The following commit(s) were added to refs/heads/main by this push: new 02091e783a Fix BZ 68068 - El performance improvement 02091e783a is described below commit 02091e783a967d16fea3e289d50a6881c0b3bb32 Author: Mark Thomas AuthorDate: Tue Nov 7 16:50:08 2023 + Fix BZ 68068 - El performance improvement https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- java/org/apache/el/parser/SimpleNode.java | 18 -- webapps/docs/changelog.xml| 4 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index a69851577f..cb8b2ad80d 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -33,9 +33,15 @@ import org.apache.el.util.MessageFactory; * @author Jacob Hookom [ja...@hookom.net] */ public abstract class SimpleNode implements Node { -protected Node parent; -protected Node[] children; +/* + * Uses SimpleNode rather than Node for performance. + * + * See https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 + */ +protected SimpleNode parent; + +protected SimpleNode[] children; protected final int id; @@ -57,7 +63,7 @@ public abstract class SimpleNode implements Node { @Override public void jjtSetParent(Node n) { -parent = n; +parent = (SimpleNode) n; } @Override @@ -68,13 +74,13 @@ public abstract class SimpleNode implements Node { @Override public void jjtAddChild(Node n, int i) { if (children == null) { -children = new Node[i + 1]; +children = new SimpleNode[i + 1]; } else if (i >= children.length) { -Node c[] = new Node[i + 1]; +SimpleNode c[] = new SimpleNode[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } -children[i] = n; +children[i] = (SimpleNode) n; } @Override diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9bef493a58..113013ab92 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -205,6 +205,10 @@ Add support for Records to expression language. (markt) + +68068: Performance improvement for EL. Based on a suggestion +by John Engebretson. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68089] ApplicationHttpRequest.getSpecial() and removeSpecial() use linear scans
https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 Mark Thomas changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #4 from Mark Thomas --- Fixed in: - 11.0.x for 11.0.0-M14 onwards - 10.1.x for 10.1.16 onwards - 9.0.x for 9.0.83 onwards - 8.5.x for 8.5.96 onwards -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Fix back-port for test
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 79aa67546b Fix back-port for test 79aa67546b is described below commit 79aa67546b756e131e34abb5b05b9a6dab490b25 Author: Mark Thomas AuthorDate: Tue Nov 7 16:37:23 2023 + Fix back-port for test --- .../apache/catalina/core/TestApplicationHttpRequestPerformance.java| 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java index a0a1556a8e..8187bd2e7f 100644 --- a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java +++ b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java @@ -25,7 +25,8 @@ public class TestApplicationHttpRequestPerformance { @Test public void testGetAttribute() { org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); -Request request = new Request(null, coyoteRequest); +Request request = new Request(); +request.setCoyoteRequest(coyoteRequest); ApplicationHttpRequest applicationHttpRequest = new ApplicationHttpRequest(request, null ,false); // Warm-up - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 10.1.x updated: Fix back-port for test
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 52a495a161 Fix back-port for test 52a495a161 is described below commit 52a495a161567b69b84d02ff8f45720f4ae7b679 Author: Mark Thomas AuthorDate: Tue Nov 7 16:37:23 2023 + Fix back-port for test --- .../apache/catalina/core/TestApplicationHttpRequestPerformance.java| 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java index a0a1556a8e..1592ceba2f 100644 --- a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java +++ b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java @@ -25,7 +25,8 @@ public class TestApplicationHttpRequestPerformance { @Test public void testGetAttribute() { org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); -Request request = new Request(null, coyoteRequest); +Request request = new Request(null); +request.setCoyoteRequest(coyoteRequest); ApplicationHttpRequest applicationHttpRequest = new ApplicationHttpRequest(request, null ,false); // Warm-up - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 9.0.x updated: Fix back-port for test
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new 1e27a54a54 Fix back-port for test 1e27a54a54 is described below commit 1e27a54a5487b80dfac91b5015e9a3a514cd2335 Author: Mark Thomas AuthorDate: Tue Nov 7 16:37:23 2023 + Fix back-port for test --- .../apache/catalina/core/TestApplicationHttpRequestPerformance.java| 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java index a0a1556a8e..1592ceba2f 100644 --- a/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java +++ b/test/org/apache/catalina/core/TestApplicationHttpRequestPerformance.java @@ -25,7 +25,8 @@ public class TestApplicationHttpRequestPerformance { @Test public void testGetAttribute() { org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); -Request request = new Request(null, coyoteRequest); +Request request = new Request(null); +request.setCoyoteRequest(coyoteRequest); ApplicationHttpRequest applicationHttpRequest = new ApplicationHttpRequest(request, null ,false); // Warm-up - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Align with ApplicationHttpRequest
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 44a080b86f Align with ApplicationHttpRequest 44a080b86f is described below commit 44a080b86f303a256a6fdec8a96c8e5b288e79a5 Author: Mark Thomas AuthorDate: Tue Nov 7 16:36:08 2023 + Align with ApplicationHttpRequest --- java/org/apache/catalina/core/ApplicationRequest.java | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index 5d79673e82..fc9516392d 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -50,9 +50,10 @@ class ApplicationRequest extends ServletRequestWrapper { protected static final String specials[] = { RequestDispatcher.INCLUDE_REQUEST_URI, RequestDispatcher.INCLUDE_CONTEXT_PATH, RequestDispatcher.INCLUDE_SERVLET_PATH, RequestDispatcher.INCLUDE_PATH_INFO, -RequestDispatcher.INCLUDE_QUERY_STRING, RequestDispatcher.FORWARD_REQUEST_URI, -RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH, -RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING }; +RequestDispatcher.INCLUDE_QUERY_STRING, ApplicationDispatcher.INCLUDE_MAPPING, +RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH, +RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO, +RequestDispatcher.FORWARD_QUERY_STRING, ApplicationDispatcher.FORWARD_MAPPING }; /* * This duplicates specials but has been added to improve the performance of isSpecial(). */ - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Fix BZ 68089 - performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 7e1f26980d Fix BZ 68089 - performance improvement 7e1f26980d is described below commit 7e1f26980d127f6681961a742656729c77801f62 Author: Mark Thomas AuthorDate: Tue Nov 7 16:31:19 2023 + Fix BZ 68089 - performance improvement Use an appropriate collection rather than a linear array scan https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 --- .../catalina/core/ApplicationHttpRequest.java | 40 +- .../apache/catalina/core/ApplicationRequest.java | 22 ++ .../TestApplicationHttpRequestPerformance.java | 47 ++ webapps/docs/changelog.xml | 5 +++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 9928d9bea7..931a34d18b 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.Map; import java.util.NoSuchElementException; @@ -77,6 +78,17 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING, ApplicationDispatcher.FORWARD_MAPPING }; +/* + * This duplicates specials to some extent but has been added to improve the performance of [get|set|is]Special(). + * It may be possible to remove specials but that will require changes to AttributeNamesEnumerator. + */ +private static final Map specialsMap = new HashMap<>(); +static { +for (int i = 0; i < specials.length; i++) { +specialsMap.put(specials[i], Integer.valueOf(i)); +} +} + private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; @@ -721,13 +733,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param name Attribute name to be tested */ protected boolean isSpecial(String name) { - -for (String special : specials) { -if (special.equals(name)) { -return true; -} -} -return false; +return specialsMap.containsKey(name); } @@ -737,12 +743,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return the special attribute pos, or -1 if it is not a special attribute */ protected int getSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -return i; -} +Integer index = specialsMap.get(name); +if (index == null) { +return -1; } -return -1; +return index.intValue(); } @@ -752,13 +757,12 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean setSpecial(String name, Object value) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = value; -return true; -} +Integer index = specialsMap.get(name); +if (index == null) { +return false; } -return false; +specialAttributes[index.intValue()] = value; +return true; } diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index 03cfa72009..5d79673e82 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -16,9 +16,12 @@ */ package org.apache.catalina.core; +import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import javax.servlet.RequestDispatcher; import javax.servlet.ServletRequest; @@ -38,16 +41,22 @@ import javax.servlet.ServletRequestWrapper; */ class ApplicationRequest extends ServletRequestWrapper { - /** * The set of attribute names that are special for request dispatchers. + * + * @deprecated Will be removed without replacement in Tomcat 11 onwards. */ +@Deprecated protected static final String specials[] = { RequestDispatcher.
(tomcat) branch 9.0.x updated: Fix BZ 68089 - performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new 71d8889afd Fix BZ 68089 - performance improvement 71d8889afd is described below commit 71d8889afd10af736239f08ef9c530e143c55155 Author: Mark Thomas AuthorDate: Tue Nov 7 16:31:19 2023 + Fix BZ 68089 - performance improvement Use an appropriate collection rather than a linear array scan https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 --- .../catalina/core/ApplicationHttpRequest.java | 40 +- .../apache/catalina/core/ApplicationRequest.java | 22 ++ .../TestApplicationHttpRequestPerformance.java | 47 ++ webapps/docs/changelog.xml | 5 +++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 9cf0d4a4ec..7ea652024c 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -80,6 +81,17 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING, RequestDispatcher.FORWARD_MAPPING }; +/* + * This duplicates specials to some extent but has been added to improve the performance of [get|set|is]Special(). + * It may be possible to remove specials but that will require changes to AttributeNamesEnumerator. + */ +private static final Map specialsMap = new HashMap<>(); +static { +for (int i = 0; i < specials.length; i++) { +specialsMap.put(specials[i], Integer.valueOf(i)); +} +} + private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; @@ -726,13 +738,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param name Attribute name to be tested */ protected boolean isSpecial(String name) { - -for (String special : specials) { -if (special.equals(name)) { -return true; -} -} -return false; +return specialsMap.containsKey(name); } @@ -742,12 +748,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return the special attribute pos, or -1 if it is not a special attribute */ protected int getSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -return i; -} +Integer index = specialsMap.get(name); +if (index == null) { +return -1; } -return -1; +return index.intValue(); } @@ -757,13 +762,12 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean setSpecial(String name, Object value) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = value; -return true; -} +Integer index = specialsMap.get(name); +if (index == null) { +return false; } -return false; +specialAttributes[index.intValue()] = value; +return true; } diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index c3fcacd036..bf84fb63cb 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -16,9 +16,12 @@ */ package org.apache.catalina.core; +import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import javax.servlet.RequestDispatcher; import javax.servlet.ServletRequest; @@ -38,10 +41,12 @@ import javax.servlet.ServletRequestWrapper; */ class ApplicationRequest extends ServletRequestWrapper { - /** * The set of attribute names that are special for request dispatchers. + * + * @deprecated Will be removed without replacement in Tomcat 11 onwards. */ +@Deprecated protected static final String specials[] = {
(tomcat) branch 10.1.x updated: Fix BZ 68089 - performance improvement
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 4201defbea Fix BZ 68089 - performance improvement 4201defbea is described below commit 4201defbeac20ad4147ea73db5905fe072d39433 Author: Mark Thomas AuthorDate: Tue Nov 7 16:31:19 2023 + Fix BZ 68089 - performance improvement Use an appropriate collection rather than a linear array scan https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 --- .../catalina/core/ApplicationHttpRequest.java | 40 +- .../apache/catalina/core/ApplicationRequest.java | 22 ++ .../TestApplicationHttpRequestPerformance.java | 47 ++ webapps/docs/changelog.xml | 5 +++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index db94ccd411..3eba826b3f 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -80,6 +81,17 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING, RequestDispatcher.FORWARD_MAPPING }; +/* + * This duplicates specials to some extent but has been added to improve the performance of [get|set|is]Special(). + * It may be possible to remove specials but that will require changes to AttributeNamesEnumerator. + */ +private static final Map specialsMap = new HashMap<>(); +static { +for (int i = 0; i < specials.length; i++) { +specialsMap.put(specials[i], Integer.valueOf(i)); +} +} + private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; @@ -726,13 +738,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param name Attribute name to be tested */ protected boolean isSpecial(String name) { - -for (String special : specials) { -if (special.equals(name)) { -return true; -} -} -return false; +return specialsMap.containsKey(name); } @@ -742,12 +748,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return the special attribute pos, or -1 if it is not a special attribute */ protected int getSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -return i; -} +Integer index = specialsMap.get(name); +if (index == null) { +return -1; } -return -1; +return index.intValue(); } @@ -757,13 +762,12 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean setSpecial(String name, Object value) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = value; -return true; -} +Integer index = specialsMap.get(name); +if (index == null) { +return false; } -return false; +specialAttributes[index.intValue()] = value; +return true; } diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index e0347353ee..8e0ec4576d 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -16,9 +16,12 @@ */ package org.apache.catalina.core; +import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import jakarta.servlet.RequestDispatcher; import jakarta.servlet.ServletRequest; @@ -38,10 +41,12 @@ import jakarta.servlet.ServletRequestWrapper; */ class ApplicationRequest extends ServletRequestWrapper { - /** * The set of attribute names that are special for request dispatchers. + * + * @deprecated Will be removed without replacement in Tomcat 11 onwards. */ +@Deprecated protected static final String specials[] =
(tomcat) branch main updated: Fix BZ 68089 - performance improvement
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 The following commit(s) were added to refs/heads/main by this push: new 71879aef1c Fix BZ 68089 - performance improvement 71879aef1c is described below commit 71879aef1c2d9518163aa4b292b05cc33ae25e9f Author: Mark Thomas AuthorDate: Tue Nov 7 16:31:19 2023 + Fix BZ 68089 - performance improvement Use an appropriate collection rather than a linear array scan https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 --- .../catalina/core/ApplicationHttpRequest.java | 40 +- .../apache/catalina/core/ApplicationRequest.java | 22 ++ .../TestApplicationHttpRequestPerformance.java | 47 ++ webapps/docs/changelog.xml | 5 +++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 529faeed05..9b60f94814 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -76,6 +77,17 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING, RequestDispatcher.FORWARD_MAPPING }; +/* + * This duplicates specials to some extent but has been added to improve the performance of [get|set|is]Special(). + * It may be possible to remove specials but that will require changes to AttributeNamesEnumerator. + */ +private static final Map specialsMap = new HashMap<>(); +static { +for (int i = 0; i < specials.length; i++) { +specialsMap.put(specials[i], Integer.valueOf(i)); +} +} + private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; @@ -708,13 +720,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param name Attribute name to be tested */ protected boolean isSpecial(String name) { - -for (String special : specials) { -if (special.equals(name)) { -return true; -} -} -return false; +return specialsMap.containsKey(name); } @@ -724,12 +730,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return the special attribute pos, or -1 if it is not a special attribute */ protected int getSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -return i; -} +Integer index = specialsMap.get(name); +if (index == null) { +return -1; } -return -1; +return index.intValue(); } @@ -739,13 +744,12 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean setSpecial(String name, Object value) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = value; -return true; -} +Integer index = specialsMap.get(name); +if (index == null) { +return false; } -return false; +specialAttributes[index.intValue()] = value; +return true; } diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index e0347353ee..8e0ec4576d 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -16,9 +16,12 @@ */ package org.apache.catalina.core; +import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import jakarta.servlet.RequestDispatcher; import jakarta.servlet.ServletRequest; @@ -38,10 +41,12 @@ import jakarta.servlet.ServletRequestWrapper; */ class ApplicationRequest extends ServletRequestWrapper { - /** * The set of attribute names that are special for request dispatchers. + * + * @deprecated Will be removed without replacement in Tomcat 11 onwards. */ +@Deprecated protected static final String specials[] =
[Bug 68089] ApplicationHttpRequest.getSpecial() and removeSpecial() use linear scans
https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 --- Comment #3 from John Engebretson --- Good idea to measure ApplicationHttpRequest.getAttribute()! Our production environment shows 0.27% cpu spent in that method, of which 0.1% cpu is spent in method-local time (including the inlined array scan). ApplicationHttpRequest.setAttribute and removeAttribute() are also present but 10x smaller. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Javadoc and comments cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 60f1769a08 Javadoc and comments cleanup 60f1769a08 is described below commit 60f1769a088ac380e7816551fe9ffe211a8a6b64 Author: remm AuthorDate: Tue Nov 7 16:14:19 2023 +0100 Javadoc and comments cleanup Remove lots of old todos that are either done or not actually useful (for example, the one buffer parsing for HTTP/1.1 was done with Coyote). Deprecate MimeHeaders.clear which only had one caller, in favor of the more consistently used recycle (at least in Tomcat). --- java/org/apache/coyote/Response.java | 2 +- java/org/apache/tomcat/util/buf/ByteChunk.java| 53 +++-- java/org/apache/tomcat/util/buf/CharChunk.java| 2 +- java/org/apache/tomcat/util/buf/MessageBytes.java | 5 +- java/org/apache/tomcat/util/http/MimeHeaders.java | 92 --- 5 files changed, 66 insertions(+), 88 deletions(-) diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index 9e60551161..9e11308278 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -619,7 +619,7 @@ public final class Response { commitTime = -1; errorException = null; errorState.set(0); -headers.clear(); +headers.recycle(); // Servlet 3.1 non-blocking write listener listener = null; synchronized (nonBlockingStateLock) { diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 1002d2fe49..b4d56883ac 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -26,23 +26,6 @@ import java.nio.charset.Charset; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; -/* - * In a server it is very important to be able to operate on - * the original byte[] without converting everything to chars. - * Some protocols are ASCII only, and some allow different - * non-UNICODE encodings. The encoding is not known beforehand, - * and can even change during the execution of the protocol. - * ( for example a multipart message may have parts with different - * encoding ) - * - * For HTTP it is not very clear how the encoding of RequestURI - * and mime values can be determined, but it is a great advantage - * to be able to parse the request without converting to string. - */ - -// TODO: This class could either extend ByteBuffer, or better a ByteBuffer -// inside this way it could provide the search/etc on ByteBuffer, as a helper. - /** * This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. * @@ -57,6 +40,18 @@ import java.nio.charset.StandardCharsets; * This is important because it allows processing the http headers directly on the received bytes, without converting to * chars and Strings until the strings are needed. In addition, the charset is determined later, from headers or user * code. + * + * In a server it is very important to be able to operate on + * the original byte[] without converting everything to chars. + * Some protocols are ASCII only, and some allow different + * non-UNICODE encodings. The encoding is not known beforehand, + * and can even change during the execution of the protocol. + * ( for example a multipart message may have parts with different + * encoding ) + * + * For HTTP it is not very clear how the encoding of RequestURI + * and mime values can be determined, but it is a great advantage + * to be able to parse the request without converting to string. * * @author d...@sun.com * @author James Todd [go...@sun.com] @@ -537,7 +532,7 @@ public final class ByteChunk extends AbstractChunk { } // limit < buf.length (the buffer is already big) -// or we already have space XXX +// or we already have space if (desiredSize <= buff.length) { return; } @@ -651,15 +646,14 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. + * + * NOTE: This only works for characters in the range 0-127. * * @param s the String to compare * * @return true if the comparison succeeded, false otherwise */ public boolean equals(String s) { -// XXX ENCODING - this only works if encoding is UTF8-compat -// ( ok for tomcat, where we compare ascii - header names, etc )!!! - byte[] b = buff; int len = end - start; if (b == null || len != s.length()) { @@ -677,6 +671,8 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String obje
(tomcat) branch 9.0.x updated: Javadoc and comments cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new ffe348b279 Javadoc and comments cleanup ffe348b279 is described below commit ffe348b279a69d2705b57914f9be68271adcd209 Author: remm AuthorDate: Tue Nov 7 16:14:19 2023 +0100 Javadoc and comments cleanup Remove lots of old todos that are either done or not actually useful (for example, the one buffer parsing for HTTP/1.1 was done with Coyote). Deprecate MimeHeaders.clear which only had one caller, in favor of the more consistently used recycle (at least in Tomcat). --- java/org/apache/coyote/Response.java | 2 +- java/org/apache/tomcat/util/buf/ByteChunk.java| 53 +++-- java/org/apache/tomcat/util/buf/CharChunk.java| 2 +- java/org/apache/tomcat/util/buf/MessageBytes.java | 5 +- java/org/apache/tomcat/util/http/MimeHeaders.java | 92 --- 5 files changed, 66 insertions(+), 88 deletions(-) diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index 290c042682..e1bed1c4e0 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -623,7 +623,7 @@ public final class Response { commitTime = -1; errorException = null; errorState.set(0); -headers.clear(); +headers.recycle(); trailerFieldsSupplier = null; // Servlet 3.1 non-blocking write listener listener = null; diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 1002d2fe49..b4d56883ac 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -26,23 +26,6 @@ import java.nio.charset.Charset; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; -/* - * In a server it is very important to be able to operate on - * the original byte[] without converting everything to chars. - * Some protocols are ASCII only, and some allow different - * non-UNICODE encodings. The encoding is not known beforehand, - * and can even change during the execution of the protocol. - * ( for example a multipart message may have parts with different - * encoding ) - * - * For HTTP it is not very clear how the encoding of RequestURI - * and mime values can be determined, but it is a great advantage - * to be able to parse the request without converting to string. - */ - -// TODO: This class could either extend ByteBuffer, or better a ByteBuffer -// inside this way it could provide the search/etc on ByteBuffer, as a helper. - /** * This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. * @@ -57,6 +40,18 @@ import java.nio.charset.StandardCharsets; * This is important because it allows processing the http headers directly on the received bytes, without converting to * chars and Strings until the strings are needed. In addition, the charset is determined later, from headers or user * code. + * + * In a server it is very important to be able to operate on + * the original byte[] without converting everything to chars. + * Some protocols are ASCII only, and some allow different + * non-UNICODE encodings. The encoding is not known beforehand, + * and can even change during the execution of the protocol. + * ( for example a multipart message may have parts with different + * encoding ) + * + * For HTTP it is not very clear how the encoding of RequestURI + * and mime values can be determined, but it is a great advantage + * to be able to parse the request without converting to string. * * @author d...@sun.com * @author James Todd [go...@sun.com] @@ -537,7 +532,7 @@ public final class ByteChunk extends AbstractChunk { } // limit < buf.length (the buffer is already big) -// or we already have space XXX +// or we already have space if (desiredSize <= buff.length) { return; } @@ -651,15 +646,14 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. + * + * NOTE: This only works for characters in the range 0-127. * * @param s the String to compare * * @return true if the comparison succeeded, false otherwise */ public boolean equals(String s) { -// XXX ENCODING - this only works if encoding is UTF8-compat -// ( ok for tomcat, where we compare ascii - header names, etc )!!! - byte[] b = buff; int len = end - start; if (b == null || len != s.length()) { @@ -677,6 +671,8 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. +
(tomcat) branch 10.1.x updated: Javadoc and comments cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new bf9074ff8d Javadoc and comments cleanup bf9074ff8d is described below commit bf9074ff8ddf104409f165deddb589a17689d362 Author: remm AuthorDate: Tue Nov 7 16:14:19 2023 +0100 Javadoc and comments cleanup Remove lots of old todos that are either done or not actually useful (for example, the one buffer parsing for HTTP/1.1 was done with Coyote). Deprecate MimeHeaders.clear which only had one caller, in favor of the more consistently used recycle (at least in Tomcat). --- java/org/apache/coyote/Response.java | 2 +- java/org/apache/tomcat/util/buf/ByteChunk.java| 53 +++-- java/org/apache/tomcat/util/buf/CharChunk.java| 2 +- java/org/apache/tomcat/util/buf/MessageBytes.java | 5 +- java/org/apache/tomcat/util/http/MimeHeaders.java | 92 --- 5 files changed, 66 insertions(+), 88 deletions(-) diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index 5eae29558d..354634513d 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -633,7 +633,7 @@ public final class Response { commitTimeNanos = -1; errorException = null; errorState.set(0); -headers.clear(); +headers.recycle(); trailerFieldsSupplier = null; // Servlet 3.1 non-blocking write listener listener = null; diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 27c985e6e2..f53102ddc5 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -26,23 +26,6 @@ import java.nio.charset.Charset; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; -/* - * In a server it is very important to be able to operate on - * the original byte[] without converting everything to chars. - * Some protocols are ASCII only, and some allow different - * non-UNICODE encodings. The encoding is not known beforehand, - * and can even change during the execution of the protocol. - * ( for example a multipart message may have parts with different - * encoding ) - * - * For HTTP it is not very clear how the encoding of RequestURI - * and mime values can be determined, but it is a great advantage - * to be able to parse the request without converting to string. - */ - -// TODO: This class could either extend ByteBuffer, or better a ByteBuffer -// inside this way it could provide the search/etc on ByteBuffer, as a helper. - /** * This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. * @@ -57,6 +40,18 @@ import java.nio.charset.StandardCharsets; * This is important because it allows processing the http headers directly on the received bytes, without converting to * chars and Strings until the strings are needed. In addition, the charset is determined later, from headers or user * code. + * + * In a server it is very important to be able to operate on + * the original byte[] without converting everything to chars. + * Some protocols are ASCII only, and some allow different + * non-UNICODE encodings. The encoding is not known beforehand, + * and can even change during the execution of the protocol. + * ( for example a multipart message may have parts with different + * encoding ) + * + * For HTTP it is not very clear how the encoding of RequestURI + * and mime values can be determined, but it is a great advantage + * to be able to parse the request without converting to string. * * @author d...@sun.com * @author James Todd [go...@sun.com] @@ -494,7 +489,7 @@ public final class ByteChunk extends AbstractChunk { } // limit < buf.length (the buffer is already big) -// or we already have space XXX +// or we already have space if (desiredSize <= buff.length) { return; } @@ -608,15 +603,14 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. + * + * NOTE: This only works for characters in the range 0-127. * * @param s the String to compare * * @return true if the comparison succeeded, false otherwise */ public boolean equals(String s) { -// XXX ENCODING - this only works if encoding is UTF8-compat -// ( ok for tomcat, where we compare ascii - header names, etc )!!! - byte[] b = buff; int len = end - start; if (b == null || len != s.length()) { @@ -634,6 +628,8 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String objec
(tomcat) branch main updated: Javadoc and comments cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/main by this push: new bfb7e88406 Javadoc and comments cleanup bfb7e88406 is described below commit bfb7e8840662c49bd8627a0bb96a17e1bb8ed0cf Author: remm AuthorDate: Tue Nov 7 16:14:19 2023 +0100 Javadoc and comments cleanup Remove lots of old todos that are either done or not actually useful (for example, the one buffer parsing for HTTP/1.1 was done with Coyote). Deprecate MimeHeaders.clear which only had one caller, in favor of the more consistently used recycle (at least in Tomcat). --- java/org/apache/coyote/Response.java | 2 +- java/org/apache/tomcat/util/buf/ByteChunk.java| 53 +++-- java/org/apache/tomcat/util/buf/CharChunk.java| 2 +- java/org/apache/tomcat/util/buf/MessageBytes.java | 5 +- java/org/apache/tomcat/util/http/MimeHeaders.java | 91 --- 5 files changed, 65 insertions(+), 88 deletions(-) diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index 6e4991ac30..d0d7f2a54d 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -655,7 +655,7 @@ public final class Response { commitTimeNanos = -1; errorException = null; errorState.set(0); -headers.clear(); +headers.recycle(); trailerFieldsSupplier = null; // Servlet 3.1 non-blocking write listener listener = null; diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 27c985e6e2..f53102ddc5 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -26,23 +26,6 @@ import java.nio.charset.Charset; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; -/* - * In a server it is very important to be able to operate on - * the original byte[] without converting everything to chars. - * Some protocols are ASCII only, and some allow different - * non-UNICODE encodings. The encoding is not known beforehand, - * and can even change during the execution of the protocol. - * ( for example a multipart message may have parts with different - * encoding ) - * - * For HTTP it is not very clear how the encoding of RequestURI - * and mime values can be determined, but it is a great advantage - * to be able to parse the request without converting to string. - */ - -// TODO: This class could either extend ByteBuffer, or better a ByteBuffer -// inside this way it could provide the search/etc on ByteBuffer, as a helper. - /** * This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. * @@ -57,6 +40,18 @@ import java.nio.charset.StandardCharsets; * This is important because it allows processing the http headers directly on the received bytes, without converting to * chars and Strings until the strings are needed. In addition, the charset is determined later, from headers or user * code. + * + * In a server it is very important to be able to operate on + * the original byte[] without converting everything to chars. + * Some protocols are ASCII only, and some allow different + * non-UNICODE encodings. The encoding is not known beforehand, + * and can even change during the execution of the protocol. + * ( for example a multipart message may have parts with different + * encoding ) + * + * For HTTP it is not very clear how the encoding of RequestURI + * and mime values can be determined, but it is a great advantage + * to be able to parse the request without converting to string. * * @author d...@sun.com * @author James Todd [go...@sun.com] @@ -494,7 +489,7 @@ public final class ByteChunk extends AbstractChunk { } // limit < buf.length (the buffer is already big) -// or we already have space XXX +// or we already have space if (desiredSize <= buff.length) { return; } @@ -608,15 +603,14 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. + * + * NOTE: This only works for characters in the range 0-127. * * @param s the String to compare * * @return true if the comparison succeeded, false otherwise */ public boolean equals(String s) { -// XXX ENCODING - this only works if encoding is UTF8-compat -// ( ok for tomcat, where we compare ascii - header names, etc )!!! - byte[] b = buff; int len = end - start; if (b == null || len != s.length()) { @@ -634,6 +628,8 @@ public final class ByteChunk extends AbstractChunk { /** * Compares the message bytes to the specified String object. +
(tomcat) branch 8.5.x updated: Reduce code duplication
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 847d9d83a5 Reduce code duplication 847d9d83a5 is described below commit 847d9d83a513d693fcd7cbda5a44872ba1b621be Author: Mark Thomas AuthorDate: Tue Nov 7 14:11:36 2023 + Reduce code duplication --- java/org/apache/catalina/core/ApplicationHttpRequest.java | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 1f9d64dbbb..9928d9bea7 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -768,13 +768,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean removeSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = null; -return true; -} -} -return false; +return setSpecial(name, null); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 10.1.x updated: Reduce code duplication
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 44be4e67fa Reduce code duplication 44be4e67fa is described below commit 44be4e67fa3a80510255aa4e9b01090be3befb40 Author: Mark Thomas AuthorDate: Tue Nov 7 14:11:36 2023 + Reduce code duplication --- java/org/apache/catalina/core/ApplicationHttpRequest.java | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index d4ba42e167..db94ccd411 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -773,13 +773,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean removeSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = null; -return true; -} -} -return false; +return setSpecial(name, null); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 9.0.x updated: Clean-up - no functional change
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new be1c0abdfc Clean-up - no functional change be1c0abdfc is described below commit be1c0abdfc589e6f471282a4d10c272ffe5feea8 Author: Mark Thomas AuthorDate: Tue Nov 7 14:10:30 2023 + Clean-up - no functional change --- .../catalina/core/ApplicationHttpRequest.java | 63 ++ .../apache/catalina/core/ApplicationRequest.java | 38 ++--- 2 files changed, 19 insertions(+), 82 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index cc86ba88db..ae21815fe4 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -16,7 +16,6 @@ */ package org.apache.catalina.core; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; @@ -54,7 +53,6 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.Parameters; import org.apache.tomcat.util.res.StringManager; - /** * Wrapper around a javax.servlet.http.HttpServletRequest that transforms an application request object * (which might be the original one passed to a servlet, or might be based on the 2.3 @@ -86,29 +84,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; -// --- Constructors - - -/** - * Construct a new wrapped request around the specified servlet request. - * - * @param request The servlet request being wrapped - * @param context The target context for the wrapped request - * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} - */ -ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { - -super(request); -this.context = context; -this.crossContext = crossContext; -setRequest(request); - -} - - -// - Instance Variables - - /** * The context for this request. */ @@ -199,6 +174,21 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected final Object[] specialAttributes = new Object[specials.length]; +/** + * Construct a new wrapped request around the specified servlet request. + * + * @param request The servlet request being wrapped + * @param context The target context for the wrapped request + * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} + */ +ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { +super(request); +this.context = context; +this.crossContext = crossContext; +setRequest(request); +} + + // - ServletRequest Methods @Override @@ -242,7 +232,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { return specialAttributes[pos]; } } - } @@ -262,11 +251,9 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { */ @Override public void removeAttribute(String name) { - if (!removeSpecial(name)) { getRequest().removeAttribute(name); } - } @@ -290,7 +277,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { if (!setSpecial(name, value)) { getRequest().setAttribute(name, value); } - } @@ -355,7 +341,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } return context.getServletContext().getRequestDispatcher(relative); - } @@ -370,7 +355,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { // - HttpServletRequest Methods - /** * Override the getContextPath() method of the wrapped request. */ @@ -553,7 +537,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } else { return super.getSession(create); } - } @@ -635,9 +618,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param contextPath The new context path */ void setContextPath(String contextPath) { - this.contextPath = contextPath; - } @@ -647,9 +628,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param pathInfo The new pat
(tomcat) branch 9.0.x updated: Reduce code duplication
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new bbb6db065c Reduce code duplication bbb6db065c is described below commit bbb6db065c963109ac1901d7cf79272061a91da5 Author: Mark Thomas AuthorDate: Tue Nov 7 14:11:36 2023 + Reduce code duplication --- java/org/apache/catalina/core/ApplicationHttpRequest.java | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index ae21815fe4..9cf0d4a4ec 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -773,13 +773,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean removeSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = null; -return true; -} -} -return false; +return setSpecial(name, null); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) branch 8.5.x updated: Clean-up - no functional change
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 3dfc7aa5d8 Clean-up - no functional change 3dfc7aa5d8 is described below commit 3dfc7aa5d897f6ae8ee8fc346b028033b2dcebb3 Author: Mark Thomas AuthorDate: Tue Nov 7 14:10:30 2023 + Clean-up - no functional change --- .../catalina/core/ApplicationHttpRequest.java | 63 ++ .../apache/catalina/core/ApplicationRequest.java | 38 ++--- 2 files changed, 19 insertions(+), 82 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index c45f895819..1f9d64dbbb 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -16,7 +16,6 @@ */ package org.apache.catalina.core; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; @@ -51,7 +50,6 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.Parameters; import org.apache.tomcat.util.res.StringManager; - /** * Wrapper around a javax.servlet.http.HttpServletRequest that transforms an application request object * (which might be the original one passed to a servlet, or might be based on the 2.3 @@ -83,29 +81,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; -// --- Constructors - - -/** - * Construct a new wrapped request around the specified servlet request. - * - * @param request The servlet request being wrapped - * @param context The target context for the wrapped request - * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} - */ -ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { - -super(request); -this.context = context; -this.crossContext = crossContext; -setRequest(request); - -} - - -// - Instance Variables - - /** * The context for this request. */ @@ -196,6 +171,21 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected final Object[] specialAttributes = new Object[specials.length]; +/** + * Construct a new wrapped request around the specified servlet request. + * + * @param request The servlet request being wrapped + * @param context The target context for the wrapped request + * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} + */ +ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { +super(request); +this.context = context; +this.crossContext = crossContext; +setRequest(request); +} + + // - ServletRequest Methods @Override @@ -239,7 +229,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { return specialAttributes[pos]; } } - } @@ -259,11 +248,9 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { */ @Override public void removeAttribute(String name) { - if (!removeSpecial(name)) { getRequest().removeAttribute(name); } - } @@ -287,7 +274,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { if (!setSpecial(name, value)) { getRequest().setAttribute(name, value); } - } @@ -352,7 +338,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } return context.getServletContext().getRequestDispatcher(relative); - } @@ -367,7 +352,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { // - HttpServletRequest Methods - /** * Override the getContextPath() method of the wrapped request. */ @@ -549,7 +533,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } else { return super.getSession(create); } - } @@ -630,9 +613,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param contextPath The new context path */ void setContextPath(String contextPath) { - this.contextPath = contextPath; - } @@ -642,9 +623,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param pathInfo The new pat
(tomcat) branch 10.1.x updated: Clean-up - no functional change
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new d589f7189f Clean-up - no functional change d589f7189f is described below commit d589f7189f7c5f92cb706286cff836120b5a300f Author: Mark Thomas AuthorDate: Tue Nov 7 14:10:30 2023 + Clean-up - no functional change --- .../catalina/core/ApplicationHttpRequest.java | 63 ++ .../apache/catalina/core/ApplicationRequest.java | 38 ++--- 2 files changed, 19 insertions(+), 82 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 494f4a41cd..d4ba42e167 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -16,7 +16,6 @@ */ package org.apache.catalina.core; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; @@ -54,7 +53,6 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.Parameters; import org.apache.tomcat.util.res.StringManager; - /** * Wrapper around a jakarta.servlet.http.HttpServletRequest that transforms an application request object * (which might be the original one passed to a servlet, or might be based on the 2.3 @@ -86,29 +84,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; -// --- Constructors - - -/** - * Construct a new wrapped request around the specified servlet request. - * - * @param request The servlet request being wrapped - * @param context The target context for the wrapped request - * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} - */ -ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { - -super(request); -this.context = context; -this.crossContext = crossContext; -setRequest(request); - -} - - -// - Instance Variables - - /** * The context for this request. */ @@ -199,6 +174,21 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected final Object[] specialAttributes = new Object[specials.length]; +/** + * Construct a new wrapped request around the specified servlet request. + * + * @param request The servlet request being wrapped + * @param context The target context for the wrapped request + * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} + */ +ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { +super(request); +this.context = context; +this.crossContext = crossContext; +setRequest(request); +} + + // - ServletRequest Methods @Override @@ -242,7 +232,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { return specialAttributes[pos]; } } - } @@ -262,11 +251,9 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { */ @Override public void removeAttribute(String name) { - if (!removeSpecial(name)) { getRequest().removeAttribute(name); } - } @@ -290,7 +277,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { if (!setSpecial(name, value)) { getRequest().setAttribute(name, value); } - } @@ -355,7 +341,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } return context.getServletContext().getRequestDispatcher(relative); - } @@ -370,7 +355,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { // - HttpServletRequest Methods - /** * Override the getContextPath() method of the wrapped request. */ @@ -553,7 +537,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } else { return super.getSession(create); } - } @@ -635,9 +618,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param contextPath The new context path */ void setContextPath(String contextPath) { - this.contextPath = contextPath; - } @@ -647,9 +628,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param pathInfo The new
(tomcat) 02/02: Reduce code duplication
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 a10a458b81449df3869756f8ddafe2b2ca5c4fdb Author: Mark Thomas AuthorDate: Tue Nov 7 14:11:36 2023 + Reduce code duplication --- java/org/apache/catalina/core/ApplicationHttpRequest.java | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index fe2c400219..529faeed05 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -755,13 +755,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @return true if the attribute was a special attribute, false otherwise */ protected boolean removeSpecial(String name) { -for (int i = 0; i < specials.length; i++) { -if (specials[i].equals(name)) { -specialAttributes[i] = null; -return true; -} -} -return false; +return setSpecial(name, null); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
(tomcat) 01/02: Clean-up - no functional change
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 3bb5881cf432b81c858f84969a801f9681681e33 Author: Mark Thomas AuthorDate: Tue Nov 7 14:10:30 2023 + Clean-up - no functional change --- .../catalina/core/ApplicationHttpRequest.java | 63 ++ .../apache/catalina/core/ApplicationRequest.java | 38 ++--- 2 files changed, 19 insertions(+), 82 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 11779d364f..fe2c400219 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -16,7 +16,6 @@ */ package org.apache.catalina.core; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; @@ -50,7 +49,6 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.Parameters; import org.apache.tomcat.util.res.StringManager; - /** * Wrapper around a jakarta.servlet.http.HttpServletRequest that transforms an application request object * (which might be the original one passed to a servlet, or might be based on the 2.3 @@ -82,29 +80,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { private static final int SPECIALS_FIRST_FORWARD_INDEX = 6; -// --- Constructors - - -/** - * Construct a new wrapped request around the specified servlet request. - * - * @param request The servlet request being wrapped - * @param context The target context for the wrapped request - * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} - */ -ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { - -super(request); -this.context = context; -this.crossContext = crossContext; -setRequest(request); - -} - - -// - Instance Variables - - /** * The context for this request. */ @@ -195,6 +170,21 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected final Object[] specialAttributes = new Object[specials.length]; +/** + * Construct a new wrapped request around the specified servlet request. + * + * @param request The servlet request being wrapped + * @param context The target context for the wrapped request + * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false} + */ +ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) { +super(request); +this.context = context; +this.crossContext = crossContext; +setRequest(request); +} + + // - ServletRequest Methods @Override @@ -238,7 +228,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { return specialAttributes[pos]; } } - } @@ -258,11 +247,9 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { */ @Override public void removeAttribute(String name) { - if (!removeSpecial(name)) { getRequest().removeAttribute(name); } - } @@ -286,7 +273,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { if (!setSpecial(name, value)) { getRequest().setAttribute(name, value); } - } @@ -351,7 +337,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } return context.getServletContext().getRequestDispatcher(relative); - } @@ -366,7 +351,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { // - HttpServletRequest Methods - /** * Override the getContextPath() method of the wrapped request. */ @@ -549,7 +533,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { } else { return super.getSession(create); } - } @@ -617,9 +600,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param contextPath The new context path */ void setContextPath(String contextPath) { - this.contextPath = contextPath; - } @@ -629,9 +610,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * @param pathInfo The new path info */ void setPathInfo(String pathInfo) { - this.pathInfo = pathInfo; - } @@ -641,9 +620,7 @@ class ApplicationHttpRequ
(tomcat) branch main updated (ea660de4f2 -> a10a458b81)
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 ea660de4f2 Fix BZ 68035 - allow deployment from appBase or xmlBase new 3bb5881cf4 Clean-up - no functional change new a10a458b81 Reduce code duplication The 2 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: .../catalina/core/ApplicationHttpRequest.java | 71 +- .../apache/catalina/core/ApplicationRequest.java | 38 ++-- 2 files changed, 20 insertions(+), 89 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68068] Hotspot in Ast*Nodes: itable method calls
https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- Comment #3 from John Engebretson --- Yes, that's perfect, thanks! -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68089] ApplicationHttpRequest.getSpecial() and removeSpecial() use linear scans
https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 Mark Thomas changed: What|Removed |Added Status|NEEDINFO|NEW --- Comment #2 from Mark Thomas --- A crude performance test shows that using a map makes the request attribute lookup about 2.5x faster. I should have a patch for this once I have got my head around how AttributeNamesEnumerator works. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68068] Hotspot in Ast*Nodes: itable method calls
https://bz.apache.org/bugzilla/show_bug.cgi?id=68068 --- Comment #2 from Mark Thomas --- Created attachment 39353 --> https://bz.apache.org/bugzilla/attachment.cgi?id=39353&action=edit Proposed patch - Tomcat 11 - v1 This is complicated by Node being generated code. Since there isn't a test to validate the fix, is the attached what is being requested? -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68037] Async Servlet implementation doesn't allow setting a response status
https://bz.apache.org/bugzilla/show_bug.cgi?id=68037 Mark Thomas changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #7 from Mark Thomas --- There is a fundamental difference between synchronous and asynchronous for IO error handling. In synchronous servlets, processing is always on a container thread. When an IOException occurs during the service method (including when thrown by container code), the container expects to catch it and handle it outside of the service() method. This offers an opportunity for an application to catch the IOException inside the service() method and effectively hide it from the container. This is what happens in this test case - hence the client sees the 408 status code. In asynchronous servlets, processing may not be on a container thread. Therefore if an IOException is thrown by the container it has to note this because it will not have an opportunity to catch and handle the exception later if on a non-container thread and the container is required to call onError(). Because the container tracks the IOException as soon as it is thrown, it is not possible for the application to hide the exception from the container. This means the standard handling for IOException is applied which includes disabling all further IO on the grounds there is no point in further IO after an IOException. Hence the client never sees the 408 status code. The application does have a narrow gap in onError() where you can achieve a similar result to the synchronous case. Something along the lines of: public void onError(Throwable t) { if (t instanceof SocketTimeoutException) { try { resp.setStatus(408); resp.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } } req.getAsyncContext().complete(); } The reason you need to use setStatus() is that sendError() also disables further output (it works in the synchronous case because the container re-enables output in the error handling but that step is skipped for asynchronous because the container knows there has been an IOException). It is a bit of a hack, but then so is catching and swallowing IOException in service(). I did spend some time seeing looking at the asynchronous error handling but couldn't see an approach I liked more than the current code. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68092] Failed to connect database after upgrading to tomcat-8.5.94 in linux
https://bz.apache.org/bugzilla/show_bug.cgi?id=68092 Mark Thomas changed: What|Removed |Added Resolution|--- |INVALID Status|NEW |RESOLVED --- Comment #2 from Mark Thomas --- The tomcat-jdbc.jar file size is unchanged between 8.5.93 and 8.5.94 at around 149.4 kB It appears that something is wrong with your local environment if tomcat-jdbc.jar is twice the size it should be. Note that even if you fix your environment, 8.5.94 has a known regression in tomcat-jdbc.jar and you should upgrade to 8.5.95 anyway. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68089] ApplicationHttpRequest.getSpecial() and removeSpecial() use linear scans
https://bz.apache.org/bugzilla/show_bug.cgi?id=68089 Remy Maucherat changed: What|Removed |Added Status|NEW |NEEDINFO --- Comment #1 from Remy Maucherat --- > These scans are largely inlined into calling methods so I cannot reliably > estimate the cpu or clock impact, however the sheer number of calls is > impressive. I understand the concern, but it sounds doubtful this is actually a problem given the nature of the checks. Please provide actual data, also demonstrating the proposed technique would provide any performance benefits. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68092] Failed to connect database after upgrading to tomcat-8.5.94 in linux
https://bz.apache.org/bugzilla/show_bug.cgi?id=68092 Mark Thomas changed: What|Removed |Added Product|Tomcat 8|Tomcat Modules Component|Connectors |jdbc-pool Version|8.5.94 |unspecified Target Milestone||--- -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 68092] Failed to connect database after upgrading to tomcat-8.5.94 in linux
https://bz.apache.org/bugzilla/show_bug.cgi?id=68092 --- Comment #1 from Remy Maucherat --- Can you try 8.5.95 ? Otherwise this change could cause it (but it looks ok to me though): https://github.com/apache/tomcat/commit/d54915ea205659f76108d4cd11808a9f31892ca3 -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: [PR] Added support for JDBC 4.3 beginRequest and endRequest methods. [tomcat]
fmeheust commented on code in PR #677: URL: https://github.com/apache/tomcat/pull/677#discussion_r1384572235 ## modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java: ## @@ -812,6 +829,28 @@ protected PooledConnection createConnection(long now, PooledConnection notUsed, }//catch } +/** + * If request boundaries are not initialised, checks if beginRequest and + * endRequest methods are implemented on connection object. + * + * @param connection The connection + * @return Returns true if connection is not null and connection implements + * JDBC 4.3 beginRequest and endRequest methods + */ +private boolean hasRequestBoundaryMethods(Connection connection) { +if (!requestBoundaryMethodsInitialised && connection != null) { +try { +beginRequest = connection.getClass().getMethod("beginRequest"); +endRequest = connection.getClass().getMethod("endRequest"); +} catch (NoSuchMethodException ex) { +// begin and end request not implemented, ignore exception +} finally { +requestBoundaryMethodsInitialised = true; Review Comment: I have changed the code and moved the code to a static block. The getMethod call is now made on the java.sql.Connection interface and not on the instance if the underlying connection, with this solution request boundaries are only called if the version of java is 9 or later. I have changed the tests accordingly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: [PR] Added support for JDBC 4.3 beginRequest and endRequest methods. [tomcat]
fmeheust commented on code in PR #677: URL: https://github.com/apache/tomcat/pull/677#discussion_r1384567373 ## modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectionBoundariesTest.java: ## @@ -0,0 +1,53 @@ +/* + * 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. + */ +package org.apache.tomcat.jdbc.test; + +import org.apache.tomcat.jdbc.test.driver.Driver; + +import java.sql.Connection; + +import org.junit.Test; +import org.junit.Assert; + +public class ConnectionBoundariesTest extends DefaultTestCase { + + +@Override +public org.apache.tomcat.jdbc.pool.DataSource createDefaultDataSource() { +// TODO Auto-generated method stub +org.apache.tomcat.jdbc.pool.DataSource ds = super.createDefaultDataSource(); +ds.getPoolProperties().setDriverClassName(Driver.class.getName()); +ds.getPoolProperties().setUrl(Driver.url); +ds.getPoolProperties().setInitialSize(0); +ds.getPoolProperties().setMaxIdle(10); +ds.getPoolProperties().setMinIdle(10); +ds.getPoolProperties().setMaxActive(10); +return ds; +} +@Test +public void connectionWithRequestBoundariesTest() throws Exception { + datasource.getPoolProperties().getDbProperties().setProperty("requestBoundaries", "true"); Review Comment: I had created another Connection class that would be returned if that property was set, but finally I just added the methods to the existing Connection class, which makes that line useless. I have removed it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org