Skip to content

Commit

Permalink
chore: upgrade to servlet 3.1.0 (#2731)
Browse files Browse the repository at this point in the history
* chore: upgrade to servlet 3.1.0

* chore: code format
  • Loading branch information
bjagg authored Nov 11, 2023
1 parent e96ce86 commit b31437b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServletOutputStream> servletOutputStreamCreator;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 extends HttpUpgradeHandler> T upgrade(Class<T> aClass)
throws IOException, ServletException {
return this.httpServletRequest.upgrade(aClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b31437b

Please sign in to comment.