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

remove BufferDateCache and DateCache
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 Sep 2016 21:38:44 -0600
parents 359012f4e797
children
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/NCSARequestLog.java	Tue Sep 20 01:05:37 2016 -0600
+++ b/src/org/eclipse/jetty/server/NCSARequestLog.java	Tue Sep 20 21:38:44 2016 -0600
@@ -24,13 +24,14 @@
 import java.io.Writer;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Locale;
 import java.util.TimeZone;
 
 import javax.servlet.http.Cookie;
 
 import org.eclipse.jetty.http.HttpHeaders;
-import org.eclipse.jetty.util.DateCache;
 import org.eclipse.jetty.util.component.AbstractLifeCycle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,14 +61,14 @@
 	private boolean _preferProxiedForAddress;
 	private String _logDateFormat = "dd/MMM/yyyy:HH:mm:ss Z";
 	private Locale _logLocale = Locale.getDefault();
-	private String _logTimeZone = "GMT";
+	public TimeZone timeZone = TimeZone.getTimeZone("GMT");
 	private boolean _logLatency = false;
 	private boolean _logCookies = false;
 	private boolean _logServer = false;
 	private boolean _logDispatch = false;
 
 	private transient OutputStream _out;
-	private transient DateCache _logDateCache;
+	private transient DateFormat dateFormat;
 	private transient Writer _writer;
 
 	/* ------------------------------------------------------------ */
@@ -171,28 +172,6 @@
 
 	/* ------------------------------------------------------------ */
 	/**
-	 * Set the timezone of the request log.
-	 * 
-	 * @param tz timezone string
-	 */
-	public void setLogTimeZone(String tz)
-	{
-		_logTimeZone = tz;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * Retrieve the timezone of the request log.
-	 * 
-	 * @return timezone string
-	 */
-	public String getLogTimeZone()
-	{
-		return _logTimeZone;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
 	 * Set the extended request log format flag.
 	 * 
 	 * @param extended true - log the extended request information,
@@ -361,13 +340,11 @@
 				addr = request.getRemoteAddr();
 
 			buf.append(addr);
-			buf.append(" - ");
+			buf.append(" - [");
 
-			buf.append(" [");
-			if (_logDateCache != null)
-				buf.append(_logDateCache.format(request.getTimeStamp()));
-			else
-				buf.append(request.getTimeStampBuffer().toString());
+			synchronized(dateFormat) {
+				buf.append(dateFormat.format(request.getTimeStamp()));
+			}
 
 			buf.append("] \"");
 			buf.append(request.getMethod());
@@ -520,11 +497,8 @@
 	@Override
 	protected synchronized void doStart() throws Exception
 	{
-		if (_logDateFormat != null)
-		{
-			_logDateCache = new DateCache(_logDateFormat,_logLocale);
-			_logDateCache.setTimeZoneID(_logTimeZone);
-		}
+		dateFormat = new SimpleDateFormat(_logDateFormat,_logLocale);
+		dateFormat.setTimeZone(timeZone);
 
 		if (_filename != null) {
 			File file = new File(_filename);
@@ -582,7 +556,7 @@
 
 			_out = null;
 			_closeOut = false;
-			_logDateCache = null;
+			dateFormat = null;
 			_writer = null;
 		}
 	}