From ce35c04716fd69b97a5f485d5ef9873c71d42c1d Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Mon, 27 May 2024 22:51:20 +0200 Subject: [PATCH 1/2] Next version is 4.1.0 with Jakarta EE 11 dependencies Signed-off-by: Arjan Tijms --- boms/bom/pom.xml | 12 +++++------ .../grizzly-httpservice-bundle/pom.xml | 6 +++--- extras/bundles/pom.xml | 2 +- extras/connection-pool/pom.xml | 2 +- extras/grizzly-httpservice/pom.xml | 4 ++-- extras/http-server-jaxws/pom.xml | 10 +++++----- extras/http-server-multipart/pom.xml | 2 +- extras/http-servlet-extras/pom.xml | 2 +- extras/pom.xml | 2 +- extras/tls-sni/pom.xml | 2 +- modules/bundles/comet/pom.xml | 6 +++--- modules/bundles/core/pom.xml | 6 +++--- modules/bundles/http-all/pom.xml | 6 +++--- modules/bundles/http-servlet/pom.xml | 6 +++--- modules/bundles/http/pom.xml | 6 +++--- modules/bundles/pom.xml | 2 +- modules/bundles/websockets/pom.xml | 6 +++--- modules/comet/pom.xml | 2 +- modules/grizzly/pom.xml | 4 ++-- modules/http-ajp/pom.xml | 2 +- modules/http-server/pom.xml | 2 +- modules/http-servlet/pom.xml | 2 +- modules/http/pom.xml | 2 +- modules/http2/pom.xml | 2 +- modules/monitoring/grizzly/pom.xml | 4 ++-- modules/monitoring/http-server/pom.xml | 4 ++-- modules/monitoring/http/pom.xml | 4 ++-- modules/monitoring/pom.xml | 2 +- modules/pom.xml | 2 +- modules/portunif/pom.xml | 2 +- modules/websockets/pom.xml | 2 +- pom.xml | 20 +++++++++---------- samples/connection-pool-samples/pom.xml | 2 +- samples/framework-samples/pom.xml | 2 +- samples/http-ajp-samples/pom.xml | 2 +- samples/http-jaxws-samples/pom.xml | 6 +++--- samples/http-multipart-samples/pom.xml | 2 +- samples/http-samples/pom.xml | 2 +- samples/http-server-samples/pom.xml | 2 +- samples/pom.xml | 2 +- samples/portunif/pom.xml | 2 +- samples/tls-sni-samples/pom.xml | 2 +- 42 files changed, 81 insertions(+), 81 deletions(-) diff --git a/boms/bom/pom.xml b/boms/bom/pom.xml index 27c2e2ba5..c4d1956a2 100644 --- a/boms/bom/pom.xml +++ b/boms/bom/pom.xml @@ -1,7 +1,7 @@ @@ -85,7 +85,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/extras/bundles/pom.xml b/extras/bundles/pom.xml index 64df55bec..1805be031 100644 --- a/extras/bundles/pom.xml +++ b/extras/bundles/pom.xml @@ -23,7 +23,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/extras/connection-pool/pom.xml b/extras/connection-pool/pom.xml index 3406787e9..5f4ab5142 100644 --- a/extras/connection-pool/pom.xml +++ b/extras/connection-pool/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/extras/grizzly-httpservice/pom.xml b/extras/grizzly-httpservice/pom.xml index 4ef5188cf..722a2bcf6 100644 --- a/extras/grizzly-httpservice/pom.xml +++ b/extras/grizzly-httpservice/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml @@ -138,7 +138,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 unpack_osgi_compendium_sources diff --git a/extras/http-server-jaxws/pom.xml b/extras/http-server-jaxws/pom.xml index 2626b5242..a23696098 100644 --- a/extras/http-server-jaxws/pom.xml +++ b/extras/http-server-jaxws/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml @@ -41,24 +41,24 @@ com.sun.xml.ws jaxws-rt - 4.0.1 + 4.0.2 provided jakarta.xml.ws jakarta.xml.ws-api - 4.0.0 + 4.0.2 com.sun.xml.bind jaxb-osgi - 4.0.3 + 4.0.5 jar org.glassfish.metro webservices-osgi - 4.0.2 + 4.0.3 jar diff --git a/extras/http-server-multipart/pom.xml b/extras/http-server-multipart/pom.xml index 3f6d87869..13dafe39b 100644 --- a/extras/http-server-multipart/pom.xml +++ b/extras/http-server-multipart/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/extras/http-servlet-extras/pom.xml b/extras/http-servlet-extras/pom.xml index d4ba929a6..803f006da 100644 --- a/extras/http-servlet-extras/pom.xml +++ b/extras/http-servlet-extras/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/extras/pom.xml b/extras/pom.xml index 2c72ced3a..fabc7782a 100644 --- a/extras/pom.xml +++ b/extras/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../pom.xml diff --git a/extras/tls-sni/pom.xml b/extras/tls-sni/pom.xml index c54ca7eb9..937f54e89 100644 --- a/extras/tls-sni/pom.xml +++ b/extras/tls-sni/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/bundles/comet/pom.xml b/modules/bundles/comet/pom.xml index c7bd9350d..fcc7c1c6c 100644 --- a/modules/bundles/comet/pom.xml +++ b/modules/bundles/comet/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -49,7 +49,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -62,7 +62,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/bundles/core/pom.xml b/modules/bundles/core/pom.xml index ddbab7076..e1705327c 100644 --- a/modules/bundles/core/pom.xml +++ b/modules/bundles/core/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -49,7 +49,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -62,7 +62,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/bundles/http-all/pom.xml b/modules/bundles/http-all/pom.xml index 596f3f6fb..03c9df548 100644 --- a/modules/bundles/http-all/pom.xml +++ b/modules/bundles/http-all/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -61,7 +61,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -74,7 +74,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/bundles/http-servlet/pom.xml b/modules/bundles/http-servlet/pom.xml index 98c6846d1..ed29fe2cc 100755 --- a/modules/bundles/http-servlet/pom.xml +++ b/modules/bundles/http-servlet/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -53,7 +53,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -66,7 +66,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/bundles/http/pom.xml b/modules/bundles/http/pom.xml index 91a2e1b9b..16a508ad9 100755 --- a/modules/bundles/http/pom.xml +++ b/modules/bundles/http/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -66,7 +66,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -79,7 +79,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/bundles/pom.xml b/modules/bundles/pom.xml index 4def160c5..522d78738 100644 --- a/modules/bundles/pom.xml +++ b/modules/bundles/pom.xml @@ -23,7 +23,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/bundles/websockets/pom.xml b/modules/bundles/websockets/pom.xml index db12368cb..c172ec894 100644 --- a/modules/bundles/websockets/pom.xml +++ b/modules/bundles/websockets/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -59,7 +59,7 @@ maven-clean-plugin - 3.3.1 + 3.3.2 @@ -72,7 +72,7 @@ maven-dependency-plugin - 3.6.0 + 3.6.1 src-dependencies diff --git a/modules/comet/pom.xml b/modules/comet/pom.xml index 8cc60d9a5..de12c9d70 100644 --- a/modules/comet/pom.xml +++ b/modules/comet/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/grizzly/pom.xml b/modules/grizzly/pom.xml index 109781392..97da27e79 100644 --- a/modules/grizzly/pom.xml +++ b/modules/grizzly/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml @@ -90,7 +90,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.0 add-source diff --git a/modules/http-ajp/pom.xml b/modules/http-ajp/pom.xml index 9a3e81de3..71744515b 100755 --- a/modules/http-ajp/pom.xml +++ b/modules/http-ajp/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/http-server/pom.xml b/modules/http-server/pom.xml index 433b2d8f5..0812ac50b 100644 --- a/modules/http-server/pom.xml +++ b/modules/http-server/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/http-servlet/pom.xml b/modules/http-servlet/pom.xml index 8349633d9..3f11c0e0d 100755 --- a/modules/http-servlet/pom.xml +++ b/modules/http-servlet/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/http/pom.xml b/modules/http/pom.xml index d723d5715..10b7d9fa9 100644 --- a/modules/http/pom.xml +++ b/modules/http/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/http2/pom.xml b/modules/http2/pom.xml index 9763ab792..a2df70bca 100644 --- a/modules/http2/pom.xml +++ b/modules/http2/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/monitoring/grizzly/pom.xml b/modules/monitoring/grizzly/pom.xml index fbb24b8f2..f1a6a47db 100644 --- a/modules/monitoring/grizzly/pom.xml +++ b/modules/monitoring/grizzly/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -103,7 +103,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.0 add-source diff --git a/modules/monitoring/http-server/pom.xml b/modules/monitoring/http-server/pom.xml index 583cbe6cd..020f9cfa9 100644 --- a/modules/monitoring/http-server/pom.xml +++ b/modules/monitoring/http-server/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -101,7 +101,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.0 add-source diff --git a/modules/monitoring/http/pom.xml b/modules/monitoring/http/pom.xml index 561086679..c2eb02872 100644 --- a/modules/monitoring/http/pom.xml +++ b/modules/monitoring/http/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../../pom.xml @@ -100,7 +100,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.6.0 add-source diff --git a/modules/monitoring/pom.xml b/modules/monitoring/pom.xml index 5cddac4af..c510c632b 100644 --- a/modules/monitoring/pom.xml +++ b/modules/monitoring/pom.xml @@ -23,7 +23,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/pom.xml b/modules/pom.xml index f587b7a1e..954d775ef 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -23,7 +23,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT grizzly-modules diff --git a/modules/portunif/pom.xml b/modules/portunif/pom.xml index 71f9c1963..2de59a6f3 100644 --- a/modules/portunif/pom.xml +++ b/modules/portunif/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/modules/websockets/pom.xml b/modules/websockets/pom.xml index a89b0c708..ea1c2da27 100644 --- a/modules/websockets/pom.xml +++ b/modules/websockets/pom.xml @@ -24,7 +24,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 521f82732..5e604651b 100644 --- a/pom.xml +++ b/pom.xml @@ -24,12 +24,12 @@ org.glassfish.grizzly grizzly-bom - 4.0.1 + 4.1.0-SNAPSHOT boms/bom/pom.xml grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT pom @@ -120,7 +120,7 @@ UTF-8 - 6.0.0 + 6.1.0 1.0.0 2.4 4.0.0 @@ -146,7 +146,7 @@ jakarta.persistence jakarta.persistence-api - 3.0.0 + 3.2.0 org.osgi @@ -193,9 +193,9 @@ maven-compiler-plugin - 3.11.0 + 3.13.0 - 11 + 17 -Xlint:unchecked,deprecation,fallthrough,finally,cast,dep-ann,empty,overrides @@ -206,14 +206,14 @@ <_noimportjava>true - <_runee>JavaSE-11 + <_runee>JavaSE-17 - + maven-enforcer-plugin @@ -225,10 +225,10 @@ - [11,) + [17,) - 3.6.3 + 3.8.9 diff --git a/samples/connection-pool-samples/pom.xml b/samples/connection-pool-samples/pom.xml index 4a93bd6cd..0b4e82609 100755 --- a/samples/connection-pool-samples/pom.xml +++ b/samples/connection-pool-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/framework-samples/pom.xml b/samples/framework-samples/pom.xml index 28b8cc4e5..64a0563f9 100755 --- a/samples/framework-samples/pom.xml +++ b/samples/framework-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/http-ajp-samples/pom.xml b/samples/http-ajp-samples/pom.xml index f8fce5de6..eb7b92aa4 100644 --- a/samples/http-ajp-samples/pom.xml +++ b/samples/http-ajp-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/http-jaxws-samples/pom.xml b/samples/http-jaxws-samples/pom.xml index 90bddcc69..04c07a9f8 100644 --- a/samples/http-jaxws-samples/pom.xml +++ b/samples/http-jaxws-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml @@ -32,7 +32,7 @@ com.sun.xml.ws jaxws-rt - 4.0.1 + 4.0.2 org.glassfish.grizzly @@ -41,7 +41,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 4.0.1 + 4.0.2 diff --git a/samples/http-multipart-samples/pom.xml b/samples/http-multipart-samples/pom.xml index db8b7a010..a7c69b920 100644 --- a/samples/http-multipart-samples/pom.xml +++ b/samples/http-multipart-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/http-samples/pom.xml b/samples/http-samples/pom.xml index 7448ba404..5d66abe68 100755 --- a/samples/http-samples/pom.xml +++ b/samples/http-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/http-server-samples/pom.xml b/samples/http-server-samples/pom.xml index 313b4c6eb..f9ee4cf23 100644 --- a/samples/http-server-samples/pom.xml +++ b/samples/http-server-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/pom.xml b/samples/pom.xml index 0cb77d00b..2f90bcce4 100755 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -17,7 +17,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../pom.xml diff --git a/samples/portunif/pom.xml b/samples/portunif/pom.xml index 1b1780c57..49c0740ea 100644 --- a/samples/portunif/pom.xml +++ b/samples/portunif/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml diff --git a/samples/tls-sni-samples/pom.xml b/samples/tls-sni-samples/pom.xml index feab1c57d..0c2ab056f 100644 --- a/samples/tls-sni-samples/pom.xml +++ b/samples/tls-sni-samples/pom.xml @@ -18,7 +18,7 @@ org.glassfish.grizzly grizzly-project - 4.0.2-SNAPSHOT + 4.1.0-SNAPSHOT ../../pom.xml From 62b61107461c6d846544f3f8f3f7e3a2e1ecb5e1 Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Mon, 27 May 2024 23:39:09 +0200 Subject: [PATCH 2/2] Updates for Servlet 6.1 compatibility Signed-off-by: Arjan Tijms --- .../grizzly/http/server/Response.java | 73 ++++++------------- .../servlet/HttpServletResponseImpl.java | 11 ++- .../http/util/CookieHeaderGenerator.java | 17 +++-- .../grizzly/http/util/CookieHeaderParser.java | 32 ++++---- 4 files changed, 59 insertions(+), 74 deletions(-) diff --git a/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/Response.java b/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/Response.java index d29ff9d1e..9fb64caf7 100755 --- a/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/Response.java +++ b/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/Response.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -18,16 +19,13 @@ package org.glassfish.grizzly.http.server; import static org.glassfish.grizzly.http.util.Constants.DEFAULT_HTTP_CHARACTER_ENCODING; +import static org.glassfish.grizzly.http.util.Constants.DEFAULT_HTTP_CHARSET; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.net.MalformedURLException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.LinkedList; @@ -38,7 +36,6 @@ import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; - import org.glassfish.grizzly.CloseListener; import org.glassfish.grizzly.CloseType; import org.glassfish.grizzly.Closeable; @@ -673,7 +670,7 @@ public boolean isCommitted() { /** * Flush the current buffered content to the network. - * + * * @throws IOException if an occur occurs flushing to the wire. */ public void flush() throws IOException { @@ -954,17 +951,7 @@ public void addCookie(final Cookie cookie) { final StringBuilder sb = new StringBuilder(); // web application code can receive a IllegalArgumentException // from the appendCookieValue invokation - if (System.getSecurityManager() != null) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - CookieSerializerUtils.serializeServerCookie(sb, cookie); - return null; - } - }); - } else { - CookieSerializerUtils.serializeServerCookie(sb, cookie); - } + CookieSerializerUtils.serializeServerCookie(sb, cookie); // if we reached here, no exception, cookie is valid // the header name is Set-Cookie for both "old" and v.1 ( RFC2109 ) @@ -988,17 +975,7 @@ protected void addSessionCookieInternal(final Cookie cookie) { final StringBuilder sb = new StringBuilder(); // web application code can receive a IllegalArgumentException // from the appendCookieValue invokation - if (System.getSecurityManager() != null) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - CookieSerializerUtils.serializeServerCookie(sb, cookie); - return null; - } - }); - } else { - CookieSerializerUtils.serializeServerCookie(sb, cookie); - } + CookieSerializerUtils.serializeServerCookie(sb, cookie); final String cookieString = sb.toString(); @@ -1279,7 +1256,18 @@ public void sendError(final int status, final String message) throws IOException * @exception java.io.IOException if an input/output error occurs */ public void sendRedirect(String location) throws IOException { + sendRedirect(location, 302, appCommitted); + } + /** + * Send a temporary redirect to the specified redirect location URL. + * + * @param location Location URL to redirect to + * + * @exception IllegalStateException if this response has already been committed + * @exception java.io.IOException if an input/output error occurs + */ + public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException { if (isCommitted()) { throw new IllegalStateException("Illegal attempt to redirect the response as the response has been committed."); } @@ -1291,7 +1279,7 @@ public void sendRedirect(String location) throws IOException { try { String absolute = toAbsolute(location, true); // END RIMOD 4642650 - setStatus(HttpStatus.FOUND_302); + setStatus(HttpStatus.getHttpStatus(sc)); setHeader(Header.Location, absolute); // According to RFC2616 section 10.3.3 302 Found, @@ -1317,7 +1305,7 @@ public void sendRedirect(String location) throws IOException { getWriter().flush(); } catch (IllegalStateException ise1) { try { - getOutputStream().write(sb.toString().getBytes(org.glassfish.grizzly.http.util.Constants.DEFAULT_HTTP_CHARSET)); + getOutputStream().write(sb.toString().getBytes(DEFAULT_HTTP_CHARSET)); } catch (IllegalStateException ise2) { // ignore; the RFC says "SHOULD" so it is acceptable // to omit the body in case of an error @@ -1505,12 +1493,12 @@ public void setStatus(int status, String message) { /** * Set the HTTP status and message to be returned with this response. - * + * * @param status {@link HttpStatus} to set */ public void setStatus(HttpStatus status) { - checkResponse(); + if (isCommitted()) { return; } @@ -1563,22 +1551,7 @@ protected String toAbsolute(final String location, final boolean normalize) { final int pos = relativePath.lastIndexOf('/'); relativePath = relativePath.substring(0, pos); - final String encodedURI; - if (System.getSecurityManager() != null) { - try { - final String frelativePath = relativePath; - encodedURI = AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public String run() throws IOException { - return urlEncoder.encodeURL(frelativePath); - } - }); - } catch (PrivilegedActionException pae) { - throw new IllegalArgumentException(location, pae.getCause()); - } - } else { - encodedURI = urlEncoder.encodeURL(relativePath); - } + final String encodedURI = urlEncoder.encodeURL(relativePath); cc.append(encodedURI, 0, encodedURI.length()); cc.append('/'); @@ -1699,7 +1672,7 @@ public SuspendContext getSuspendContext() { /** * Return true if that {@link Response#suspend()} has been * invoked and set to true - * + * * @return true if that {@link Response#suspend()} has been * invoked and set to true */ @@ -1924,7 +1897,7 @@ protected synchronized boolean markCancelled(final int expectedModCount) { /** * Marks {@link Response} as cancelled, but doesn't resume associated {@link FilterChainContext} invocation. - * + * * @deprecated */ @Deprecated diff --git a/modules/http-servlet/src/main/java/org/glassfish/grizzly/servlet/HttpServletResponseImpl.java b/modules/http-servlet/src/main/java/org/glassfish/grizzly/servlet/HttpServletResponseImpl.java index 094982b6c..531d19694 100644 --- a/modules/http-servlet/src/main/java/org/glassfish/grizzly/servlet/HttpServletResponseImpl.java +++ b/modules/http-servlet/src/main/java/org/glassfish/grizzly/servlet/HttpServletResponseImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -459,7 +459,14 @@ public void sendError(int sc) throws IOException { */ @Override public void sendRedirect(String location) throws IOException { + if (isCommitted()) { + throw new IllegalStateException("Illegal attempt to redirect the response after it has been committed."); + } + response.sendRedirect(location); + } + @Override + public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException { if (isCommitted()) { throw new IllegalStateException("Illegal attempt to redirect the response after it has been committed."); } @@ -639,4 +646,6 @@ public void setTrailerFields(final Supplier> supplier) { public Supplier> getTrailerFields() { return response.getTrailers(); } + + } diff --git a/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderGenerator.java b/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderGenerator.java index 78560c903..6ca04b4b8 100644 --- a/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderGenerator.java +++ b/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright 2004, 2022 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -89,8 +89,13 @@ public static String generateHeader(String name, String value, int maxAge, Strin // RFC 6265 prefers Max-Age to Expires but... (see below) if (maxAge > -1) { // Negative Max-Age is equivalent to no Max-Age - header.append("; Max-Age="); - header.append(maxAge); + + // Max age 0 is omit Max-Age itself, but conditionally (see below) + // add Expires + if (maxAge > 0) { + header.append("; Max-Age="); + header.append(maxAge); + } if (CookieUtils.ALWAYS_ADD_EXPIRES) { // Microsoft IE and Microsoft Edge don't understand Max-Age so send @@ -149,8 +154,10 @@ public static String generateHeader(String name, String value, int maxAge, Strin validateAttribute(entry.getKey(), entry.getValue()); header.append("; "); header.append(entry.getKey()); - header.append('='); - header.append(entry.getValue()); + if (!"".equals(entry.getValue())) { + header.append('='); + header.append(entry.getValue()); + } } } } diff --git a/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderParser.java b/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderParser.java index b6ea633b1..eea8681c9 100644 --- a/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderParser.java +++ b/modules/http/src/main/java/org/glassfish/grizzly/http/util/CookieHeaderParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright 2004, 2022 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -194,26 +194,22 @@ private static SkipResult skipByte(ByteBuffer byteBuffer, byte target) { */ private static ByteBuffer readCookieValueRfc6265(ByteBuffer byteBuffer) { boolean quoted = false; - if (byteBuffer.hasRemaining()) { - if (byteBuffer.get() == QUOTE_BYTE) { - quoted = true; - } else { - byteBuffer.rewind(); - } - } - int start = byteBuffer.position(); - int end = byteBuffer.limit(); + int cookieValueStart = byteBuffer.position(); + int cookieValueEnd = byteBuffer.limit(); + while (byteBuffer.hasRemaining()) { - byte b = byteBuffer.get(); - if (isCookieOctet[(b & 0xFF)]) { + byte byteFromBuffer = byteBuffer.get(); + if (isCookieOctet[(byteFromBuffer & 0xFF)]) { // NO-OP - } else if (b == SEMICOLON_BYTE || b == SPACE_BYTE || b == TAB_BYTE) { - end = byteBuffer.position() - 1; - byteBuffer.position(end); + } else if (byteFromBuffer == SEMICOLON_BYTE || byteFromBuffer == SPACE_BYTE || byteFromBuffer == TAB_BYTE) { + cookieValueEnd = byteBuffer.position() - 1; + byteBuffer.position(cookieValueEnd); break; - } else if (quoted && b == QUOTE_BYTE) { - end = byteBuffer.position() - 1; + } else if (byteFromBuffer == QUOTE_BYTE && cookieValueStart == byteBuffer.position() -1) { + quoted = true; + } else if (quoted && byteFromBuffer == QUOTE_BYTE) { + cookieValueEnd = byteBuffer.position(); break; } else { // Invalid cookie @@ -221,7 +217,7 @@ private static ByteBuffer readCookieValueRfc6265(ByteBuffer byteBuffer) { } } - return new ByteBuffer(byteBuffer.bytes, start, end - start); + return new ByteBuffer(byteBuffer.bytes, cookieValueStart, cookieValueEnd - cookieValueStart); }