This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a846e4abf0b5b6307c34c52c1063dca4d3526354 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Jul 29 21:05:19 2019 +0100 Deprecate FastDateFormat.RFC1123_DATE --- java/org/apache/catalina/connector/Request.java | 32 ++++++++++++++++------ java/org/apache/catalina/connector/Response.java | 22 ++++----------- .../tomcat/util/http/FastHttpDateFormat.java | 3 ++ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index 11c64bb..53f3925 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -119,10 +119,10 @@ public class Request implements HttpServletRequest { // ----------------------------------------------------------- Constructors public Request() { - formats[0].setTimeZone(GMT_ZONE); - formats[1].setTimeZone(GMT_ZONE); - formats[2].setTimeZone(GMT_ZONE); - + formats = new SimpleDateFormat[formatsTemplate.length]; + for(int i = 0; i < formats.length; i++) { + formats[i] = (SimpleDateFormat) formatsTemplate[i].clone(); + } } @@ -156,6 +156,10 @@ public class Request implements HttpServletRequest { // ----------------------------------------------------- Variables + /** + * @deprecated Unused. This will be removed in Tomcat 10. + */ + @Deprecated protected static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT"); @@ -176,11 +180,17 @@ public class Request implements HttpServletRequest { * * Notice that because SimpleDateFormat is not thread-safe, we can't * declare formats[] as a static variable. + * + * @deprecated Unused. This will be removed in Tomcat 10 */ - protected SimpleDateFormat formats[] = { - new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), - new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), - new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) + @Deprecated + protected final SimpleDateFormat formats[]; + + @Deprecated + private static final SimpleDateFormat formatsTemplate[] = { + new SimpleDateFormat(FastHttpDateFormat.RFC1123_DATE, Locale.US), + new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), + new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; @@ -2231,7 +2241,7 @@ public class Request implements HttpServletRequest { } // Attempt to convert the date header in a variety of formats - long result = FastHttpDateFormat.parseDate(value, formats); + long result = FastHttpDateFormat.parseDate(value); if (result != (-1L)) { return result; } @@ -3663,5 +3673,9 @@ public class Request implements HttpServletRequest { // NO-OP } }); + + for (SimpleDateFormat sdf : formatsTemplate) { + sdf.setTimeZone(GMT_ZONE); + } } } diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java index 1d45bf7..2d5c558 100644 --- a/java/org/apache/catalina/connector/Response.java +++ b/java/org/apache/catalina/connector/Response.java @@ -31,7 +31,6 @@ import java.util.Collection; import java.util.Enumeration; import java.util.List; import java.util.Locale; -import java.util.TimeZone; import javax.servlet.ServletOutputStream; import javax.servlet.SessionTrackingMode; @@ -43,7 +42,6 @@ import org.apache.catalina.Globals; import org.apache.catalina.Session; import org.apache.catalina.Wrapper; import org.apache.catalina.security.SecurityUtil; -import org.apache.catalina.util.DateTool; import org.apache.catalina.util.RequestUtil; import org.apache.catalina.util.SessionConfig; import org.apache.juli.logging.Log; @@ -98,7 +96,10 @@ public class Response implements HttpServletResponse { /** * The date format we will use for creating date headers. + * + * @deprecated Unused. This will be removed in Tomcat 10 */ + @Deprecated protected SimpleDateFormat format = null; @@ -1058,14 +1059,7 @@ public class Response implements HttpServletResponse { return; } - if (format == null) { - format = new SimpleDateFormat(DateTool.HTTP_RESPONSE_DATE_HEADER, - Locale.US); - format.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - addHeader(name, FastHttpDateFormat.formatDate(value, format)); - + addHeader(name, FastHttpDateFormat.formatDate(value)); } @@ -1416,13 +1410,7 @@ public class Response implements HttpServletResponse { return; } - if (format == null) { - format = new SimpleDateFormat(DateTool.HTTP_RESPONSE_DATE_HEADER, - Locale.US); - format.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - setHeader(name, FastHttpDateFormat.formatDate(value, format)); + setHeader(name, FastHttpDateFormat.formatDate(value)); } diff --git a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java index 4f787a2..66a767a 100644 --- a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java +++ b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java @@ -41,7 +41,10 @@ public final class FastHttpDateFormat { /** * The only date format permitted when generating HTTP headers. + * + * @deprecated Unused. This will be removed in Tomcat 10. */ + @Deprecated public static final String RFC1123_DATE = "EEE, dd MMM yyyy HH:mm:ss zzz"; // HTTP date formats --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org