You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/02/10 19:50:57 UTC
[tomcat] branch 8.5.x updated: Remove PushBuilder from the Servlet
4.0 API preview package
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 45f6c01 Remove PushBuilder from the Servlet 4.0 API preview package
45f6c01 is described below
commit 45f6c010d93ab3f0c391c4107871f2b0d27dfb84
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Feb 10 19:48:48 2020 +0000
Remove PushBuilder from the Servlet 4.0 API preview package
---
java/org/apache/catalina/connector/Request.java | 16 +-
.../apache/catalina/connector/RequestFacade.java | 13 +-
.../catalina/core/ApplicationHttpRequest.java | 4 +-
.../catalina/core/ApplicationPushBuilder.java | 18 +-
.../apache/catalina/filters/RemoteIpFilter.java | 15 --
.../servlet4preview/http/HttpServletRequest.java | 16 --
.../http/HttpServletRequestWrapper.java | 14 --
.../catalina/servlet4preview/http/PushBuilder.java | 196 ---------------------
webapps/docs/changelog.xml | 6 +
9 files changed, 16 insertions(+), 282 deletions(-)
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index c4b6554..a38e97a 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -82,7 +82,6 @@ import org.apache.catalina.core.ApplicationSessionCookieConfig;
import org.apache.catalina.core.AsyncContextImpl;
import org.apache.catalina.mapper.MappingData;
import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.session.ManagerBase;
import org.apache.catalina.util.ParameterMap;
import org.apache.catalina.util.TLSUtil;
@@ -2004,21 +2003,12 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
}
- // --------------------------------------------- HttpServletRequest Methods
-
- /**
- * Pulled forward from Servlet 4.0. The method signature may be modified,
- * removed or replaced at any time until Servlet 4.0 becomes final.
- *
- * @return A builder to use to construct the push request
- */
- @Override
- public PushBuilder newPushBuilder() {
+ public ApplicationPushBuilder newPushBuilder() {
return newPushBuilder(this);
}
- public PushBuilder newPushBuilder(HttpServletRequest request) {
+ public ApplicationPushBuilder newPushBuilder(HttpServletRequest request) {
AtomicBoolean result = new AtomicBoolean();
coyoteRequest.action(ActionCode.IS_PUSH_SUPPORTED, result);
if (result.get()) {
@@ -2029,6 +2019,8 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
}
+ // --------------------------------------------- HttpServletRequest Methods
+
/**
* {@inheritDoc}
*
diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java
index 23146ed..41d0dde 100644
--- a/java/org/apache/catalina/connector/RequestFacade.java
+++ b/java/org/apache/catalina/connector/RequestFacade.java
@@ -40,10 +40,10 @@ import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.Part;
import org.apache.catalina.Globals;
+import org.apache.catalina.core.ApplicationPushBuilder;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.servlet4preview.http.HttpServletMapping;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
-import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -1128,19 +1128,12 @@ public class RequestFacade implements HttpServletRequest {
}
- public PushBuilder newPushBuilder(javax.servlet.http.HttpServletRequest request) {
+ public ApplicationPushBuilder newPushBuilder(javax.servlet.http.HttpServletRequest request) {
return this.request.newPushBuilder(request);
}
- /**
- * {@inheritDoc}
- * <p>
- * Pulled forward from Servlet 4.0. The method signature may be modified,
- * removed or replaced at any time until Servlet 4.0 becomes final.
- */
- @Override
- public PushBuilder newPushBuilder() {
+ public ApplicationPushBuilder newPushBuilder() {
return request.newPushBuilder();
}
}
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 3277d9a..2bb795c 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -43,7 +43,6 @@ import org.apache.catalina.Manager;
import org.apache.catalina.Session;
import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.servlet4preview.http.HttpServletMapping;
-import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.util.ParameterMap;
import org.apache.catalina.util.URLEncoder;
import org.apache.tomcat.util.buf.B2CConverter;
@@ -639,8 +638,7 @@ class ApplicationHttpRequest
}
- @Override
- public PushBuilder newPushBuilder() {
+ public ApplicationPushBuilder newPushBuilder() {
ServletRequest current = getRequest();
while (current instanceof ServletRequestWrapper) {
current = ((ServletRequestWrapper) current).getRequest();
diff --git a/java/org/apache/catalina/core/ApplicationPushBuilder.java b/java/org/apache/catalina/core/ApplicationPushBuilder.java
index 3c8e99e..98ba60d 100644
--- a/java/org/apache/catalina/core/ApplicationPushBuilder.java
+++ b/java/org/apache/catalina/core/ApplicationPushBuilder.java
@@ -35,7 +35,6 @@ import javax.servlet.http.HttpSession;
import org.apache.catalina.Context;
import org.apache.catalina.authenticator.AuthenticatorBase;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.util.SessionConfig;
import org.apache.coyote.ActionCode;
import org.apache.tomcat.util.buf.HexUtils;
@@ -45,7 +44,7 @@ import org.apache.tomcat.util.http.CookieProcessor;
import org.apache.tomcat.util.http.parser.HttpParser;
import org.apache.tomcat.util.res.StringManager;
-public class ApplicationPushBuilder implements PushBuilder {
+public class ApplicationPushBuilder {
private static final StringManager sm = StringManager.getManager(ApplicationPushBuilder.class);
private static final Set<String> DISALLOWED_METHODS = new HashSet<>();
@@ -176,7 +175,7 @@ public class ApplicationPushBuilder implements PushBuilder {
}
}
- @Override
+
public ApplicationPushBuilder path(String path) {
if (path.startsWith("/")) {
this.path = path;
@@ -193,13 +192,11 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public String getPath() {
return path;
}
- @Override
public ApplicationPushBuilder method(String method) {
String upperMethod = method.trim().toUpperCase(Locale.ENGLISH);
if (DISALLOWED_METHODS.contains(upperMethod) || upperMethod.length() == 0) {
@@ -218,39 +215,33 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public String getMethod() {
return method;
}
- @Override
public ApplicationPushBuilder queryString(String queryString) {
this.queryString = queryString;
return this;
}
- @Override
public String getQueryString() {
return queryString;
}
- @Override
public ApplicationPushBuilder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}
- @Override
public String getSessionId() {
return sessionId;
}
- @Override
public ApplicationPushBuilder addHeader(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
@@ -263,7 +254,6 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public ApplicationPushBuilder setHeader(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
@@ -278,7 +268,6 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public ApplicationPushBuilder removeHeader(String name) {
headers.remove(name);
@@ -286,13 +275,11 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public Set<String> getHeaderNames() {
return Collections.unmodifiableSet(headers.keySet());
}
- @Override
public String getHeader(String name) {
List<String> values = headers.get(name);
if (values == null) {
@@ -303,7 +290,6 @@ public class ApplicationPushBuilder implements PushBuilder {
}
- @Override
public void push() {
if (path == null) {
throw new IllegalStateException(sm.getString("pushBuilder.noPath"));
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java
index d22233f..50bcb5e 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -31,7 +31,6 @@ import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestWrapper;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
@@ -39,8 +38,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.AccessLog;
import org.apache.catalina.Globals;
-import org.apache.catalina.connector.RequestFacade;
-import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -644,18 +641,6 @@ public class RemoteIpFilter implements Filter {
return url;
}
-
- public PushBuilder getPushBuilder() {
- ServletRequest current = getRequest();
- while (current instanceof ServletRequestWrapper) {
- current = ((ServletRequestWrapper) current).getRequest();
- }
- if (current instanceof RequestFacade) {
- return ((RequestFacade) current).newPushBuilder(this);
- } else {
- return null;
- }
- }
}
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
index e460762..64ac62b 100644
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
+++ b/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
@@ -22,20 +22,4 @@ package org.apache.catalina.servlet4preview.http;
public interface HttpServletRequest extends javax.servlet.http.HttpServletRequest {
public HttpServletMapping getHttpServletMapping();
-
- /**
- * Obtain a builder for generating push requests. {@link PushBuilder}
- * documents how this request will be used as the basis for a push request.
- * Each call to this method will return a new instance, independent of any
- * previous instance obtained.
- *
- * @return A builder that can be used to generate push requests based on
- * this request or {@code null} if push is not supported. Note that
- * even if a PushBuilder instance is returned, by the time that
- * {@link PushBuilder#push()} is called, it may no longer be valid
- * to push a request and the push request will be ignored.
- *
- * @since Servlet 4.0
- */
- public PushBuilder newPushBuilder();
}
diff --git a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java b/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
index dc31764..67b6efa 100644
--- a/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
+++ b/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
@@ -50,18 +50,4 @@ public class HttpServletRequestWrapper extends javax.servlet.http.HttpServletReq
public HttpServletMapping getHttpServletMapping() {
return this._getHttpServletRequest().getHttpServletMapping();
}
-
- /**
- * {@inheritDoc}
- * <p>
- * The default behavior of this method is to return
- * {@link HttpServletRequest#newPushBuilder()} on the wrapped request
- * object.
- *
- * @since Servlet 4.0
- */
- @Override
- public PushBuilder newPushBuilder() {
- return this._getHttpServletRequest().newPushBuilder();
- }
}
diff --git a/java/org/apache/catalina/servlet4preview/http/PushBuilder.java b/java/org/apache/catalina/servlet4preview/http/PushBuilder.java
deleted file mode 100644
index 2ece00d..0000000
--- a/java/org/apache/catalina/servlet4preview/http/PushBuilder.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.catalina.servlet4preview.http;
-
-import java.util.Set;
-
-/**
- * Builds a push request based on the {@link HttpServletRequest} from which this
- * builder was obtained. The push request will be constructed on the following
- * basis:
- * <ul>
- * <li>The request method is set to <code>GET</code>.</li>
- * <li>The path will not be set. This must be set explicitly via a call to
- * {@link #path(String)}.</li>
- * <li>Conditional, range, expectation, authorization and referer headers will
- * be removed.</li>
- * <li>Cookies added to the associated response will be added to the push
- * request unless maxAge <= 0 in which case any request cookie with the
- * same name will be removed.</li>
- * <li>The referer header will be set to
- * {@link HttpServletRequest#getRequestURL()} plus, if present, the query
- * string from {@link HttpServletRequest#getQueryString()}.
- * </ul>
- *
- * @since Servlet 4.0
- */
-public interface PushBuilder {
-
- /**
- * Specify the HTTP method to use for the push request.
- *
- * @param method The method to use for the push request
- *
- * @return This builder instance
- *
- * @throws IllegalArgumentException if an HTTP method is specified that is
- * known not to be <a
- * href="https://tools.ietf.org/html/rfc7540#section-8.2">cacheable
- * and safe</a>. POST, PUT, DELETE, CONNECT, OPTIONS and TRACE will
- * trigger the exception.
- */
- PushBuilder method(String method);
-
- /**
- * Specifies the query string to use in subsequent push requests generated
- * by a call to {@link #push()}. This will be appended to any query string
- * specified in the call to {@link #path(String)}.
- *
- * @param queryString The query string to use to generate push requests
- *
- * @return This builder instance
- */
- PushBuilder queryString(String queryString);
-
- /**
- * Specifies the session ID to use in subsequent push requests generated
- * by a call to {@link #push()}. The session ID will be presented the same
- * way as it is on the original request (cookie or URL parameter). The
- * default is determined in the following order:
- * <ul>
- * <li>the requested session ID for the originating request</li>
- * <li>the session ID generated in the originated request</li>
- * <li>{@code null}</li>
- * </ul>
- *
- * @param sessionId The session ID to use to generate push requests
- *
- * @return This builder instance
- */
- PushBuilder sessionId(String sessionId);
-
- /**
- * Sets an HTTP header on the request. Any existing headers of the same name
- * are first remove.
- *
- * @param name The name of the header to set
- * @param value The value of the header to set
- *
- * @return This builder instance
- */
- PushBuilder setHeader(String name, String value);
-
- /**
- * Adds an HTTP header to the request.
- *
- * @param name The name of the header to add
- * @param value The value of the header to add
- *
- * @return This builder instance
- */
- PushBuilder addHeader(String name, String value);
-
- /**
- * Removes an HTTP header from the request.
- *
- * @param name The name of the header to remove
- *
- * @return This builder instance
- */
- PushBuilder removeHeader(String name);
-
- /**
- * Sets the URI path to be used for the push request. This must be called
- * before every call to {@link #push()}. If the path includes a query
- * string, the query string will be appended to the existing query string
- * (if any) and no de-duplication will occur.
- *
- * @param path Paths beginning with '/' are treated as absolute paths. All
- * other paths are treated as relative to the context path of
- * the request used to create this builder instance. The path
- * may include a query string.
- *
- * @return This builder instance
- */
- PushBuilder path(String path);
-
- /**
- * Generates the push request and sends it to the client unless pushes are
- * not available for some reason. After calling this method the following
- * fields are set to {@code null}:
- * <ul>
- * <li>{@code path}</li>
- * <li>conditional request headers ({@code if-none-match} and
- * {@code if-modified-since})</li>
- * </ul>
- *
- * @throws IllegalStateException If this method is called when {@code path}
- * is {@code null}
- * @throws IllegalArgumentException If the request to push requires a body
- */
- void push();
-
- /**
- * Obtain the name of the HTTP method that will be used for push requests
- * generated by future calls to {@code push()}.
- *
- * @return The HTTP method to be used for future push requests
- */
- String getMethod();
-
- /**
- * Obtain the query string that will be used for push requests generated by
- * future calls to {@code push()}.
- *
- * @return The query string that will be appended to push requests.
- */
- String getQueryString();
-
- /**
- * Obtain the session ID that will be used for push requests generated by
- * future calls to {@code push()}.
- *
- * @return The session that will be used for push requests.
- */
- String getSessionId();
-
- /**
- * @return The current set of names of HTTP headers to be used the next time
- * {@code push()} is called.
- */
- Set<String> getHeaderNames();
-
- /**
- * Obtain a value for the given HTTP header.
- * TODO Servlet 4.0
- * Clarify the behaviour of this method
- *
- * @param name The name of the header whose value is to be returned
- *
- * @return The value of the given header. If multiple values are defined
- * then any may be returned
- */
- String getHeader(String name);
-
- /**
- * Obtain the path that will be used for the push request that will be
- * generated by the next call to {@code push()}.
- *
- * @return The path value that will be associated with the next push request
- */
- String getPath();
-}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 7ffd7af..29ec984 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -56,6 +56,12 @@
<code>HTTP_HOST</code> variable rather than extracting it from the
<code>Host</code> header as this allows HTTP/2 to be supported. (markt)
</fix>
+ <scode>
+ Remove <code>PushBuilder</code> from the deprecated Servlet 4 Preview
+ API. Users still depending on this feature should ideally upgrade to
+ Tomcat 9.0.x. If upgrade is not possible, application code should cast
+ to the internal Tomcat implementation classes. (markt)
+ </scode>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org