From b31437b69d02fe4a71c7b01ee55674e8fedb5c25 Mon Sep 17 00:00:00 2001 From: Benito Gonzalez Date: Fri, 10 Nov 2023 21:03:15 -0800 Subject: [PATCH] chore: upgrade to servlet 3.1.0 (#2731) * chore: upgrade to servlet 3.1.0 * chore: code format --- gradle.properties | 2 +- .../rendering/LazyServletOutputStream.java | 11 +++++++++++ .../utils/DelegatingServletOutputStream.java | 17 +++++++++++++++-- .../web/AbstractHttpServletRequestWrapper.java | 17 +++++++++++++++++ .../web/AbstractHttpServletResponseWrapper.java | 5 +++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 03029186839..995f399e908 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,7 +34,7 @@ projectLicenseDistribution=repo projectIssueSystem=GITHUB projectIssueUrl=https://github.com/uPortal-Project/uPortal/issues -servletApiDependency=javax.servlet:javax.servlet-api:3.0.1 +servletApiDependency=javax.servlet:javax.servlet-api:3.1.0 portletApiDependency=org.apache.portals:portlet-api_2.1.0_spec:1.0 # Dependency Versions diff --git a/uPortal-rendering/src/main/java/org/apereo/portal/portlet/rendering/LazyServletOutputStream.java b/uPortal-rendering/src/main/java/org/apereo/portal/portlet/rendering/LazyServletOutputStream.java index 1f0b03bf9f8..1bd5584c495 100644 --- a/uPortal-rendering/src/main/java/org/apereo/portal/portlet/rendering/LazyServletOutputStream.java +++ b/uPortal-rendering/src/main/java/org/apereo/portal/portlet/rendering/LazyServletOutputStream.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.util.concurrent.Callable; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; public class LazyServletOutputStream extends ServletOutputStream { private final Callable servletOutputStreamCreator; @@ -139,4 +140,14 @@ public void println(float f) throws IOException { public void println(double d) throws IOException { getServletOutputStream().println(d); } + + @Override + public boolean isReady() { + return this.servletOutputStream != null && this.servletOutputStream.isReady(); + } + + @Override + public void setWriteListener(WriteListener writeListener) { + getServletOutputStream().setWriteListener(writeListener); + } } diff --git a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/DelegatingServletOutputStream.java b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/DelegatingServletOutputStream.java index 4de0450d224..84eba70bf05 100644 --- a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/DelegatingServletOutputStream.java +++ b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/DelegatingServletOutputStream.java @@ -14,9 +14,12 @@ */ package org.apereo.portal.utils; +import com.sun.istack.NotNull; import java.io.IOException; import java.io.OutputStream; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; +import org.apache.commons.lang.NotImplementedException; /** {@link ServletOutputStream} impl that delegates to an {@link OutputStream} */ public class DelegatingServletOutputStream extends ServletOutputStream { @@ -32,12 +35,12 @@ public void write(int b) throws IOException { } @Override - public void write(byte[] b) throws IOException { + public void write(@NotNull byte[] b) throws IOException { outputStream.write(b); } @Override - public void write(byte[] b, int off, int len) throws IOException { + public void write(@NotNull byte[] b, int off, int len) throws IOException { outputStream.write(b, off, len); } @@ -50,4 +53,14 @@ public void flush() throws IOException { public void close() throws IOException { outputStream.close(); } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) { + throw new NotImplementedException("setWriteListener() not implemented"); + } } diff --git a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletRequestWrapper.java b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletRequestWrapper.java index 9539242cc5b..efb279fb961 100644 --- a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletRequestWrapper.java +++ b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletRequestWrapper.java @@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpUpgradeHandler; import javax.servlet.http.Part; import org.apache.commons.lang.Validate; @@ -387,4 +388,20 @@ public void login(String uid, String password) throws ServletException { public void logout() throws ServletException { this.httpServletRequest.logout(); } + + @Override + public long getContentLengthLong() { + return this.httpServletRequest.getContentLengthLong(); + } + + @Override + public String changeSessionId() { + return this.httpServletRequest.changeSessionId(); + } + + @Override + public T upgrade(Class aClass) + throws IOException, ServletException { + return this.httpServletRequest.upgrade(aClass); + } } diff --git a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletResponseWrapper.java b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletResponseWrapper.java index afede8f0964..fc6612a0c2e 100644 --- a/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletResponseWrapper.java +++ b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/web/AbstractHttpServletResponseWrapper.java @@ -157,6 +157,11 @@ public void setContentLength(int len) { this.httpServletResponse.setContentLength(len); } + @Override + public void setContentLengthLong(long len) { + this.httpServletResponse.setContentLengthLong(len); + } + @Override public void setContentType(String type) { this.httpServletResponse.setContentType(type);