Author: violetagg Date: Sun Jun 18 19:17:00 2017 New Revision: 1799117 URL: http://svn.apache.org/viewvc?rev=1799117&view=rev Log: Format the code. No functional changes.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/juli/AsyncFileHandler.java tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java Modified: tomcat/tc7.0.x/trunk/java/org/apache/juli/AsyncFileHandler.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/juli/AsyncFileHandler.java?rev=1799117&r1=1799116&r2=1799117&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/juli/AsyncFileHandler.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/juli/AsyncFileHandler.java Sun Jun 18 19:17:00 2017 @@ -47,23 +47,23 @@ public class AsyncFileHandler extends Fi public static final int OVERFLOW_DROP_FIRST = 2; public static final int OVERFLOW_DROP_FLUSH = 3; public static final int OVERFLOW_DROP_CURRENT = 4; - - public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(System.getProperty("org.apache.juli.AsyncOverflowDropType","1")); - public static final int DEFAULT_MAX_RECORDS = Integer.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount","10000")); - public static final int LOGGER_SLEEP_TIME = Integer.parseInt(System.getProperty("org.apache.juli.AsyncLoggerPollInterval","1000")); - + + public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(System.getProperty("org.apache.juli.AsyncOverflowDropType", "1")); + public static final int DEFAULT_MAX_RECORDS = Integer.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount", "10000")); + public static final int LOGGER_SLEEP_TIME = Integer.parseInt(System.getProperty("org.apache.juli.AsyncLoggerPollInterval", "1000")); + protected static LinkedBlockingDeque<LogEntry> queue = new LinkedBlockingDeque<LogEntry>(DEFAULT_MAX_RECORDS); protected static LoggerThread logger = new LoggerThread(); - + static { logger.start(); } - + protected volatile boolean closed = false; - + public AsyncFileHandler() { - this(null,null,null); + this(null, null, null); } public AsyncFileHandler(String directory, String prefix, String suffix) { @@ -73,25 +73,29 @@ public class AsyncFileHandler extends Fi @Override public void close() { - if (closed) return; + if (closed) { + return; + } closed = true; super.close(); } - + @Override protected void open() { - if(!closed) return; + if (!closed) { + return; + } closed = false; super.open(); } - + @Override public void publish(LogRecord record) { if (!isLoggable(record)) { return; } - LogEntry entry = new LogEntry(record,this); + LogEntry entry = new LogEntry(record, this); boolean added = false; try { while (!added && !queue.offer(entry)) { @@ -107,7 +111,7 @@ public class AsyncFileHandler extends Fi break; } case OVERFLOW_DROP_FLUSH: { - added = queue.offer(entry,1000,TimeUnit.MILLISECONDS); + added = queue.offer(entry, 1000, TimeUnit.MILLISECONDS); break; } case OVERFLOW_DROP_CURRENT: { @@ -116,14 +120,14 @@ public class AsyncFileHandler extends Fi } }//switch }//while - }catch (InterruptedException x) { + } catch (InterruptedException x) { //allow thread to be interrupted and back out of the publish operation //after this we clear the flag Thread.interrupted(); } - + } - + protected void publishInternal(LogRecord record) { super.publish(record); } @@ -132,24 +136,26 @@ public class AsyncFileHandler extends Fi protected boolean run = true; public LoggerThread() { this.setDaemon(true); - this.setName("AsyncFileHandlerWriter-"+System.identityHashCode(this)); + this.setName("AsyncFileHandlerWriter-" + System.identityHashCode(this)); } - + @Override public void run() { while (run) { try { LogEntry entry = queue.poll(LOGGER_SLEEP_TIME, TimeUnit.MILLISECONDS); - if (entry!=null) entry.flush(); - }catch (InterruptedException x) { + if (entry != null) { + entry.flush(); + } + } catch (InterruptedException x) { Thread.interrupted(); - }catch (Exception x) { + } catch (Exception x) { x.printStackTrace(); } }//while } } - + protected static class LogEntry { private LogRecord record; private AsyncFileHandler handler; @@ -158,7 +164,7 @@ public class AsyncFileHandler extends Fi this.record = record; this.handler = handler; } - + public boolean flush() { if (handler.closed) { return false; @@ -167,8 +173,7 @@ public class AsyncFileHandler extends Fi return true; } } - + } - - + } Modified: tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java?rev=1799117&r1=1799116&r2=1799117&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/juli/FileHandler.java Sun Jun 18 19:17:00 2017 @@ -77,18 +77,17 @@ import java.util.logging.SimpleFormatter * <code>java.util.logging.SimpleFormatter</code></li> * </ul> */ -public class FileHandler - extends Handler { +public class FileHandler extends Handler { // ------------------------------------------------------------ Constructor - + public FileHandler() { this(null, null, null); } - - + + public FileHandler(String directory, String prefix, String suffix) { this.directory = directory; this.prefix = prefix; @@ -96,7 +95,7 @@ public class FileHandler configure(); openWriter(); } - + // ----------------------------------------------------- Instance Variables @@ -200,13 +199,14 @@ public class FileHandler } try { - if (writer!=null) { + if (writer != null) { writer.write(result); if (bufferSize < 0) { writer.flush(); } } else { - reportError("FileHandler is closed or not yet initialized, unable to log ["+result+"]", null, ErrorManager.WRITE_FAILURE); + reportError("FileHandler is closed or not yet initialized, unable to log [" + + result + "]", null, ErrorManager.WRITE_FAILURE); } } catch (Exception e) { reportError(null, e, ErrorManager.WRITE_FAILURE); @@ -216,8 +216,8 @@ public class FileHandler writerLock.readLock().unlock(); } } - - + + // -------------------------------------------------------- Private Methods @@ -230,11 +230,12 @@ public class FileHandler } protected void closeWriter() { - + writerLock.writeLock().lock(); try { - if (writer == null) + if (writer == null) { return; + } writer.write(getFormatter().getTail(this)); writer.flush(); writer.close(); @@ -256,18 +257,19 @@ public class FileHandler writerLock.readLock().lock(); try { - if (writer == null) + if (writer == null) { return; + } writer.flush(); } catch (Exception e) { reportError(null, e, ErrorManager.FLUSH_FAILURE); } finally { writerLock.readLock().unlock(); } - + } - - + + /** * Configure from <code>LogManager</code> properties. */ @@ -278,17 +280,20 @@ public class FileHandler date = tsString.substring(0, 10); String className = this.getClass().getName(); //allow classes to override - + ClassLoader cl = Thread.currentThread().getContextClassLoader(); - + // Retrieve configuration of logging file name rotatable = Boolean.parseBoolean(getProperty(className + ".rotatable", "true")); - if (directory == null) + if (directory == null) { directory = getProperty(className + ".directory", "logs"); - if (prefix == null) + } + if (prefix == null) { prefix = getProperty(className + ".prefix", "juli."); - if (suffix == null) + } + if (suffix == null) { suffix = getProperty(className + ".suffix", ".log"); + } String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(bufferSize)); try { bufferSize = Integer.parseInt(sBufferSize); @@ -330,13 +335,13 @@ public class FileHandler } else { setFormatter(new SimpleFormatter()); } - + // Set error manager setErrorManager(new ErrorManager()); - + } - + private String getProperty(String name, String defaultValue) { String value = LogManager.getLogManager().getProperty(name); if (value == null) { @@ -346,22 +351,21 @@ public class FileHandler } return value; } - - + + /** * Open the new log file for the date specified by <code>date</code>. */ protected void open() { openWriter(); } - + protected void openWriter() { // Create the directory if necessary File dir = new File(directory); if (!dir.mkdirs() && !dir.isDirectory()) { - reportError("Unable to create [" + dir + "]", null, - ErrorManager.OPEN_FAILURE); + reportError("Unable to create [" + dir + "]", null, ErrorManager.OPEN_FAILURE); writer = null; return; } @@ -375,14 +379,13 @@ public class FileHandler + (rotatable ? date : "") + suffix); File parent = pathname.getParentFile(); if (!parent.mkdirs() && !parent.isDirectory()) { - reportError("Unable to create [" + parent + "]", null, - ErrorManager.OPEN_FAILURE); + reportError("Unable to create [" + parent + "]", null, ErrorManager.OPEN_FAILURE); writer = null; return; } String encoding = getEncoding(); fos = new FileOutputStream(pathname, true); - os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos; + os = bufferSize > 0 ? new BufferedOutputStream(fos, bufferSize) : fos; writer = new PrintWriter( (encoding != null) ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os), false); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org