You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2017/06/06 07:04:26 UTC
svn commit: r1797741 - in /tomcat/trunk/java/org/apache/juli:
AsyncFileHandler.java FileHandler.java
Author: violetagg
Date: Tue Jun 6 07:04:26 2017
New Revision: 1797741
URL: http://svn.apache.org/viewvc?rev=1797741&view=rev
Log:
Format the code. No functional changes.
Modified:
tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java
tomcat/trunk/java/org/apache/juli/FileHandler.java
Modified: tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java?rev=1797741&r1=1797740&r2=1797741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java (original)
+++ tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java Tue Jun 6 07:04:26 2017
@@ -71,7 +71,7 @@ public class AsyncFileHandler extends Fi
protected volatile boolean closed = false;
public AsyncFileHandler() {
- this(null,null,null);
+ this(null, null, null);
}
public AsyncFileHandler(String directory, String prefix, String suffix) {
@@ -81,14 +81,18 @@ 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();
}
@@ -102,7 +106,7 @@ public class AsyncFileHandler extends Fi
// fill source entries, before we hand the record over to another
// thread with another class loader
record.getSourceMethodName();
- LogEntry entry = new LogEntry(record,this);
+ LogEntry entry = new LogEntry(record, this);
boolean added = false;
try {
while (!added && !queue.offer(entry)) {
@@ -118,7 +122,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: {
@@ -127,7 +131,7 @@ 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. No further action required.
}
@@ -142,7 +146,7 @@ public class AsyncFileHandler extends Fi
protected final boolean run = true;
public LoggerThread() {
this.setDaemon(true);
- this.setName("AsyncFileHandlerWriter-"+System.identityHashCode(this));
+ this.setName("AsyncFileHandlerWriter-" + System.identityHashCode(this));
}
@Override
@@ -150,7 +154,9 @@ public class AsyncFileHandler extends Fi
while (run) {
try {
LogEntry entry = queue.poll(LOGGER_SLEEP_TIME, TimeUnit.MILLISECONDS);
- if (entry!=null) entry.flush();
+ if (entry != null) {
+ entry.flush();
+ }
} catch (InterruptedException x) {
// Ignore the attempt to interrupt the thread.
} catch (Exception x) {
Modified: tomcat/trunk/java/org/apache/juli/FileHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/FileHandler.java?rev=1797741&r1=1797740&r2=1797741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/juli/FileHandler.java (original)
+++ tomcat/trunk/java/org/apache/juli/FileHandler.java Tue Jun 6 07:04:26 2017
@@ -76,9 +76,7 @@ import java.util.logging.LogRecord;
* <code>java.util.logging.SimpleFormatter</code></li>
* </ul>
*/
-public class FileHandler
- extends Handler {
-
+public class FileHandler extends Handler {
// ------------------------------------------------------------ Constructor
@@ -199,13 +197,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);
@@ -231,8 +230,9 @@ public class FileHandler
writerLock.writeLock().lock();
try {
- if (writer == null)
+ if (writer == null) {
return;
+ }
writer.write(getFormatter().getTail(this));
writer.flush();
writer.close();
@@ -254,8 +254,9 @@ 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);
@@ -281,12 +282,15 @@ public class FileHandler
// 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);
@@ -358,8 +362,7 @@ public class FileHandler
// 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;
}
@@ -373,14 +376,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org