[tomcat] branch 9.0.x updated: Revert stream memory footprint reduction and incomplete fixes

2020-09-08 Thread markt
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 7e26b57  Revert stream memory footprint reduction and incomplete fixes
7e26b57 is described below

commit 7e26b575f485413fca9a5491f081f509faf338b1
Author: Mark Thomas 
AuthorDate: Tue Sep 8 10:16:57 2020 +0100

Revert stream memory footprint reduction and incomplete fixes

Revert the changes due to the steady stream of regressions that are
being reported and.or found by the CI systems. A more robust solution is
required.
---
 java/org/apache/coyote/http2/Stream.java | 41 
 webapps/docs/changelog.xml   |  5 
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index b01ca01..c3139ab 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -300,19 +300,14 @@ class Stream extends AbstractStream implements 
HeaderEmitter {
 
 
 void doStreamCancel(String msg, Http2Error error) throws CloseNowException 
{
-// Avoid NPEs on duplicate cancellations
-StreamOutputBuffer streamOutputBuffer = this.streamOutputBuffer;
-Response coyoteResponse = this.coyoteResponse;
 StreamException se = new StreamException(msg, error, getIdAsInt());
-if (streamOutputBuffer != null && coyoteResponse != null) {
-// Prevent the application making further writes
-streamOutputBuffer.closed = true;
-// Prevent Tomcat's error handling trying to write
-coyoteResponse.setError();
-coyoteResponse.setErrorReported();
-// Trigger a reset once control returns to Tomcat
-streamOutputBuffer.reset = se;
-}
+// Prevent the application making further writes
+streamOutputBuffer.closed = true;
+// Prevent Tomcat's error handling trying to write
+coyoteResponse.setError();
+coyoteResponse.setErrorReported();
+// Trigger a reset once control returns to Tomcat
+streamOutputBuffer.reset = se;
 throw new CloseNowException(msg, se);
 }
 
@@ -475,12 +470,8 @@ class Stream extends AbstractStream implements 
HeaderEmitter {
 }
 
 if (headerState == HEADER_STATE_TRAILER) {
-// Avoid NPE if Stream has been closed on Stream specific 
thread
-Request coyoteRequest = this.coyoteRequest;
-if (coyoteRequest != null) {
-// HTTP/2 headers are already always lower case
-coyoteRequest.getTrailerFields().put(name, value);
-}
+// HTTP/2 headers are already always lower case
+coyoteRequest.getTrailerFields().put(name, value);
 } else {
 coyoteRequest.getMimeHeaders().addValue(name).setString(value);
 }
@@ -656,14 +647,9 @@ class Stream extends AbstractStream implements 
HeaderEmitter {
 
 
 final boolean isContentLengthInconsistent() {
-Request coyoteRequest = this.coyoteRequest;
-// May be null when processing trailer headers after stream has been
-// closed.
-if (coyoteRequest != null) {
-long contentLengthHeader = coyoteRequest.getContentLengthLong();
-if (contentLengthHeader > -1 && contentLengthReceived != 
contentLengthHeader) {
-return true;
-}
+long contentLengthHeader = coyoteRequest.getContentLengthLong();
+if (contentLengthHeader > -1 && contentLengthReceived != 
contentLengthHeader) {
+return true;
 }
 return false;
 }
@@ -765,12 +751,15 @@ class Stream extends AbstractStream implements 
HeaderEmitter {
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("stream.recycle", getConnectionId(), 
getIdentifier()));
 }
+/*
+ * Temporarily disabled due to multiple regressions (NPEs)
 coyoteRequest = null;
 cookieHeader = null;
 coyoteResponse = null;
 inputBuffer = null;
 streamOutputBuffer = null;
 http2OutputBuffer = null;
+*/
 }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f9bcfd5..b835e53 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -172,6 +172,11 @@
 streams to account for DATA frames containing zero-length padding.
 (markt)
   
+  
+64710: Revert the changes to reduce the memory footprint of
+closed HTTP/2 streams as they triggered multiple regressions in the 
form
+of NullPointerExceptions. (markt)
+  
 
   
   



[tomcat] branch 9.0.x updated: Revert "Simpler way to determine Graal runtime"

2020-07-22 Thread fhanik
This is an automated email from the ASF dual-hosted git repository.

fhanik 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 87cbed1  Revert "Simpler way to determine Graal runtime"
87cbed1 is described below

commit 87cbed1244205fb112f421449482d02b56f6167b
Author: Filip Hanik 
AuthorDate: Wed Jul 22 11:40:14 2020 -0700

Revert "Simpler way to determine Graal runtime"

This reverts commit 6a73695fa6d024ed9fc4adeb32073cbd94309c51.

https://tomcat.markmail.org/search/?q=#query:%20list%3Aorg.apache.tomcat.dev+page:1+mid:7vo7ugmqjz2z7x5f+state:results
---
 java/org/apache/jasper/runtime/JspRuntimeLibrary.java | 16 +++-
 java/org/apache/naming/NamingContext.java | 15 ++-
 java/org/apache/tomcat/util/compat/GraalCompat.java   | 15 ++-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java 
b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index d710f84..c0a7a63 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -56,7 +56,21 @@ import org.apache.tomcat.InstanceManager;
  */
 public class JspRuntimeLibrary {
 
-public static final boolean GRAAL = 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+public static final boolean GRAAL;
+
+static {
+boolean result = false;
+try {
+Class nativeImageClazz = 
Class.forName("org.graalvm.nativeimage.ImageInfo");
+result = nativeImageClazz.getMethod("inImageCode").invoke(null) != 
null;
+// Note: This will also be true for the Graal substrate VM
+} catch (ClassNotFoundException e) {
+// Must be Graal
+} catch (ReflectiveOperationException | IllegalArgumentException e) {
+// Should never happen
+}
+GRAAL = result;
+}
 
 /**
  * Returns the value of the javax.servlet.error.exception request
diff --git a/java/org/apache/naming/NamingContext.java 
b/java/org/apache/naming/NamingContext.java
index 40f4085..0471279 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -792,7 +792,20 @@ public class NamingContext implements Context {
 // -- Protected Methods
 
 
-private static final boolean GRAAL = 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+private static final boolean GRAAL;
+
+static {
+boolean result = false;
+try {
+Class nativeImageClazz = 
Class.forName("org.graalvm.nativeimage.ImageInfo");
+result = 
Boolean.TRUE.equals(nativeImageClazz.getMethod("inImageCode").invoke(null));
+} catch (ClassNotFoundException e) {
+// Must be Graal
+} catch (ReflectiveOperationException | IllegalArgumentException e) {
+// Should never happen
+}
+GRAAL = result;
+}
 
 /**
  * Retrieves the named object.
diff --git a/java/org/apache/tomcat/util/compat/GraalCompat.java 
b/java/org/apache/tomcat/util/compat/GraalCompat.java
index e3cb09d..9fb835a 100644
--- a/java/org/apache/tomcat/util/compat/GraalCompat.java
+++ b/java/org/apache/tomcat/util/compat/GraalCompat.java
@@ -20,7 +20,20 @@ import java.io.IOException;
 
 class GraalCompat extends Jre9Compat {
 
-private static final boolean GRAAL = 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;
+private static final boolean GRAAL;
+
+static {
+boolean result = false;
+try {
+Class nativeImageClazz = 
Class.forName("org.graalvm.nativeimage.ImageInfo");
+result = 
Boolean.TRUE.equals(nativeImageClazz.getMethod("inImageCode").invoke(null));
+} catch (ClassNotFoundException e) {
+// Must be Graal
+} catch (ReflectiveOperationException | IllegalArgumentException e) {
+// Should never happen
+}
+GRAAL = result;
+}
 
 static boolean isSupported() {
 // This property does not exist for a native image


-
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: Revert "Fixes OSGI bundling error"

2020-06-23 Thread fhanik
This is an automated email from the ASF dual-hosted git repository.

fhanik 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 7ec1d31  Revert "Fixes OSGI bundling error"
7ec1d31 is described below

commit 7ec1d3158461c50123092a96c7ca8f032721a314
Author: Filip Hanik 
AuthorDate: Tue Jun 23 14:17:46 2020 -0700

Revert "Fixes OSGI bundling error"

This reverts commit caed3194b48ccbbac0572417b0e60807683a8690.
---
 res/bnd/build-defaults.bnd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/bnd/build-defaults.bnd b/res/bnd/build-defaults.bnd
index a099b49..cdefb9c 100644
--- a/res/bnd/build-defaults.bnd
+++ b/res/bnd/build-defaults.bnd
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-Bundle-Version: ${version}
+Bundle-Version: ${version_cleanup;${version}}
 
 Specification-Title: Apache Tomcat
 Specification-Version: ${version.major.minor}


-
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: Revert

2020-05-13 Thread remm
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 c0796a1  Revert
c0796a1 is described below

commit c0796a1c283086d60d8a23212dab1d719bdb301d
Author: remm 
AuthorDate: Wed May 13 15:48:12 2020 +0200

Revert
---
 java/org/apache/catalina/connector/CoyoteAdapter.java | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java 
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 606311f..8587bfd 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -72,8 +72,6 @@ public class CoyoteAdapter implements Adapter {
 System.getProperty("java.vm.vendor") + "/" +
 System.getProperty("java.runtime.version") + ")";
 
-private static final String INVALID_URI = "Invalid URI ";
-
 private static final EnumSet SSL_ONLY =
 EnumSet.of(SessionTrackingMode.SSL);
 
@@ -616,7 +614,7 @@ public class CoyoteAdapter implements Adapter {
 connector.getService().getContainer().logAccess(request, 
response, 0, true);
 return false;
 } else {
-response.sendError(400, INVALID_URI);
+response.sendError(400, "Invalid URI");
 }
 }
 
@@ -634,7 +632,7 @@ public class CoyoteAdapter implements Adapter {
 try {
 req.getURLDecoder().convert(decodedURI.getByteChunk(), 
connector.getEncodedSolidusHandlingInternal());
 } catch (IOException ioe) {
-response.sendError(400, INVALID_URI + ioe.getMessage());
+response.sendError(400, "Invalid URI: " + ioe.getMessage());
 }
 // Normalization
 if (normalize(req.decodedURI())) {
@@ -648,7 +646,7 @@ public class CoyoteAdapter implements Adapter {
 response.sendError(400, "Invalid URI");
 }
 } else {
-response.sendError(400, INVALID_URI);
+response.sendError(400, "Invalid URI");
 }
 } else {
 /* The URI is chars or String, and has been sent using an in-memory


-
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: Revert "Check for non-null 'methods'"

2020-02-20 Thread mgrigorov
This is an automated email from the ASF dual-hosted git repository.

mgrigorov 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 eb2ab3c  Revert "Check for non-null 'methods'"
eb2ab3c is described below

commit eb2ab3cd33e23b786685bb40f6c50e78f46c379b
Author: Martin Tzvetanov Grigorov 
AuthorDate: Thu Feb 20 13:25:21 2020 +0200

Revert "Check for non-null 'methods'"

This reverts commit f85638784471b80da82fc4ef89b3424698da981b.
---
 java/javax/servlet/http/HttpServlet.java | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/java/javax/servlet/http/HttpServlet.java 
b/java/javax/servlet/http/HttpServlet.java
index 2ac26cf..aedbee6 100644
--- a/java/javax/servlet/http/HttpServlet.java
+++ b/java/javax/servlet/http/HttpServlet.java
@@ -502,21 +502,19 @@ public abstract class HttpServlet extends GenericServlet {
 }
 // End of Tomcat specific hack
 
-if (methods != null) {
-for (int i = 0; i < methods.length; i++) {
-Method m = methods[i];
+for (int i=0; i