Switch to javax.servlet:3.1.0
Implement new required methods for Servlet 3.1 in test classes:
Servlet 3.1 introduces several new abstract methods on interfaces or
classes that existed in servlet 2.5. Provide a mimimal, throwing
implementation that largely allows servlet 2.5-written classes to
compile and run using servlet 3.1.
PiperOrigin-RevId: 417877794
Change-Id: I9fe856fab678ede1b58dd7c0731bc5ed5927ed49
diff --git a/WORKSPACE b/WORKSPACE
index 1fd87c1..6404298 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -105,12 +105,6 @@
)
maven_jar(
- name = "servlet-api_2_5",
- artifact = "org.eclipse.jetty.orbit:javax.servlet:2.5.0.v201103041518",
- sha1 = "9c16011c06bc6fe5e9dba080fcb40ddb4b75dc85",
-)
-
-maven_jar(
name = "servlet-api",
artifact = "javax.servlet:javax.servlet-api:3.1.0",
sha1 = "3cd63d075497751784b2fa84be59432f4905bf7c",
diff --git a/java/com/google/gitiles/BUILD b/java/com/google/gitiles/BUILD
index 8e79933..4b0850a 100644
--- a/java/com/google/gitiles/BUILD
+++ b/java/com/google/gitiles/BUILD
@@ -30,7 +30,7 @@
java_library(
name = "servlet-api",
neverlink = 1,
- exports = ["//lib:servlet-api_2_5"],
+ exports = ["//lib:servlet-api"],
)
java_library(
diff --git a/javatests/com/google/gitiles/BUILD b/javatests/com/google/gitiles/BUILD
index 5469beb..cfb3eae 100644
--- a/javatests/com/google/gitiles/BUILD
+++ b/javatests/com/google/gitiles/BUILD
@@ -19,7 +19,7 @@
deps = DEPS + [
"//java/com/google/gitiles:servlet",
"//lib:jsr305",
- "//lib:servlet-api_2_5",
+ "//lib:servlet-api",
"//lib/truth",
"//lib:jgit-junit",
"//lib/junit",
@@ -40,7 +40,7 @@
deps = DEPS + [
"//java/com/google/gitiles:servlet",
":testutil",
- "//lib:servlet-api_2_5",
+ "//lib:servlet-api",
"//lib/truth",
"//lib:jgit-junit",
"//lib/junit",
diff --git a/javatests/com/google/gitiles/FakeHttpServletRequest.java b/javatests/com/google/gitiles/FakeHttpServletRequest.java
index ba94c3e..14ddd59 100644
--- a/javatests/com/google/gitiles/FakeHttpServletRequest.java
+++ b/javatests/com/google/gitiles/FakeHttpServletRequest.java
@@ -25,6 +25,7 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.security.Principal;
@@ -34,11 +35,20 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
import org.eclipse.jgit.http.server.ServletUtils;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
@@ -101,6 +111,11 @@
}
@Override
+ public long getContentLengthLong() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public String getContentType() {
return null;
}
@@ -126,6 +141,41 @@
}
@Override
+ public ServletContext getServletContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public AsyncContext startAsync() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public DispatcherType getDispatcherType() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public Locale getLocale() {
return Locale.US;
}
@@ -353,6 +403,11 @@
}
@Override
+ public String changeSessionId() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public HttpSession getSession(boolean create) {
throw new UnsupportedOperationException();
}
@@ -379,6 +434,37 @@
}
@Override
+ public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void login(String username, String password) throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void logout() throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Collection<Part> getParts() throws IOException, ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Part getPart(String name) throws IOException, ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass)
+ throws IOException, ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public boolean isRequestedSessionIdValid() {
throw new UnsupportedOperationException();
}
diff --git a/javatests/com/google/gitiles/FakeHttpServletResponse.java b/javatests/com/google/gitiles/FakeHttpServletResponse.java
index 2cf316d..ff20cea 100644
--- a/javatests/com/google/gitiles/FakeHttpServletResponse.java
+++ b/javatests/com/google/gitiles/FakeHttpServletResponse.java
@@ -28,8 +28,10 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
+import java.util.Collection;
import java.util.Locale;
import javax.servlet.ServletOutputStream;
+import javax.servlet.WriteListener;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.util.RawParseUtils;
@@ -84,6 +86,16 @@
outputStream =
new ServletOutputStream() {
@Override
+ public boolean isReady() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWriteListener(WriteListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public void write(int c) throws IOException {
osWriter.write(c);
osWriter.flush();
@@ -134,6 +146,11 @@
}
@Override
+ public void setContentLengthLong(long length) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public void setContentType(String type) {
headers.removeAll(HttpHeaders.CONTENT_TYPE);
headers.put(HttpHeaders.CONTENT_TYPE, type);
@@ -240,6 +257,7 @@
committed = true;
}
+ @Override
public synchronized int getStatus() {
return status;
}
@@ -252,10 +270,21 @@
return RawParseUtils.decode(getActualBody());
}
+ @Override
public String getHeader(String name) {
return Iterables.getFirst(headers.get(checkNotNull(name)), null);
}
+ @Override
+ public Collection<String> getHeaders(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Collection<String> getHeaderNames() {
+ throw new UnsupportedOperationException();
+ }
+
private PrintWriter newPrintWriter() {
return new PrintWriter(new OutputStreamWriter(actualBody, UTF_8));
}
diff --git a/lib/BUILD b/lib/BUILD
index 0f9620e..a0dfa57 100644
--- a/lib/BUILD
+++ b/lib/BUILD
@@ -17,7 +17,6 @@
"gfm-tables",
"html-types",
"jsr305",
- "servlet-api_2_5",
"servlet-api",
"gson",
"guava",
diff --git a/lib/jetty/BUILD b/lib/jetty/BUILD
index 521fd22..3a35ef5 100644
--- a/lib/jetty/BUILD
+++ b/lib/jetty/BUILD
@@ -8,7 +8,7 @@
name = "servlet",
exports = [
":security",
- "//lib:servlet-api", # Different from the rest of gitiles-server.
+ "//lib:servlet-api",
"@servlet//jar",
],
)