diff src/org/eclipse/jetty/server/Request.java @ 855:fa6158f29c45

remove BufferDateCache and DateCache
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 Sep 2016 21:38:44 -0600
parents 86338c0029a9
children 3dcc52e17535
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Request.java	Tue Sep 20 01:05:37 2016 -0600
+++ b/src/org/eclipse/jetty/server/Request.java	Tue Sep 20 21:38:44 2016 -0600
@@ -28,6 +28,9 @@
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.security.Principal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -1226,7 +1229,7 @@
 	public Buffer getTimeStampBuffer()
 	{
 		if (_timeStampBuffer == null && _timeStamp > 0)
-			_timeStampBuffer = HttpFields.__dateCache.formatBuffer(_timeStamp);
+			_timeStampBuffer = formatBuffer(_timeStamp);
 		return _timeStampBuffer;
 	}
 
@@ -1981,4 +1984,24 @@
 		setParameters(parameters);
 		setQueryString(query);
 	}
+
+
+	private static Buffer _buffer;
+	private static String _last;
+	private static final DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
+	static {
+		dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+	}
+
+	private static Buffer formatBuffer(long date) {
+		synchronized(dateFormat) {
+			String d = dateFormat.format(date);
+			if (d==_last)
+				return _buffer;
+			_last=d;
+			_buffer=new ByteArrayBuffer(d);
+			return _buffer;
+		}
+	}
+
 }