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 2008/09/29 18:26:30 UTC
svn commit: r700167 - in /tomcat/trunk/java/org/apache:
catalina/ssi/ResponseIncludeWrapper.java tomcat/util/buf/DateTool.java
tomcat/util/buf/MessageBytes.java tomcat/util/http/ServerCookie.java
Author: markt
Date: Mon Sep 29 09:26:29 2008
New Revision: 700167
URL: http://svn.apache.org/viewvc?rev=700167&view=rev
Log:
Remove the deprecated DateTool and some other (all bar one) deprecated methods that depended on it. Update SSI and ServerCookie to use local formats in a thread safe way.
Removed:
tomcat/trunk/java/org/apache/tomcat/util/buf/DateTool.java
Modified:
tomcat/trunk/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java
tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java
Modified: tomcat/trunk/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java?rev=700167&r1=700166&r2=700167&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ssi/ResponseIncludeWrapper.java Mon Sep 29 09:26:29 2008
@@ -22,6 +22,8 @@
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Locale;
+import java.util.TimeZone;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
@@ -29,7 +31,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
-import org.apache.catalina.util.DateTool;
/**
* A HttpServletResponseWrapper, used from
* <code>SSIServletExternalResolver</code>
@@ -44,8 +45,9 @@
*/
private static final String CONTENT_TYPE = "content-type";
private static final String LAST_MODIFIED = "last-modified";
- private static final DateFormat format =
- new SimpleDateFormat(DateTool.RFC1123_PATTERN, DateTool.LOCALE_US);
+ private static final DateFormat RFC1123_FORMAT;
+ private final static String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z";
+
protected long lastModified = -1;
private String contentType = null;
@@ -59,7 +61,11 @@
private ServletContext context;
private HttpServletRequest request;
-
+ static {
+ RFC1123_FORMAT = new SimpleDateFormat(RFC1123_PATTERN, Locale.US);
+ RFC1123_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
/**
* Initialize our wrapper with the current HttpServletResponse and
* ServletOutputStream.
@@ -212,8 +218,8 @@
String lname = name.toLowerCase();
if (lname.equals(LAST_MODIFIED)) {
try {
- synchronized(format) {
- lastModified = format.parse(value).getTime();
+ synchronized(RFC1123_FORMAT) {
+ lastModified = RFC1123_FORMAT.parse(value).getTime();
}
} catch (Throwable ignore) { }
} else if (lname.equals(CONTENT_TYPE)) {
@@ -234,8 +240,8 @@
String lname = name.toLowerCase();
if (lname.equals(LAST_MODIFIED)) {
try {
- synchronized(format) {
- lastModified = format.parse(value).getTime();
+ synchronized(RFC1123_FORMAT) {
+ lastModified = RFC1123_FORMAT.parse(value).getTime();
}
} catch (Throwable ignore) { }
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java?rev=700167&r1=700166&r2=700167&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java Mon Sep 29 09:26:29 2008
@@ -547,31 +547,6 @@
private Date dateValue;
private boolean hasDateValue=false;
- /**
- * @deprecated The buffer are general purpose, caching for headers should
- * be done in headers. The second parameter allows us to pass a date format
- * instance to avoid synchronization problems.
- */
- public void setTime(long t, DateFormat df) {
- // XXX replace it with a byte[] tool
- recycle();
- if( dateValue==null)
- dateValue=new Date(t);
- else
- dateValue.setTime(t);
- if( df==null )
- strValue=DateTool.format1123(dateValue);
- else
- strValue=DateTool.format1123(dateValue,df);
- hasStrValue=true;
- hasDateValue=true;
- type=T_STR;
- }
-
- public void setTime(long t) {
- setTime( t, null );
- }
-
/** Set the buffer to the representation of an int
*/
public void setInt(int i) {
@@ -658,27 +633,6 @@
type=T_BYTES;
}
- /**
- * @deprecated The buffer are general purpose, caching for headers should
- * be done in headers
- */
- public long getTime()
- {
- if( hasDateValue ) {
- if( dateValue==null) return -1;
- return dateValue.getTime();
- }
-
- long l=DateTool.parseDate( this );
- if( dateValue==null)
- dateValue=new Date(l);
- else
- dateValue.setTime(l);
- hasDateValue=true;
- return l;
- }
-
-
// Used for headers conversion
/** Convert the buffer to an int, cache the value
*/
Modified: tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java?rev=700167&r1=700166&r2=700167&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java Mon Sep 29 09:26:29 2008
@@ -18,11 +18,14 @@
package org.apache.tomcat.util.http;
import java.io.Serializable;
+import java.text.DateFormat;
import java.text.FieldPosition;
+import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.DateTool;
import org.apache.tomcat.util.buf.MessageBytes;
@@ -51,6 +54,19 @@
private int maxAge = -1;
private int version = 0;
+ // Other fields
+ private static final String OLD_COOKIE_PATTERN =
+ "EEE, dd-MMM-yyyy HH:mm:ss z";
+ private static final DateFormat OLD_COOKIE_FORMAT;
+ private static final String ancientDate;
+
+
+ static {
+ OLD_COOKIE_FORMAT = new SimpleDateFormat(OLD_COOKIE_PATTERN, Locale.US);
+ OLD_COOKIE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
+ ancientDate = OLD_COOKIE_FORMAT.format(new Date(10000));
+ }
+
/**
* If set to true, we parse cookies according to the servlet spec,
*/
@@ -245,9 +261,6 @@
}
}
- private static final String ancientDate =
- DateTool.formatOldCookie(new Date(10000));
-
// TODO RFC2965 fields also need to be passed
public static void appendCookieValue( StringBuffer headerBuf,
int version,
@@ -296,10 +309,12 @@
if (maxAge == 0)
buf.append( ancientDate );
else
- DateTool.formatOldCookie
- (new Date( System.currentTimeMillis() +
- maxAge *1000L), buf,
- new FieldPosition(0));
+ synchronized (OLD_COOKIE_FORMAT) {
+ OLD_COOKIE_FORMAT.format(
+ new Date(System.currentTimeMillis() +
+ maxAge*1000L),
+ buf, new FieldPosition(0));
+ }
} else {
buf.append ("; Max-Age=");
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org