You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/06/03 18:18:07 UTC
[1/6] logging-log4j2 git commit: Use final.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 018ca8a30 -> ce4492f63
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageInliningBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageInliningBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageInliningBenchmark.java
index a9b5844..931dc1b 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageInliningBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageInliningBenchmark.java
@@ -240,7 +240,7 @@ public class ParameterizedMessageInliningBenchmark {
* Returns the sum of the lengths of all Strings in the specified array.
*/
// 27 bytes
- private static int sumStringLengths(String[] arguments) {
+ private static int sumStringLengths(final String[] arguments) {
int result = 0;
for (int i = 0; i < arguments.length; i++) {
result += arguments[i].length();
@@ -249,13 +249,13 @@ public class ParameterizedMessageInliningBenchmark {
}
// 22 bytes
- private static boolean isDelimPair(final String messagePattern, int i, final char curChar) {
+ private static boolean isDelimPair(final String messagePattern, final int i, final char curChar) {
return curChar == DELIM_START && messagePattern.charAt(i + 1) == DELIM_STOP;
}
// 28 bytes
private static int format0_handleMaybeLastChar(final String messagePattern, final int len, final char[] result,
- int pos, int escapeCounter, int i) {
+ int pos, final int escapeCounter, final int i) {
if (i == len - 1) {
final char curChar = messagePattern.charAt(i);
pos = format0_handleLastChar(result, pos, escapeCounter, curChar);
@@ -264,7 +264,7 @@ public class ParameterizedMessageInliningBenchmark {
}
// 28 bytes
- private static int format0_handleLastChar(final char[] result, int pos, int escapeCounter, final char curChar) {
+ private static int format0_handleLastChar(final char[] result, int pos, final int escapeCounter, final char curChar) {
if (curChar == ESCAPE_CHAR) {
pos = format0_writeUnescapedEscapeChars(escapeCounter + 1, result, pos);
} else {
@@ -274,7 +274,7 @@ public class ParameterizedMessageInliningBenchmark {
}
// 16 bytes
- private static int format0_handleLiteralChar(final char[] result, int pos, int escapeCounter, final char curChar) {
+ private static int format0_handleLiteralChar(final char[] result, int pos, final int escapeCounter, final char curChar) {
// any other char beside ESCAPE or DELIM_START/STOP-combo
// write unescaped escape chars
pos = format0_writeUnescapedEscapeChars(escapeCounter, result, pos);
@@ -293,18 +293,18 @@ public class ParameterizedMessageInliningBenchmark {
* Returns {@code true} if the specified parameter is odd.
*/
// 11 bytes
- private static boolean isOdd(int number) {
+ private static boolean isOdd(final int number) {
return (number & 1) == 1;
}
// 11 bytes
- private static int format0_writeEscapedEscapeChars(int escapeCounter, char[] result, int pos) {
+ private static int format0_writeEscapedEscapeChars(final int escapeCounter, final char[] result, final int pos) {
final int escapedEscapes = escapeCounter >> 1; // divide by two
return format0_writeUnescapedEscapeChars(escapedEscapes, result, pos);
}
// 20 bytes
- private static int format0_writeUnescapedEscapeChars(int escapeCounter, char[] result, int pos) {
+ private static int format0_writeUnescapedEscapeChars(int escapeCounter, final char[] result, int pos) {
while (escapeCounter > 0) {
result[pos++] = ESCAPE_CHAR;
escapeCounter--;
@@ -313,7 +313,7 @@ public class ParameterizedMessageInliningBenchmark {
}
// 25 bytes
- private static int format0_appendArg(final String[] arguments, int currentArgument, final char[] result, int pos) {
+ private static int format0_appendArg(final String[] arguments, final int currentArgument, final char[] result, int pos) {
if (currentArgument < arguments.length) {
pos = format0_appendArg0(arguments, currentArgument, result, pos);
} else {
@@ -323,7 +323,7 @@ public class ParameterizedMessageInliningBenchmark {
}
// 27 bytes
- private static int format0_appendArg0(final String[] arguments, int currentArgument, final char[] result, int pos) {
+ private static int format0_appendArg0(final String[] arguments, final int currentArgument, final char[] result, final int pos) {
final String arg = arguments[currentArgument];
final int argLen = arg.length();
arg.getChars(0, argLen, result, pos);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/PatternLayoutComparisonBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/PatternLayoutComparisonBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/PatternLayoutComparisonBenchmark.java
index 0919835..0bcf3da 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/PatternLayoutComparisonBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/PatternLayoutComparisonBenchmark.java
@@ -106,7 +106,7 @@ public class PatternLayoutComparisonBenchmark {
patternLayoutEncoder.init(baos);
}
- ILoggingEvent makeLoggingEvent(String message) {
+ ILoggingEvent makeLoggingEvent(final String message) {
return new LoggingEvent(PatternLayoutComparisonBenchmark.class.getName(), logger,
ch.qos.logback.classic.Level.DEBUG, message, null, null);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
index 7e9459c..c18413a 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/StringEncodingBenchmark.java
@@ -127,7 +127,7 @@ public class StringEncodingBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public byte[] shiftJisEncoder() throws CharacterCodingException {
- ByteBuffer buf = ENCODER_SHIFT_JIS.encode(CharBuffer.wrap(LOGMSG));
+ final ByteBuffer buf = ENCODER_SHIFT_JIS.encode(CharBuffer.wrap(LOGMSG));
return buf.array();
}
@@ -135,7 +135,7 @@ public class StringEncodingBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public byte[] iso8859_1Encoder() throws CharacterCodingException {
- ByteBuffer buf = ENCODER_ISO8859_1.encode(CharBuffer.wrap(LOGMSG));
+ final ByteBuffer buf = ENCODER_ISO8859_1.encode(CharBuffer.wrap(LOGMSG));
return buf.array();
}
@@ -171,8 +171,8 @@ public class StringEncodingBenchmark {
return result;
}
- private int nonIsoChar(String logmsg, int i) {
- char c = logmsg.charAt(i++);
+ private int nonIsoChar(final String logmsg, int i) {
+ final char c = logmsg.charAt(i++);
if ((Character.isHighSurrogate(c)) && (i < logmsg.length()) && (Character.isLowSurrogate(logmsg.charAt(i)))) {
i++;
}
@@ -189,10 +189,10 @@ public class StringEncodingBenchmark {
return result;
}
- private static int encodeISOArray(String charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ private static int encodeISOArray(final String charArray, int charIndex, final byte[] byteArray, int byteIndex, final int length) {
int i = 0;
for (; i < length; i++) {
- char c = charArray.charAt(charIndex++);
+ final char c = charArray.charAt(charIndex++);
if (c > 255) {
break;
}
@@ -201,16 +201,16 @@ public class StringEncodingBenchmark {
return i;
}
- private int encode(String charArray, int charOffset, int charLength, byte[] byteArray) {
+ private int encode(final String charArray, int charOffset, int charLength, final byte[] byteArray) {
int offset = 0;
int length = Math.min(charLength, byteArray.length);
int charDoneIndex = charOffset + length;
while (charOffset < charDoneIndex) {
- int m = encodeISOArray(charArray, charOffset, byteArray, offset, length);
+ final int m = encodeISOArray(charArray, charOffset, byteArray, offset, length);
charOffset += m;
offset += m;
if (m != length) {
- char c = charArray.charAt(charOffset++);
+ final char c = charArray.charAt(charOffset++);
if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
&& (Character.isLowSurrogate(charArray.charAt(charOffset)))) {
if (charLength > byteArray.length) {
@@ -230,17 +230,17 @@ public class StringEncodingBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public byte[] iso8859_1CustomPortedJDK8CopyArray() throws CharacterCodingException {
- char[] charArray = LOGMSG.toCharArray();
+ final char[] charArray = LOGMSG.toCharArray();
final int length = charArray.length;
final byte[] result = new byte[length];
encode0(charArray, 0, length, result);
return result;
}
- private static int encodeISOArray0(char[] charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ private static int encodeISOArray0(final char[] charArray, int charIndex, final byte[] byteArray, int byteIndex, final int length) {
int i = 0;
for (; i < length; i++) {
- char c = charArray[(charIndex++)];
+ final char c = charArray[(charIndex++)];
if (c > 255) {
break;
}
@@ -249,16 +249,16 @@ public class StringEncodingBenchmark {
return i;
}
- private int encode0(char[] charArray, int charOffset, int charLength, byte[] byteArray) {
+ private int encode0(final char[] charArray, int charOffset, int charLength, final byte[] byteArray) {
int offset = 0;
int length = Math.min(charLength, byteArray.length);
int charDoneIndex = charOffset + length;
while (charOffset < charDoneIndex) {
- int m = encodeISOArray0(charArray, charOffset, byteArray, offset, length);
+ final int m = encodeISOArray0(charArray, charOffset, byteArray, offset, length);
charOffset += m;
offset += m;
if (m != length) {
- char c = charArray[(charOffset++)];
+ final char c = charArray[(charOffset++)];
if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
&& (Character.isLowSurrogate(charArray[(charOffset)]))) {
if (charLength > byteArray.length) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TextEncoderHelperBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TextEncoderHelperBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TextEncoderHelperBenchmark.java
index 7fd83fd..bf67c9d 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TextEncoderHelperBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TextEncoderHelperBenchmark.java
@@ -74,7 +74,7 @@ public class TextEncoderHelperBenchmark {
}
@Override
- public ByteBuffer drain(ByteBuffer buf) {
+ public ByteBuffer drain(final ByteBuffer buf) {
buf.flip();
count += buf.limit();
buf.clear();
@@ -119,7 +119,7 @@ public class TextEncoderHelperBenchmark {
//private static final ThreadLocal<StringBuilderEncoder> textEncoderHelper = new ThreadLocal<>();
private final StringBuilderEncoder textEncoderHelper = new StringBuilderEncoder(CHARSET_DEFAULT);
private StringBuilderEncoder getEncoder() {
- StringBuilderEncoder result = textEncoderHelper;
+ final StringBuilderEncoder result = textEncoderHelper;
return result;
}
@@ -191,7 +191,7 @@ public class TextEncoderHelperBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public long byteArrayMCD() {
- byte[] data = PATTERN_M_C_D.toByteArray(EVENT);
+ final byte[] data = PATTERN_M_C_D.toByteArray(EVENT);
ByteBuffer buff = destination.getByteBuffer();
if (buff.remaining() < data.length) {
buff = destination.drain(buff);
@@ -204,8 +204,8 @@ public class TextEncoderHelperBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public long serializableMCD() {
- String str = PATTERN_M_C_D.toSerializable(EVENT);
- byte[] data = str.getBytes(CHARSET_DEFAULT);
+ final String str = PATTERN_M_C_D.toSerializable(EVENT);
+ final byte[] data = str.getBytes(CHARSET_DEFAULT);
ByteBuffer buff = destination.getByteBuffer();
if (buff.remaining() < data.length) {
buff = destination.drain(buff);
@@ -226,7 +226,7 @@ public class TextEncoderHelperBenchmark {
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public String toStringMCD() {
- String str = PATTERN_M_C_D.toSerializable(EVENT);
+ final String str = PATTERN_M_C_D.toSerializable(EVENT);
return str;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsConcurrentHashMapBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsConcurrentHashMapBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsConcurrentHashMapBenchmark.java
index 7d1ccc9..9755f5a 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsConcurrentHashMapBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsConcurrentHashMapBenchmark.java
@@ -48,21 +48,21 @@ public class ThreadLocalVsConcurrentHashMapBenchmark {
@Benchmark
public String newInstance() {
- StringBuilder sb = getNew();
+ final StringBuilder sb = getNew();
sb.append(VALUE);
return sb.toString();
}
@Benchmark
public String threadLocal() {
- StringBuilder sb = getThreadLocal();
+ final StringBuilder sb = getThreadLocal();
sb.append(VALUE);
return sb.toString();
}
@Benchmark
public String concurrentHashMap() {
- StringBuilder sb = getConcurrentMap();
+ final StringBuilder sb = getConcurrentMap();
sb.append(VALUE);
return sb.toString();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsPoolBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsPoolBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsPoolBenchmark.java
index 113e56a..57baee5 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsPoolBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadLocalVsPoolBenchmark.java
@@ -78,9 +78,9 @@ public class ThreadLocalVsPoolBenchmark {
/**
*/
private static PatternFormatter[] createFormatters() {
- Configuration config = new DefaultConfiguration();
- PatternParser parser = new PatternParser(config, "Converter", LogEventPatternConverter.class);
- List<PatternFormatter> result = parser.parse(LOG4JPATTERN, false, true);
+ final Configuration config = new DefaultConfiguration();
+ final PatternParser parser = new PatternParser(config, "Converter", LogEventPatternConverter.class);
+ final List<PatternFormatter> result = parser.parse(LOG4JPATTERN, false, true);
return (PatternFormatter[]) result.toArray(new PatternFormatter[result.size()]);
}
@@ -183,11 +183,11 @@ abstract class ObjectPool<T> {
private final Deque<T> pool = new ConcurrentLinkedDeque<>();
public T borrowObject() {
- T object = pool.poll();
+ final T object = pool.poll();
return object == null ? createObject() : object;
}
- public void returnObject(T object) {
+ public void returnObject(final T object) {
pool.add(object);
}
@@ -200,12 +200,12 @@ abstract class ObjectPool<T> {
class StringBuilderPool extends ObjectPool<StringBuilder> {
private final int initialSize;
- public StringBuilderPool(int stringBuilderSize) {
+ public StringBuilderPool(final int stringBuilderSize) {
this.initialSize = stringBuilderSize;
}
@Override
- public void returnObject(StringBuilder stringBuilder) {
+ public void returnObject(final StringBuilder stringBuilder) {
stringBuilder.setLength(0);
super.returnObject(stringBuilder);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
index c62ea68..d1a6240 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
@@ -124,8 +124,8 @@ public class ThreadsafeDateFormatBenchmark {
public String format(final long timestamp) {
if (timestamp != this.timestamp) {
this.timestamp = timestamp;
- char[] buffer = reusableBuffer.get();
- int len = customFormat.format(timestamp, buffer, 0);
+ final char[] buffer = reusableBuffer.get();
+ final int len = customFormat.format(timestamp, buffer, 0);
formatted = new String(buffer, 0, len);
}
return formatted;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/VarargsBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/VarargsBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/VarargsBenchmark.java
index 60d6abf..b5c4634 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/VarargsBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/VarargsBenchmark.java
@@ -68,13 +68,13 @@ public class VarargsBenchmark {
"six", "seven", "eight", "nine", "ten");
}
- private long varargMethod(String string, String... p) {
+ private long varargMethod(final String string, final String... p) {
return string.length() + p[0].length() + p[1].length() + p[2].length() + p[3].length() + p[4].length()
+ p[5].length() + p[6].length() + p[7].length() + p[8].length() + p[9].length();
}
- private long individualArgMethod(String string, String p1, String p2, String p3, String p4, String p5, String p6,
- String p7, String p8, String p9, String p10) {
+ private long individualArgMethod(final String string, final String p1, final String p2, final String p3, final String p4, final String p5, final String p6,
+ final String p7, final String p8, final String p9, final String p10) {
return string.length() + p1.length() + p2.length() + p3.length() + p4.length() + p5.length() + p6.length()
+ p7.length() + p8.length() + p9.length() + p10.length();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/AbstractLogger.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/AbstractLogger.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/AbstractLogger.java
index 10f053e..af527b8 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/AbstractLogger.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/AbstractLogger.java
@@ -30,15 +30,15 @@ public abstract class AbstractLogger {
protected abstract Layout<?> createLayout();
- protected void log(Message message) {
+ protected void log(final Message message) {
callAppenders(createLogEvent(message));
}
- private void callAppenders(LogEvent logEvent) {
+ private void callAppenders(final LogEvent logEvent) {
appender.append(logEvent);
}
- private LogEvent createLogEvent(Message message) {
+ private LogEvent createLogEvent(final Message message) {
reusedLogEvent.setMessage(message);
return reusedLogEvent;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ClassicLogger.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ClassicLogger.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ClassicLogger.java
index 49481f7..97fd24e 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ClassicLogger.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ClassicLogger.java
@@ -32,7 +32,7 @@ public class ClassicLogger extends AbstractLogger {
return PatternLayout.newBuilder().withCharset(StandardCharsets.UTF_8).withPattern("%m").build();
}
- public void log(String message, Object... params) {
+ public void log(final String message, final Object... params) {
log(new ParameterizedMessage(message, params));
//log(new NoGcMessage(16).set(message, params[0], params[1], params[2], params[3]));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/DemoAppender.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/DemoAppender.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/DemoAppender.java
index 2f3851d..df9ade0 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/DemoAppender.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/DemoAppender.java
@@ -31,23 +31,23 @@ public class DemoAppender extends AbstractAppender implements ByteBufferDestinat
public long checksum;
- public DemoAppender(Layout<?> layout) {
+ public DemoAppender(final Layout<?> layout) {
super("demo", null, layout);
}
@Override
- public void append(LogEvent event) {
- Layout<?> layout = getLayout();
+ public void append(final LogEvent event) {
+ final Layout<?> layout = getLayout();
if (layout instanceof NoGcLayout) {
layout.encode(event, this);
drain(byteBuffer);
} else {
- byte[] binary = getLayout().toByteArray(event);
+ final byte[] binary = getLayout().toByteArray(event);
consume(binary, 0, binary.length);
}
}
- private void consume(byte[] data, int offset, int length) {
+ private void consume(final byte[] data, final int offset, final int length) {
// need to do something with the result or the JVM may optimize everything away
long sum = 0;
for (int i = offset; i < length; i++) {
@@ -62,7 +62,7 @@ public class DemoAppender extends AbstractAppender implements ByteBufferDestinat
}
@Override
- public ByteBuffer drain(ByteBuffer buf) {
+ public ByteBuffer drain(final ByteBuffer buf) {
buf.flip();
consume(buf.array(), buf.position(), buf.limit());
buf.clear();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLayout.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLayout.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLayout.java
index 5f84975..81fa861 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLayout.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLayout.java
@@ -41,15 +41,15 @@ public class NoGcLayout implements Layout<Serializable>, Encoder<LogEvent> {
private final PatternSerializer2 serializer = new PatternSerializer2();
private final StringBuilderEncoder cachedHelper;
- public NoGcLayout(Charset charset) {
+ public NoGcLayout(final Charset charset) {
cachedHelper = new StringBuilderEncoder(charset);
}
@Override
- public void encode(LogEvent event, ByteBufferDestination destination) {
- StringBuilder text = toText(event, getCachedStringBuilder());
+ public void encode(final LogEvent event, final ByteBufferDestination destination) {
+ final StringBuilder text = toText(event, getCachedStringBuilder());
- Encoder<StringBuilder> helper = getCachedHelper();
+ final Encoder<StringBuilder> helper = getCachedHelper();
helper.encode(text, destination);
}
@@ -60,7 +60,7 @@ public class NoGcLayout implements Layout<Serializable>, Encoder<LogEvent> {
* Implementations are free to return a new StringBuilder if they can
* detect in advance that the specified StringBuilder is too small.
*/
- StringBuilder toText(LogEvent e, StringBuilder destination) {
+ StringBuilder toText(final LogEvent e, final StringBuilder destination) {
return serializer.toSerializable(e, destination);
}
@@ -88,7 +88,7 @@ public class NoGcLayout implements Layout<Serializable>, Encoder<LogEvent> {
this.formatters = formatters;
}
- public StringBuilder toSerializable(final LogEvent event, StringBuilder buf) {
+ public StringBuilder toSerializable(final LogEvent event, final StringBuilder buf) {
//final StringBuilder buf = getStringBuilder();
final int len = formatters.length;
for (int i = 0; i < len; i++) {
@@ -113,12 +113,12 @@ public class NoGcLayout implements Layout<Serializable>, Encoder<LogEvent> {
}
@Override
- public byte[] toByteArray(LogEvent event) {
+ public byte[] toByteArray(final LogEvent event) {
return null;
}
@Override
- public Serializable toSerializable(LogEvent event) {
+ public Serializable toSerializable(final LogEvent event) {
return null;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLogger.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLogger.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLogger.java
index 687b718..07a43fc 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLogger.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcLogger.java
@@ -31,7 +31,7 @@ public class NoGcLogger extends AbstractLogger {
return new NoGcLayout(StandardCharsets.UTF_8);
}
- public void log(String message, Object p1, Object p2, Object p3, Object p4) {
+ public void log(final String message, final Object p1, final Object p2, final Object p3, final Object p4) {
reusedMessage.set(message, p1, p2, p3, p4);
log(reusedMessage);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcMessage.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcMessage.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcMessage.java
index fdb84d9..8ee995e 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcMessage.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/NoGcMessage.java
@@ -52,8 +52,8 @@ public class NoGcMessage implements Message {
return getState().buffer;
}
- public void set(String message, Object p1, Object p2, Object p3, Object p4) {
- InternalState state = getState();
+ public void set(final String message, final Object p1, final Object p2, final Object p3, final Object p4) {
+ final InternalState state = getState();
state.params[0] = p1;
state.params[1] = p2;
state.params[2] = p3;
@@ -62,7 +62,7 @@ public class NoGcMessage implements Message {
int current = 0;
state.buffer.setLength(0);
for (int i = 0; i < message.length() - 1; i++) {
- char c = message.charAt(i);
+ final char c = message.charAt(i);
if (c == '{' && message.charAt(i + 1) == '}') {
append(state.params[current++], state.buffer);
i++;
@@ -70,13 +70,13 @@ public class NoGcMessage implements Message {
state.buffer.append(c);
}
}
- char c = message.charAt(message.length() - 1);
+ final char c = message.charAt(message.length() - 1);
if (c != '}') {
state.buffer.append(c);
}
}
- private void append(Object param, StringBuilder buffer) {
+ private void append(final Object param, final StringBuilder buffer) {
if (param instanceof StringBuilder) {
buffer.append((StringBuilder) param);
} else {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ParameterizedMessage.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ParameterizedMessage.java
index be45a60..8dae290 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ParameterizedMessage.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/ParameterizedMessage.java
@@ -354,7 +354,7 @@ public class ParameterizedMessage implements Message {
// Profiling showed this method is important to log4j performance. Modify with care!
// 28 bytes (allows immediate JVM inlining: < 35 bytes) LOG4J2-1096
private static int handleRemainingCharIfAny(final String messagePattern, final int len, final char[] result,
- int pos, int escapeCounter, int i) {
+ int pos, final int escapeCounter, final int i) {
if (i == len - 1) {
final char curChar = messagePattern.charAt(i);
pos = handleLastChar(result, pos, escapeCounter, curChar);
@@ -427,7 +427,7 @@ public class ParameterizedMessage implements Message {
*/
// Profiling showed this method is important to log4j performance. Modify with care!
// 20 bytes (allows immediate JVM inlining: < 35 bytes) LOG4J2-1096
- private static int writeUnescapedEscapeChars(int escapeCounter, char[] result, int pos) {
+ private static int writeUnescapedEscapeChars(int escapeCounter, final char[] result, int pos) {
while (escapeCounter > 0) {
result[pos++] = ESCAPE_CHAR;
escapeCounter--;
@@ -460,7 +460,7 @@ public class ParameterizedMessage implements Message {
private static int writeArgAt0(final String[] arguments, final int currentArgument, final char[] result,
final int pos) {
final String arg = String.valueOf(arguments[currentArgument]);
- int argLen = arg.length();
+ final int argLen = arg.length();
arg.getChars(0, argLen, result, pos);
return pos + argLen;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/Test.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/Test.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/Test.java
index f7b4169..f932e20 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/Test.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/nogc/Test.java
@@ -38,12 +38,12 @@ public class Test {
static long[] duration = new long[COUNT];
static long[] checksums = new long[COUNT];
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
if ("Classic".equalsIgnoreCase(args[0])) {
- ClassicLogger logger = new ClassicLogger();
+ final ClassicLogger logger = new ClassicLogger();
runTestSuite(logger);
} else if ("NoGC".equalsIgnoreCase(args[0])) {
- NoGcLogger logger = new NoGcLogger();
+ final NoGcLogger logger = new NoGcLogger();
runTestSuite(logger);
} else {
throw new IllegalArgumentException("Specify either Classic or NoGC");
@@ -54,23 +54,23 @@ public class Test {
reportResults(args[0]);
}
- private static void runTestSuite(ClassicLogger logger) throws Exception {
+ private static void runTestSuite(final ClassicLogger logger) throws Exception {
for (int i = 0; i < 10; i++) {
doTestRun(logger, REPETITIONS, i);
Thread.sleep(100);
}
}
- private static void runTestSuite(NoGcLogger logger) throws Exception {
+ private static void runTestSuite(final NoGcLogger logger) throws Exception {
for (int i = 0; i < 10; i++) {
doTestRun(logger, REPETITIONS, i);
Thread.sleep(100);
}
}
- private static void doTestRun(NoGcLogger logger, int repetitions, int n) {
+ private static void doTestRun(final NoGcLogger logger, final int repetitions, final int n) {
startTime[n] = System.currentTimeMillis();
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < repetitions; i++) {
logger.log("Test message str={}, double={}, int={}, obj={}", "abc", box(i / 2.5), box(i), "XYX");
//logger.log("Test message str={}, double={}, int={}, obj={}", "abc", (i / 2.5), (i), logger);
@@ -80,9 +80,9 @@ public class Test {
logger.appender.checksum = 0;
}
- private static void doTestRun(ClassicLogger logger, int repetitions, int n) {
+ private static void doTestRun(final ClassicLogger logger, final int repetitions, final int n) {
startTime[n] = System.currentTimeMillis();
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < repetitions; i++) {
logger.log("Test message str={}, double={}, int={}, obj={}", "abc", i / 2.5, i, "XYX");
}
@@ -91,9 +91,9 @@ public class Test {
logger.appender.checksum = 0;
}
- private static void doTestRunBoth(ClassicLogger classic, NoGcLogger nogc, int repetitions, int n) {
+ private static void doTestRunBoth(final ClassicLogger classic, final NoGcLogger nogc, final int repetitions, final int n) {
startTime[n] = System.currentTimeMillis();
- long start = System.nanoTime();
+ final long start = System.nanoTime();
for (int i = 0; i < repetitions; i++) {
classic.log("Test message str={}, double={}, int={}, obj={}", "abc", i / 2.5, i, "XYX");
nogc.log("Test message str={}, double={}, int={}, obj={}", "abc", box(i / 2.5), box(i), "XYX");
@@ -105,7 +105,7 @@ public class Test {
duration[n] = System.nanoTime() - start;
}
- private static void reportResults(String type) {
+ private static void reportResults(final String type) {
for (int i = 0; i < COUNT; i++) {
System.out.printf("%s[%d] (%3$tF %3$tT.%3$tL) took %4$,d ns. CHECK=%5$s%n", type, i,
new Date(startTime[i]), duration[i], Long.toHexString(checksums[i]));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
index 35171c2..30fa0d6 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
@@ -32,17 +32,17 @@ public class DemoAppender extends AbstractAppender implements ByteBufferDestinat
public long checksum;
- public DemoAppender(Layout<?> layout) {
+ public DemoAppender(final Layout<?> layout) {
super("demo", null, layout);
}
@Override
- public void append(LogEvent event) {
+ public void append(final LogEvent event) {
if (Constants.ENABLE_DIRECT_ENCODERS) {
getLayout().encode(event, this);
drain(byteBuffer);
} else {
- byte[] binary = getLayout().toByteArray(event);
+ final byte[] binary = getLayout().toByteArray(event);
consume(binary, 0, binary.length);
}
}
@@ -53,14 +53,14 @@ public class DemoAppender extends AbstractAppender implements ByteBufferDestinat
}
@Override
- public ByteBuffer drain(ByteBuffer buf) {
+ public ByteBuffer drain(final ByteBuffer buf) {
buf.flip();
consume(buf.array(), buf.position(), buf.limit());
buf.clear();
return buf;
}
- private void consume(byte[] data, int offset, int length) {
+ private void consume(final byte[] data, final int offset, final int length) {
// need to do something with the result or the JVM may optimize everything away
long sum = 0;
for (int i = offset; i < length; i++) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
index 0dd4345..bd34b52 100644
--- a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
+++ b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java
@@ -57,7 +57,7 @@ public class CustomConfiguration extends AbstractConfiguration {
/**
* Constructor to create the default configuration.
*/
- public CustomConfiguration(ConfigurationSource source) {
+ public CustomConfiguration(final ConfigurationSource source) {
super(source);
setName(CONFIG_NAME);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomLookup.java
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomLookup.java b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomLookup.java
index fcd2c5c..8bd3415 100644
--- a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomLookup.java
+++ b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomLookup.java
@@ -51,14 +51,14 @@ public class CustomLookup extends AbstractLookup {
@Override
public String lookup(final LogEvent event, final String key) {
try {
- Map<String, String> properties = loggerProperties.get(event.getLoggerName());
+ final Map<String, String> properties = loggerProperties.get(event.getLoggerName());
if (properties == null) {
return "";
}
if (key == null || key.length() == 0 || key.equals("*")) {
- StringBuilder sb = new StringBuilder("{");
+ final StringBuilder sb = new StringBuilder("{");
boolean first = true;
- for (Map.Entry<String, String> entry : properties.entrySet()) {
+ for (final Map.Entry<String, String> entry : properties.entrySet()) {
if (!first) {
sb.append(", ");
}
@@ -75,7 +75,7 @@ public class CustomLookup extends AbstractLookup {
}
}
- public static void setLoggerProperties(String loggerName, Map<String, String> properties) {
+ public static void setLoggerProperties(final String loggerName, final Map<String, String> properties) {
loggerProperties.put(loggerName, properties);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomMapMessage.java
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomMapMessage.java b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomMapMessage.java
index 5480a8e..1bf6529 100644
--- a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomMapMessage.java
+++ b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/CustomMapMessage.java
@@ -28,7 +28,7 @@ public class CustomMapMessage extends MapMessage {
private static final long serialVersionUID = 1L;
private final String message;
- public CustomMapMessage(String msg, Map<String, String> map) {
+ public CustomMapMessage(final String msg, final Map<String, String> map) {
super(map);
this.message = msg;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/MapMessageLookup.java
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/MapMessageLookup.java b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/MapMessageLookup.java
index 7a1faaa..0bcd0dd 100644
--- a/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/MapMessageLookup.java
+++ b/log4j-samples/loggerProperties/src/main/java/org/apache/logging/log4j/lookup/MapMessageLookup.java
@@ -51,17 +51,17 @@ public class MapMessageLookup extends AbstractLookup {
*/
@Override
public String lookup(final LogEvent event, final String key) {
- Message msg = event.getMessage();
+ final Message msg = event.getMessage();
if (msg instanceof MapMessage) {
try {
- Map<String, String> properties = ((MapMessage) msg).getData();
+ final Map<String, String> properties = ((MapMessage) msg).getData();
if (properties == null) {
return "";
}
if (key == null || key.length() == 0 || key.equals("*")) {
- StringBuilder sb = new StringBuilder("{");
+ final StringBuilder sb = new StringBuilder("{");
boolean first = true;
- for (Map.Entry<String, String> entry : properties.entrySet()) {
+ for (final Map.Entry<String, String> entry : properties.entrySet()) {
if (!first) {
sb.append(", ");
}
@@ -80,7 +80,7 @@ public class MapMessageLookup extends AbstractLookup {
return null;
}
- public static void setLoggerProperties(String loggerName, Map<String, String> properties) {
+ public static void setLoggerProperties(final String loggerName, final Map<String, String> properties) {
loggerProperties.put(loggerName, properties);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-samples/loggerProperties/src/test/java/org/apache/logging/log4j/CustomPropertiesTest.java
----------------------------------------------------------------------
diff --git a/log4j-samples/loggerProperties/src/test/java/org/apache/logging/log4j/CustomPropertiesTest.java b/log4j-samples/loggerProperties/src/test/java/org/apache/logging/log4j/CustomPropertiesTest.java
index 3612dde..5c5321b 100644
--- a/log4j-samples/loggerProperties/src/test/java/org/apache/logging/log4j/CustomPropertiesTest.java
+++ b/log4j-samples/loggerProperties/src/test/java/org/apache/logging/log4j/CustomPropertiesTest.java
@@ -30,8 +30,8 @@ public class CustomPropertiesTest {
@Test
public void testProperties() throws Exception {
- Logger logger = LogManager.getLogger("TestProperties");
- Map<String, String> loggerProperties = new ConcurrentHashMap<>();
+ final Logger logger = LogManager.getLogger("TestProperties");
+ final Map<String, String> loggerProperties = new ConcurrentHashMap<>();
CustomLookup.setLoggerProperties("TestProperties", loggerProperties);
loggerProperties.put("key1", "CustomPropertiesTest");
loggerProperties.put("key2", "TestValue");
@@ -40,8 +40,8 @@ public class CustomPropertiesTest {
@Test
public void mapMessageProperties() throws Exception {
- Logger logger = LogManager.getLogger("MapProperties");
- Map<String, String> loggerProperties = new ConcurrentHashMap<>();
+ final Logger logger = LogManager.getLogger("MapProperties");
+ final Map<String, String> loggerProperties = new ConcurrentHashMap<>();
loggerProperties.put("key1", "CustomPropertiesTest");
loggerProperties.put("key2", "TestValue");
logger.debug(new CustomMapMessage("This is a test", loggerProperties));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java b/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
index fb95d97..7e193dd 100644
--- a/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
+++ b/log4j-taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
@@ -87,12 +87,12 @@ final class Log4jTaglibLoggerContext implements LoggerContext {
}
@Override
- public boolean hasLogger(String name, MessageFactory messageFactory) {
+ public boolean hasLogger(final String name, final MessageFactory messageFactory) {
return loggerRegistry.hasLogger(name, messageFactory);
}
@Override
- public boolean hasLogger(String name, Class<? extends MessageFactory> messageFactoryClass) {
+ public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
return loggerRegistry.hasLogger(name, messageFactoryClass);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
index 7923b2b..4c0120b 100644
--- a/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
+++ b/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
@@ -62,12 +62,12 @@ public class SLF4JLoggerContext implements LoggerContext {
}
@Override
- public boolean hasLogger(String name, MessageFactory messageFactory) {
+ public boolean hasLogger(final String name, final MessageFactory messageFactory) {
return loggerRegistry.hasLogger(name, messageFactory);
}
@Override
- public boolean hasLogger(String name, Class<? extends MessageFactory> messageFactoryClass) {
+ public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
return loggerRegistry.hasLogger(name, messageFactoryClass);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-web/src/main/java/org/apache/logging/log4j/web/ServletRequestThreadContext.java
----------------------------------------------------------------------
diff --git a/log4j-web/src/main/java/org/apache/logging/log4j/web/ServletRequestThreadContext.java b/log4j-web/src/main/java/org/apache/logging/log4j/web/ServletRequestThreadContext.java
index c8e5221..d7820b2 100644
--- a/log4j-web/src/main/java/org/apache/logging/log4j/web/ServletRequestThreadContext.java
+++ b/log4j-web/src/main/java/org/apache/logging/log4j/web/ServletRequestThreadContext.java
@@ -25,21 +25,21 @@ import org.apache.logging.log4j.ThreadContext;
public class ServletRequestThreadContext {
- public static void put(String key, ServletRequest servletRequest) {
+ public static void put(final String key, final ServletRequest servletRequest) {
put(key, "RemoteAddr", servletRequest.getRemoteAddr());
put(key, "RemoteHost", servletRequest.getRemoteHost());
put(key, "RemotePort", servletRequest.getRemotePort());
}
- public static void put(String key, String field, Object value) {
+ public static void put(final String key, final String field, final Object value) {
put(key + "." + field, Objects.toString(value));
}
- public static void put(String key, String value) {
+ public static void put(final String key, final String value) {
ThreadContext.put(key, value);
}
- public static void put(String key, HttpServletRequest servletRequest) {
+ public static void put(final String key, final HttpServletRequest servletRequest) {
put(key, (ServletRequest) servletRequest);
}
}
[3/6] logging-log4j2 git commit: Use final.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
index d279660..48d2a10 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModifiedTest.java
@@ -1,97 +1,97 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.nio.file.attribute.FileTime;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the FileAgeFilter class.
- */
-public class IfLastModifiedTest {
-
- @Test
- public void testGetDurationReturnsConstructorValue() {
- IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("P7D"));
- assertEquals(0, filter.getAge().compareTo(Duration.parse("P7D")));
- }
-
- @Test
- public void testAcceptsIfFileAgeEqualToDuration() {
- IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
- DummyFileAttributes attrs = new DummyFileAttributes();
- final long age = 33 * 1000;
- attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
- assertTrue(filter.accept(null, null, attrs));
- }
-
- @Test
- public void testAcceptsIfFileAgeExceedsDuration() {
- IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
- DummyFileAttributes attrs = new DummyFileAttributes();
- final long age = 33 * 1000 + 5;
- attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
- assertTrue(filter.accept(null, null, attrs));
- }
-
- @Test
- public void testDoesNotAcceptIfFileAgeLessThanDuration() {
- IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
- DummyFileAttributes attrs = new DummyFileAttributes();
- final long age = 33 * 1000 - 5;
- attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
- assertFalse(filter.accept(null, null, attrs));
- }
-
- @Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
- final CountingCondition counter = new CountingCondition(true);
- IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter);
- DummyFileAttributes attrs = new DummyFileAttributes();
- final long oldEnough = 33 * 1000 + 5;
- attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - oldEnough);
-
- assertTrue(filter.accept(null, null, attrs));
- assertEquals(1, counter.getAcceptCount());
- assertTrue(filter.accept(null, null, attrs));
- assertEquals(2, counter.getAcceptCount());
- assertTrue(filter.accept(null, null, attrs));
- assertEquals(3, counter.getAcceptCount());
-
- final long tooYoung = 33 * 1000 - 5;
- attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - tooYoung);
- assertFalse(filter.accept(null, null, attrs));
- assertEquals(3, counter.getAcceptCount()); // no increase
- assertFalse(filter.accept(null, null, attrs));
- assertEquals(3, counter.getAcceptCount());
- assertFalse(filter.accept(null, null, attrs));
- assertEquals(3, counter.getAcceptCount());
- }
-
- @Test
- public void testBeforeTreeWalk() {
- final CountingCondition counter = new CountingCondition(true);
- final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter, counter,
- counter);
- filter.beforeFileTreeWalk();
- assertEquals(3, counter.getBeforeFileTreeWalkCount());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.attribute.FileTime;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the FileAgeFilter class.
+ */
+public class IfLastModifiedTest {
+
+ @Test
+ public void testGetDurationReturnsConstructorValue() {
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("P7D"));
+ assertEquals(0, filter.getAge().compareTo(Duration.parse("P7D")));
+ }
+
+ @Test
+ public void testAcceptsIfFileAgeEqualToDuration() {
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
+ final DummyFileAttributes attrs = new DummyFileAttributes();
+ final long age = 33 * 1000;
+ attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
+ assertTrue(filter.accept(null, null, attrs));
+ }
+
+ @Test
+ public void testAcceptsIfFileAgeExceedsDuration() {
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
+ final DummyFileAttributes attrs = new DummyFileAttributes();
+ final long age = 33 * 1000 + 5;
+ attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
+ assertTrue(filter.accept(null, null, attrs));
+ }
+
+ @Test
+ public void testDoesNotAcceptIfFileAgeLessThanDuration() {
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
+ final DummyFileAttributes attrs = new DummyFileAttributes();
+ final long age = 33 * 1000 - 5;
+ attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
+ assertFalse(filter.accept(null, null, attrs));
+ }
+
+ @Test
+ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter);
+ final DummyFileAttributes attrs = new DummyFileAttributes();
+ final long oldEnough = 33 * 1000 + 5;
+ attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - oldEnough);
+
+ assertTrue(filter.accept(null, null, attrs));
+ assertEquals(1, counter.getAcceptCount());
+ assertTrue(filter.accept(null, null, attrs));
+ assertEquals(2, counter.getAcceptCount());
+ assertTrue(filter.accept(null, null, attrs));
+ assertEquals(3, counter.getAcceptCount());
+
+ final long tooYoung = 33 * 1000 - 5;
+ attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - tooYoung);
+ assertFalse(filter.accept(null, null, attrs));
+ assertEquals(3, counter.getAcceptCount()); // no increase
+ assertFalse(filter.accept(null, null, attrs));
+ assertEquals(3, counter.getAcceptCount());
+ assertFalse(filter.accept(null, null, attrs));
+ assertEquals(3, counter.getAcceptCount());
+ }
+
+ @Test
+ public void testBeforeTreeWalk() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter, counter,
+ counter);
+ filter.beforeFileTreeWalk();
+ assertEquals(3, counter.getBeforeFileTreeWalkCount());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
index dcd5ffd..255fec4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTimeTest.java
@@ -42,11 +42,11 @@ public class PathSortByModificationTimeTest {
@Test
public void testCompareRecentFirst() {
- PathSorter sorter = PathSortByModificationTime.createSorter(true);
- Path p1 = Paths.get("aaa");
- Path p2 = Paths.get("bbb");
- DummyFileAttributes a1 = new DummyFileAttributes();
- DummyFileAttributes a2 = new DummyFileAttributes();
+ final PathSorter sorter = PathSortByModificationTime.createSorter(true);
+ final Path p1 = Paths.get("aaa");
+ final Path p2 = Paths.get("bbb");
+ final DummyFileAttributes a1 = new DummyFileAttributes();
+ final DummyFileAttributes a2 = new DummyFileAttributes();
a1.lastModified = FileTime.fromMillis(100);
a2.lastModified = FileTime.fromMillis(222);
@@ -65,11 +65,11 @@ public class PathSortByModificationTimeTest {
@Test
public void testCompareRecentLast() {
- PathSorter sorter = PathSortByModificationTime.createSorter(false);
- Path p1 = Paths.get("aaa");
- Path p2 = Paths.get("bbb");
- DummyFileAttributes a1 = new DummyFileAttributes();
- DummyFileAttributes a2 = new DummyFileAttributes();
+ final PathSorter sorter = PathSortByModificationTime.createSorter(false);
+ final Path p1 = Paths.get("aaa");
+ final Path p2 = Paths.get("bbb");
+ final DummyFileAttributes a1 = new DummyFileAttributes();
+ final DummyFileAttributes a2 = new DummyFileAttributes();
a1.lastModified = FileTime.fromMillis(100);
a2.lastModified = FileTime.fromMillis(222);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
index aadfac9..b3198ba 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptConditionTest.java
@@ -1,130 +1,130 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.script.Script;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the ScriptCondition class.
- */
-public class ScriptConditionTest {
-
- @Test(expected = NullPointerException.class)
- public void testConstructorDisallowsNullScript() {
- new ScriptCondition(null, new DefaultConfiguration());
- }
-
- @Test(expected = NullPointerException.class)
- public void testConstructorDisallowsNullConfig() {
- new ScriptCondition(new Script("test", "js", "print('hi')"), null);
- }
-
- @Test
- public void testCreateConditionReturnsNullForNullScript() {
- assertNull(ScriptCondition.createCondition(null, new DefaultConfiguration()));
- }
-
- @Test(expected = NullPointerException.class)
- public void testCreateConditionDisallowsNullConfig() {
- ScriptCondition.createCondition(new Script("test", "js", "print('hi')"), null);
- }
-
- @Test
- public void testSelectFilesToDelete() {
- Configuration config = new DefaultConfiguration();
- config.initialize(); // creates the ScriptManager
-
- Script script = new Script("test", "javascript", "pathList;"); // script that returns pathList
- ScriptCondition condition = new ScriptCondition(script, config);
- List<PathWithAttributes> pathList = new ArrayList<>();
- Path base = Paths.get("baseDirectory");
- List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
- assertSame(result, pathList);
- }
-
- @Test
- public void testSelectFilesToDelete2() {
- Configuration config = new DefaultConfiguration();
- config.initialize(); // creates the ScriptManager
-
- List<PathWithAttributes> pathList = new ArrayList<>();
- pathList.add(new PathWithAttributes(Paths.get("/path/1"), new DummyFileAttributes()));
- pathList.add(new PathWithAttributes(Paths.get("/path/2"), new DummyFileAttributes()));
- pathList.add(new PathWithAttributes(Paths.get("/path/3"), new DummyFileAttributes()));
-
- String scriptText = "pathList.remove(1);" //
- + "pathList;";
- Script script = new Script("test", "javascript", scriptText);
- ScriptCondition condition = new ScriptCondition(script, config);
- Path base = Paths.get("baseDirectory");
- List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
- assertSame(result, pathList);
- assertEquals(2, result.size());
- assertEquals(Paths.get("/path/1"), result.get(0).getPath());
- assertEquals(Paths.get("/path/3"), result.get(1).getPath());
- }
-
- @Test
- public void testSelectFilesToDelete3() {
- Configuration config = new DefaultConfiguration();
- config.initialize(); // creates the ScriptManager
-
- List<PathWithAttributes> pathList = new ArrayList<>();
- pathList.add(new PathWithAttributes(Paths.get("/path/1/abc/a.txt"), new DummyFileAttributes()));
- pathList.add(new PathWithAttributes(Paths.get("/path/2/abc/bbb.txt"), new DummyFileAttributes()));
- pathList.add(new PathWithAttributes(Paths.get("/path/3/abc/c.txt"), new DummyFileAttributes()));
-
- String scriptText = "" //
- + "import java.nio.file.*;" //
- + "def pattern = ~/(\\d*)[\\/\\\\]abc[\\/\\\\].*\\.txt/;" //
- + "assert pattern.getClass() == java.util.regex.Pattern;" //
- + "def copy = pathList.collect{it};"
- + "pathList.each { pathWithAttribs -> \n" //
- + " def relative = basePath.relativize pathWithAttribs.path;" //
- + " println 'relative path: ' + relative;" //
- + " def str = relative.toString();"
- + " def m = pattern.matcher(str);" //
- + " if (m.find()) {" //
- + " def index = m.group(1) as int;" //
- + " println 'extracted index: ' + index;" //
- + " def isOdd = (index % 2) == 1;"
- + " println 'is odd: ' + isOdd;" //
- + " if (isOdd) { copy.remove pathWithAttribs}"
- + " }" //
- + "}" //
- + "println copy;"
- + "copy;";
- Script script = new Script("test", "groovy", scriptText);
- ScriptCondition condition = new ScriptCondition(script, config);
- Path base = Paths.get("/path");
- List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
- assertEquals(1, result.size());
- assertEquals(Paths.get("/path/2/abc/bbb.txt"), result.get(0).getPath());
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.DefaultConfiguration;
+import org.apache.logging.log4j.core.script.Script;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the ScriptCondition class.
+ */
+public class ScriptConditionTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testConstructorDisallowsNullScript() {
+ new ScriptCondition(null, new DefaultConfiguration());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testConstructorDisallowsNullConfig() {
+ new ScriptCondition(new Script("test", "js", "print('hi')"), null);
+ }
+
+ @Test
+ public void testCreateConditionReturnsNullForNullScript() {
+ assertNull(ScriptCondition.createCondition(null, new DefaultConfiguration()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testCreateConditionDisallowsNullConfig() {
+ ScriptCondition.createCondition(new Script("test", "js", "print('hi')"), null);
+ }
+
+ @Test
+ public void testSelectFilesToDelete() {
+ final Configuration config = new DefaultConfiguration();
+ config.initialize(); // creates the ScriptManager
+
+ final Script script = new Script("test", "javascript", "pathList;"); // script that returns pathList
+ final ScriptCondition condition = new ScriptCondition(script, config);
+ final List<PathWithAttributes> pathList = new ArrayList<>();
+ final Path base = Paths.get("baseDirectory");
+ final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
+ assertSame(result, pathList);
+ }
+
+ @Test
+ public void testSelectFilesToDelete2() {
+ final Configuration config = new DefaultConfiguration();
+ config.initialize(); // creates the ScriptManager
+
+ final List<PathWithAttributes> pathList = new ArrayList<>();
+ pathList.add(new PathWithAttributes(Paths.get("/path/1"), new DummyFileAttributes()));
+ pathList.add(new PathWithAttributes(Paths.get("/path/2"), new DummyFileAttributes()));
+ pathList.add(new PathWithAttributes(Paths.get("/path/3"), new DummyFileAttributes()));
+
+ final String scriptText = "pathList.remove(1);" //
+ + "pathList;";
+ final Script script = new Script("test", "javascript", scriptText);
+ final ScriptCondition condition = new ScriptCondition(script, config);
+ final Path base = Paths.get("baseDirectory");
+ final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
+ assertSame(result, pathList);
+ assertEquals(2, result.size());
+ assertEquals(Paths.get("/path/1"), result.get(0).getPath());
+ assertEquals(Paths.get("/path/3"), result.get(1).getPath());
+ }
+
+ @Test
+ public void testSelectFilesToDelete3() {
+ final Configuration config = new DefaultConfiguration();
+ config.initialize(); // creates the ScriptManager
+
+ final List<PathWithAttributes> pathList = new ArrayList<>();
+ pathList.add(new PathWithAttributes(Paths.get("/path/1/abc/a.txt"), new DummyFileAttributes()));
+ pathList.add(new PathWithAttributes(Paths.get("/path/2/abc/bbb.txt"), new DummyFileAttributes()));
+ pathList.add(new PathWithAttributes(Paths.get("/path/3/abc/c.txt"), new DummyFileAttributes()));
+
+ final String scriptText = "" //
+ + "import java.nio.file.*;" //
+ + "def pattern = ~/(\\d*)[\\/\\\\]abc[\\/\\\\].*\\.txt/;" //
+ + "assert pattern.getClass() == java.util.regex.Pattern;" //
+ + "def copy = pathList.collect{it};"
+ + "pathList.each { pathWithAttribs -> \n" //
+ + " def relative = basePath.relativize pathWithAttribs.path;" //
+ + " println 'relative path: ' + relative;" //
+ + " def str = relative.toString();"
+ + " def m = pattern.matcher(str);" //
+ + " if (m.find()) {" //
+ + " def index = m.group(1) as int;" //
+ + " println 'extracted index: ' + index;" //
+ + " def isOdd = (index % 2) == 1;"
+ + " println 'is odd: ' + isOdd;" //
+ + " if (isOdd) { copy.remove pathWithAttribs}"
+ + " }" //
+ + "}" //
+ + "println copy;"
+ + "copy;";
+ final Script script = new Script("test", "groovy", scriptText);
+ final ScriptCondition condition = new ScriptCondition(script, config);
+ final Path base = Paths.get("/path");
+ final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
+ assertEquals(1, result.size());
+ assertEquals(Paths.get("/path/2/abc/bbb.txt"), result.get(0).getPath());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
index f5eac73..dd32a0c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitorTest.java
@@ -1,94 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.nio.file.FileVisitOption;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.attribute.FileAttribute;
-import java.nio.file.attribute.FileTime;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the SortingVisitor class.
- */
-public class SortingVisitorTest {
-
- private Path base;
- private Path aaa;
- private Path bbb;
- private Path ccc;
-
- @Before
- public void setUp() throws Exception {
- base = Files.createTempDirectory("tempDir", new FileAttribute<?>[0]);
- aaa = Files.createTempFile(base, "aaa", null, new FileAttribute<?>[0]);
- bbb = Files.createTempFile(base, "bbb", null, new FileAttribute<?>[0]);
- ccc = Files.createTempFile(base, "ccc", null, new FileAttribute<?>[0]);
-
- // lastModified granularity is 1 sec(!) on some file systems...
- final long now = System.currentTimeMillis();
- Files.setLastModifiedTime(aaa, FileTime.fromMillis(now));
- Files.setLastModifiedTime(bbb, FileTime.fromMillis(now + 1000));
- Files.setLastModifiedTime(ccc, FileTime.fromMillis(now + 2000));
- }
-
- @After
- public void tearDown() throws Exception {
- Files.deleteIfExists(ccc);
- Files.deleteIfExists(bbb);
- Files.deleteIfExists(aaa);
- Files.deleteIfExists(base);
- }
-
- @Test
- public void testRecentFirst() throws Exception {
- SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(true));
- Set<FileVisitOption> options = Collections.emptySet();
- Files.walkFileTree(base, options, 1, visitor);
-
- List<PathWithAttributes> found = visitor.getSortedPaths();
- assertNotNull(found);
- assertEquals("file count", 3, found.size());
- assertEquals("1st: most recent; sorted=" + found, ccc, found.get(0).getPath());
- assertEquals("2nd; sorted=" + found, bbb, found.get(1).getPath());
- assertEquals("3rd: oldest; sorted=" + found, aaa, found.get(2).getPath());
- }
-
- @Test
- public void testRecentLast() throws Exception {
- SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(false));
- Set<FileVisitOption> options = Collections.emptySet();
- Files.walkFileTree(base, options, 1, visitor);
-
- List<PathWithAttributes> found = visitor.getSortedPaths();
- assertNotNull(found);
- assertEquals("file count", 3, found.size());
- assertEquals("1st: oldest first; sorted=" + found, aaa, found.get(0).getPath());
- assertEquals("2nd; sorted=" + found, bbb, found.get(1).getPath());
- assertEquals("3rd: most recent sorted; list=" + found, ccc, found.get(2).getPath());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.FileVisitOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileTime;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the SortingVisitor class.
+ */
+public class SortingVisitorTest {
+
+ private Path base;
+ private Path aaa;
+ private Path bbb;
+ private Path ccc;
+
+ @Before
+ public void setUp() throws Exception {
+ base = Files.createTempDirectory("tempDir", new FileAttribute<?>[0]);
+ aaa = Files.createTempFile(base, "aaa", null, new FileAttribute<?>[0]);
+ bbb = Files.createTempFile(base, "bbb", null, new FileAttribute<?>[0]);
+ ccc = Files.createTempFile(base, "ccc", null, new FileAttribute<?>[0]);
+
+ // lastModified granularity is 1 sec(!) on some file systems...
+ final long now = System.currentTimeMillis();
+ Files.setLastModifiedTime(aaa, FileTime.fromMillis(now));
+ Files.setLastModifiedTime(bbb, FileTime.fromMillis(now + 1000));
+ Files.setLastModifiedTime(ccc, FileTime.fromMillis(now + 2000));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Files.deleteIfExists(ccc);
+ Files.deleteIfExists(bbb);
+ Files.deleteIfExists(aaa);
+ Files.deleteIfExists(base);
+ }
+
+ @Test
+ public void testRecentFirst() throws Exception {
+ final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(true));
+ final Set<FileVisitOption> options = Collections.emptySet();
+ Files.walkFileTree(base, options, 1, visitor);
+
+ final List<PathWithAttributes> found = visitor.getSortedPaths();
+ assertNotNull(found);
+ assertEquals("file count", 3, found.size());
+ assertEquals("1st: most recent; sorted=" + found, ccc, found.get(0).getPath());
+ assertEquals("2nd; sorted=" + found, bbb, found.get(1).getPath());
+ assertEquals("3rd: oldest; sorted=" + found, aaa, found.get(2).getPath());
+ }
+
+ @Test
+ public void testRecentLast() throws Exception {
+ final SortingVisitor visitor = new SortingVisitor(new PathSortByModificationTime(false));
+ final Set<FileVisitOption> options = Collections.emptySet();
+ Files.walkFileTree(base, options, 1, visitor);
+
+ final List<PathWithAttributes> found = visitor.getSortedPaths();
+ assertNotNull(found);
+ assertEquals("file count", 3, found.size());
+ assertEquals("1st: oldest first; sorted=" + found, aaa, found.get(0).getPath());
+ assertEquals("2nd; sorted=" + found, bbb, found.get(1).getPath());
+ assertEquals("3rd: most recent sorted; list=" + found, ccc, found.get(2).getPath());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
index c6624ea..4e292ca 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithPurgingTest.java
@@ -84,7 +84,7 @@ public class RoutingAppenderWithPurgingTest {
EventLogger.logEvent(msg);
msg = new StructuredDataMessage("3", "This is a test 3", "Service");
EventLogger.logEvent(msg);
- String[] files = {IDLE_LOG_FILE1, IDLE_LOG_FILE2, IDLE_LOG_FILE3, MANUAL_LOG_FILE1, MANUAL_LOG_FILE2, MANUAL_LOG_FILE3};
+ final String[] files = {IDLE_LOG_FILE1, IDLE_LOG_FILE2, IDLE_LOG_FILE3, MANUAL_LOG_FILE1, MANUAL_LOG_FILE2, MANUAL_LOG_FILE3};
assertFileExistance(files);
assertEquals("Incorrect number of appenders with IdlePurgePolicy.", 3, routingAppenderIdle.getAppenders().size());
@@ -107,7 +107,7 @@ public class RoutingAppenderWithPurgingTest {
}
private void assertFileExistance(final String... files) {
- for (String file : files) {
+ for (final String file : files) {
assertTrue("File should exist - " + file + " file ", new File(file).exists());
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
index 591d08b..349db77 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
@@ -84,7 +84,7 @@ public class AsyncLoggerTestNanoTime {
final String[] line1Parts = line1.split(" AND ");
assertEquals("Use actual System.nanoTime()", line1Parts[2]);
assertEquals(line1Parts[0], line1Parts[1]);
- long loggedNanoTime = Long.parseLong(line1Parts[0]);
+ final long loggedNanoTime = Long.parseLong(line1Parts[0]);
assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1));
final String[] line2Parts = line2.split(" AND ");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
index 305a5ee..2c9ed8a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
@@ -45,7 +45,7 @@ public class AsyncQueueFullPolicyFactoryTest {
@Test
public void testCreateReturnsDefaultRouterByDefault() throws Exception {
- AsyncQueueFullPolicy router = AsyncQueueFullPolicyFactory.create();
+ final AsyncQueueFullPolicy router = AsyncQueueFullPolicyFactory.create();
assertEquals(DefaultAsyncQueueFullPolicy.class, router.getClass());
}
@@ -77,7 +77,7 @@ public class AsyncQueueFullPolicyFactoryTest {
System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
- for (Level level : Level.values()) {
+ for (final Level level : Level.values()) {
System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL,
level.name());
assertEquals(level, ((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
index 22489c2..b05313d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
@@ -36,14 +36,14 @@ public class DefaultAsyncQueueFullPolicyTest {
@Test
public void testGetRouteEnqueuesIfQueueFullAndCalledFromDifferentThread() throws Exception {
- DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
+ final DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), Level.ALL));
assertEquals(EventRoute.ENQUEUE, router.getRoute(otherThreadId(), Level.OFF));
}
@Test
public void testGetRouteSynchronousIfQueueFullAndCalledFromSameThread() throws Exception {
- DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
+ final DefaultAsyncQueueFullPolicy router = new DefaultAsyncQueueFullPolicy();
assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), Level.ALL));
assertEquals(EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), Level.OFF));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
index a979133..ff2350c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/DiscardingAsyncQueueFullPolicyTest.java
@@ -49,9 +49,9 @@ public class DiscardingAsyncQueueFullPolicyTest {
@Test
public void testGetRouteDiscardsIfThresholdCapacityReachedAndLevelEqualOrLessSpecificThanThreshold()
throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
- for (Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
+ for (final Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(otherThreadId(), level));
assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
@@ -61,9 +61,9 @@ public class DiscardingAsyncQueueFullPolicyTest {
@Test
public void testGetRouteDiscardsIfQueueFullAndLevelEqualOrLessSpecificThanThreshold() throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
- for (Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
+ for (final Level level : new Level[] {Level.WARN, Level.INFO, Level.DEBUG, Level.TRACE, Level.ALL}) {
assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(currentThreadId(), level));
assertEquals(level.name(), EventRoute.DISCARD, router.getRoute(otherThreadId(), level));
}
@@ -72,9 +72,9 @@ public class DiscardingAsyncQueueFullPolicyTest {
@Test
public void testGetRouteEnqueuesIfThresholdCapacityReachedButLevelMoreSpecificThanThreshold()
throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
- for (Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
+ for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
assertEquals(level.name(), EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level));
assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
@@ -84,25 +84,25 @@ public class DiscardingAsyncQueueFullPolicyTest {
@Test
public void testGetRouteEnqueuesIfOtherThreadQueueFullAndLevelMoreSpecificThanThreshold() throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
- for (Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
+ for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
assertEquals(level.name(), EventRoute.ENQUEUE, router.getRoute(otherThreadId(), level));
}
}
@Test
public void testGetRouteSynchronousIfCurrentThreadQueueFullAndLevelMoreSpecificThanThreshold() throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.WARN);
- for (Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
+ for (final Level level : new Level[] {Level.ERROR, Level.FATAL, Level.OFF}) {
assertEquals(level.name(), EventRoute.SYNCHRONOUS, router.getRoute(currentThreadId(), level));
}
}
@Test
public void testGetDiscardCount() throws Exception {
- DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.INFO);
+ final DiscardingAsyncQueueFullPolicy router = new DiscardingAsyncQueueFullPolicy(Level.INFO);
assertEquals("initially", 0, DiscardingAsyncQueueFullPolicy.getDiscardCount(router));
assertEquals(EventRoute.DISCARD, router.getRoute(-1L, Level.INFO));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
index 57140b5..c09c428 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
@@ -133,8 +133,8 @@ public class ResponseTimeTest {
// Warmup: run as many iterations of 50,000 calls to logger.log as we can in 1 minute
final long WARMUP_DURATION_MILLIS = TimeUnit.MINUTES.toMillis(1);
- List<Histogram> warmupServiceTmHistograms = new ArrayList<>(threadCount);
- List<Histogram> warmupResponseTmHistograms = new ArrayList<>(threadCount);
+ final List<Histogram> warmupServiceTmHistograms = new ArrayList<>(threadCount);
+ final List<Histogram> warmupResponseTmHistograms = new ArrayList<>(threadCount);
final int WARMUP_COUNT = 50000 / threadCount;
runLatencyTest(logger, WARMUP_DURATION_MILLIS, WARMUP_COUNT, loadMessagesPerSec, idleStrategy,
@@ -146,9 +146,9 @@ public class ResponseTimeTest {
}
System.out.println("-----------------Starting measured run. load=" + loadMessagesPerSec);
- long start = System.currentTimeMillis();
- List<Histogram> serviceTmHistograms = new ArrayList<>(threadCount);
- List<Histogram> responseTmHistograms = new ArrayList<>(threadCount);
+ final long start = System.currentTimeMillis();
+ final List<Histogram> serviceTmHistograms = new ArrayList<>(threadCount);
+ final List<Histogram> responseTmHistograms = new ArrayList<>(threadCount);
PrintingAsyncQueueFullPolicy.ringbufferFull.set(0);
// Actual test: run as many iterations of 1,000,000 calls to logger.log as we can in 4 minutes.
@@ -156,7 +156,7 @@ public class ResponseTimeTest {
final int COUNT = (1000 * 1000) / threadCount;
runLatencyTest(logger, TEST_DURATION_MILLIS, COUNT, loadMessagesPerSec, idleStrategy, serviceTmHistograms,
responseTmHistograms, threadCount);
- long end = System.currentTimeMillis();
+ final long end = System.currentTimeMillis();
// ... and report the results
final Histogram resultServiceTm = createResultHistogram(serviceTmHistograms, start, end);
@@ -208,7 +208,7 @@ public class ResponseTimeTest {
LATCH.countDown();
try {
LATCH.await(); // wait until all threads are ready to go
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
interrupt();
return;
}
@@ -317,7 +317,7 @@ public class ResponseTimeTest {
public long nsecToNextOperation() {
- long now = System.nanoTime();
+ final long now = System.nanoTime();
long nextStartTime = expectedNextOperationNanoTime();
@@ -337,7 +337,7 @@ public class ResponseTimeTest {
}
// Figure out if it's time to send, per catch up throughput:
- long unitsCompletedSinceCatchUpStart =
+ final long unitsCompletedSinceCatchUpStart =
unitsCompleted - unitsCompletedAtCatchUpStart;
nextStartTime = catchUpStartTime +
@@ -358,7 +358,7 @@ public class ResponseTimeTest {
* @param unitCount
*/
public void acquire(final long unitCount) {
- long nsecToNextOperation = nsecToNextOperation();
+ final long nsecToNextOperation = nsecToNextOperation();
if (nsecToNextOperation > 0) {
sleepNs(nsecToNextOperation);
}
@@ -367,7 +367,7 @@ public class ResponseTimeTest {
private void sleepNs(final long ns) {
long now = System.nanoTime();
- long deadline = now + ns;
+ final long deadline = now + ns;
while ((now = System.nanoTime()) < deadline) {
idleStrategy.idle();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
index dacc1a5..dd4f82a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
@@ -41,7 +41,7 @@ public class SimplePerfTest {
public static void main(final String[] args) throws Exception {
System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName());
- Logger logger = LogManager.getLogger();
+ final Logger logger = LogManager.getLogger();
if (!(logger instanceof AsyncLogger)) {
throw new IllegalStateException();
}
@@ -58,8 +58,8 @@ public class SimplePerfTest {
final long[] DURATIONS = new long[1024];
// warmup
- long startMs = System.currentTimeMillis();
- long end = startMs + TimeUnit.SECONDS.toMillis(10);
+ final long startMs = System.currentTimeMillis();
+ final long end = startMs + TimeUnit.SECONDS.toMillis(10);
int warmupCount = 0;
do {
runTest(logger, runtimeMXBean, UPTIMES, DURATIONS, warmupCount);
@@ -69,23 +69,23 @@ public class SimplePerfTest {
final int COUNT = 10;
for (int i = 0; i < COUNT; i++) {
- int count = warmupCount + i;
+ final int count = warmupCount + i;
runTest(logger, runtimeMXBean, UPTIMES, DURATIONS, count);
// Thread.sleep(1000);// drain buffer
}
- double testDurationNanos = System.nanoTime() - testStartNanos;
+ final double testDurationNanos = System.nanoTime() - testStartNanos;
System.out.println("Done. Calculating stats...");
printReport("Warmup", UPTIMES, DURATIONS, 0, warmupCount);
printReport("Test", UPTIMES, DURATIONS, warmupCount, COUNT);
- StringBuilder sb = new StringBuilder(512);
+ final StringBuilder sb = new StringBuilder(512);
sb.append("Test took: ").append(testDurationNanos/(1000.0*1000.0*1000.0)).append(" sec");
System.out.println(sb);
final List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
for (int i = 0; i < gcBeans.size(); i++) {
- GarbageCollectorMXBean gcBean = gcBeans.get(i);
+ final GarbageCollectorMXBean gcBean = gcBeans.get(i);
sb.setLength(0);
sb.append("GC[").append(gcBean.getName()).append("] ");
sb.append(gcBean.getCollectionCount()).append(" collections, collection time=");
@@ -96,7 +96,7 @@ public class SimplePerfTest {
private static void printReport(final String label, final long[] UPTIMES, final long[] DURATIONS,
final int offset, final int length) {
- StringBuilder sb = new StringBuilder(512);
+ final StringBuilder sb = new StringBuilder(512);
long total = 0;
for (int i = offset; i < offset + length; i++) {
sb.setLength(0);
@@ -117,9 +117,9 @@ public class SimplePerfTest {
private static void runTest(final Logger logger, final RuntimeMXBean runtimeMXBean, final long[] UPTIMES,
final long[] DURATIONS, final int index) {
UPTIMES[index] = runtimeMXBean.getUptime();
- long startNanos = System.nanoTime();
+ final long startNanos = System.nanoTime();
loop(logger, ITERATIONS);
- long endNanos = System.nanoTime();
+ final long endNanos = System.nanoTime();
DURATIONS[index] = endNanos - startNanos;
}
@@ -138,11 +138,11 @@ public class SimplePerfTest {
private static void workAroundLog4j2_5Bug() {
// use reflection so we can use the same test with older versions of log4j2
try {
- Method setUseThreadLocals =
+ final Method setUseThreadLocals =
AsyncLoggerContext.class.getDeclaredMethod("setUseThreadLocals", new Class[]{boolean.class});
- LoggerContext context = LogManager.getContext(false);
+ final LoggerContext context = LogManager.getContext(false);
setUseThreadLocals.invoke(context, new Object[] {Boolean.TRUE});
- } catch (Throwable ignored) {
+ } catch (final Throwable ignored) {
}
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
index 43d91cc..e5db9cc 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AbstractLog4j2_1100Test.java
@@ -1,68 +1,68 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-public abstract class AbstractLog4j2_1100Test {
-
- @Rule
- public LoggerContextRule context = new LoggerContextRule(getConfigurationResource());
-
- protected abstract String getConfigurationResource();
-
- @Test
- public void test() {
- final Configuration configuration = context.getConfiguration();
- assertNotNull(configuration);
- final RollingFileAppender appender = configuration.getAppender("File");
- assertNotNull(appender);
- final CompositeTriggeringPolicy compositeTriggeringPolicy = appender.getTriggeringPolicy();
- assertNotNull(compositeTriggeringPolicy);
- final TriggeringPolicy[] triggeringPolicies = compositeTriggeringPolicy.getTriggeringPolicies();
- SizeBasedTriggeringPolicy sizeBasedTriggeringPolicy = null;
- TimeBasedTriggeringPolicy timeBasedTriggeringPolicy = null;
- for (TriggeringPolicy triggeringPolicy : triggeringPolicies) {
- if (triggeringPolicy instanceof TimeBasedTriggeringPolicy) {
- timeBasedTriggeringPolicy = (TimeBasedTriggeringPolicy) triggeringPolicy;
- assertEquals(7, timeBasedTriggeringPolicy.getInterval());
- }
- if (triggeringPolicy instanceof SizeBasedTriggeringPolicy) {
- sizeBasedTriggeringPolicy = (SizeBasedTriggeringPolicy) triggeringPolicy;
- assertEquals(100 * 1024 * 1024, sizeBasedTriggeringPolicy.getMaxFileSize());
- }
- }
- if (timeBasedTriggeringPolicy == null) {
- fail("Missing TimeBasedTriggeringPolicy");
- }
- if (sizeBasedTriggeringPolicy == null) {
- fail("Missing SizeBasedTriggeringPolicy");
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
+import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
+import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
+import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
+import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+public abstract class AbstractLog4j2_1100Test {
+
+ @Rule
+ public LoggerContextRule context = new LoggerContextRule(getConfigurationResource());
+
+ protected abstract String getConfigurationResource();
+
+ @Test
+ public void test() {
+ final Configuration configuration = context.getConfiguration();
+ assertNotNull(configuration);
+ final RollingFileAppender appender = configuration.getAppender("File");
+ assertNotNull(appender);
+ final CompositeTriggeringPolicy compositeTriggeringPolicy = appender.getTriggeringPolicy();
+ assertNotNull(compositeTriggeringPolicy);
+ final TriggeringPolicy[] triggeringPolicies = compositeTriggeringPolicy.getTriggeringPolicies();
+ SizeBasedTriggeringPolicy sizeBasedTriggeringPolicy = null;
+ TimeBasedTriggeringPolicy timeBasedTriggeringPolicy = null;
+ for (final TriggeringPolicy triggeringPolicy : triggeringPolicies) {
+ if (triggeringPolicy instanceof TimeBasedTriggeringPolicy) {
+ timeBasedTriggeringPolicy = (TimeBasedTriggeringPolicy) triggeringPolicy;
+ assertEquals(7, timeBasedTriggeringPolicy.getInterval());
+ }
+ if (triggeringPolicy instanceof SizeBasedTriggeringPolicy) {
+ sizeBasedTriggeringPolicy = (SizeBasedTriggeringPolicy) triggeringPolicy;
+ assertEquals(100 * 1024 * 1024, sizeBasedTriggeringPolicy.getMaxFileSize());
+ }
+ }
+ if (timeBasedTriggeringPolicy == null) {
+ fail("Missing TimeBasedTriggeringPolicy");
+ }
+ if (sizeBasedTriggeringPolicy == null) {
+ fail("Missing SizeBasedTriggeringPolicy");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AppenderControlArraySetTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AppenderControlArraySetTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AppenderControlArraySetTest.java
index f742f04..58ac9ea 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AppenderControlArraySetTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/AppenderControlArraySetTest.java
@@ -63,7 +63,7 @@ public class AppenderControlArraySetTest {
final AppenderControlArraySet set = new AppenderControlArraySet();
final AppenderControl[] controls = new AppenderControl[] {createControl("A"), createControl("B"),
createControl("B"), createControl("B"), createControl("A")};
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
set.add(ctl);
}
assertEquals(2, set.get().length);
@@ -118,7 +118,7 @@ public class AppenderControlArraySetTest {
final AppenderControlArraySet set = new AppenderControlArraySet();
final AppenderControl[] controls = new AppenderControl[] {createControl("A"), createControl("B"),
createControl("C"), createControl("D")};
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
set.add(ctl);
}
assertEquals(controls.length, set.get().length);
@@ -135,11 +135,11 @@ public class AppenderControlArraySetTest {
final AppenderControlArraySet set = new AppenderControlArraySet();
final AppenderControl[] controls = new AppenderControl[] {createControl("A"), createControl("B"),
createControl("C"), createControl("D")};
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
set.add(ctl);
}
final Map<String, Appender> expected = new HashMap<>();
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
expected.put(ctl.getAppenderName(), ctl.getAppender());
}
assertEquals(expected, set.asMap());
@@ -162,7 +162,7 @@ public class AppenderControlArraySetTest {
final AppenderControlArraySet set = new AppenderControlArraySet();
final AppenderControl[] controls = new AppenderControl[] {createControl("A"), createControl("B"),
createControl("C")};
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
set.add(ctl);
}
assertEquals(3, set.get().length);
@@ -182,7 +182,7 @@ public class AppenderControlArraySetTest {
final AppenderControlArraySet set = new AppenderControlArraySet();
final AppenderControl[] controls = new AppenderControl[] {createControl("A"), createControl("B"),
createControl("C")};
- for (AppenderControl ctl : controls) {
+ for (final AppenderControl ctl : controls) {
set.add(ctl);
}
assertEquals(3, set.get().length);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java
index ecf57f0..d60c001 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java
@@ -88,10 +88,10 @@ public class CompositeConfigurationTest {
@Test
public void compositeLogger() {
final LoggerContextRule lcr = new LoggerContextRule("classpath:log4j-comp-logger.xml,log4j-comp-logger.json");
- Statement test = new Statement() {
+ final Statement test = new Statement() {
@Override
public void evaluate() throws Throwable {
- CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
+ final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
Map<String, Appender> appendersMap = config.getLogger("cat1").getAppenders();
assertEquals("Expected 2 Appender references for cat1 but got " + appendersMap.size(), 2,
appendersMap.size());
@@ -169,7 +169,7 @@ public class CompositeConfigurationTest {
rule.apply(statement, Description
.createTestDescription(getClass(), Thread.currentThread().getStackTrace()[1].getMethodName()))
.evaluate();
- } catch (Throwable throwable) {
+ } catch (final Throwable throwable) {
throw new RuntimeException(throwable);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
index 94e7420..d73ca30 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
@@ -364,12 +364,12 @@ public class TestConfigurator {
@Test
public void testBuilder() throws Exception {
- ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+ final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel(Level.ERROR);
builder.setConfigurationName("BuilderTest");
builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
.addAttribute("level", Level.DEBUG));
- AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target",
+ final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target",
ConsoleAppender.Target.SYSTEM_OUT);
appenderBuilder.add(builder.newLayout("PatternLayout").
addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
@@ -389,7 +389,7 @@ public class TestConfigurator {
@Test
public void testRolling() throws Exception {
- ConfigurationBuilder< BuiltConfiguration > builder =
+ final ConfigurationBuilder< BuiltConfiguration > builder =
ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel( Level.ERROR);
@@ -401,9 +401,9 @@ public class TestConfigurator {
addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
builder.add( appenderBuilder );
- LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout")
+ final LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout")
.addAttribute("pattern", "%d [%t] %-5level: %msg%n");
- ComponentBuilder triggeringPolicy = builder.newComponent("Policies")
+ final ComponentBuilder triggeringPolicy = builder.newComponent("Policies")
.addComponent(builder.newComponent("CronTriggeringPolicy").addAttribute("schedule", "0 0 0 * * ?"))
.addComponent(builder.newComponent("SizeBasedTriggeringPolicy").addAttribute("size", "100M"));
appenderBuilder = builder.newAppender("rolling", "RollingFile")
@@ -420,30 +420,30 @@ public class TestConfigurator {
builder.add( builder.newRootLogger( Level.DEBUG )
.add( builder.newAppenderRef( "rolling" ) ) );
- Configuration config = builder.build();
+ final Configuration config = builder.build();
config.initialize();
assertNotNull("No rolling file appender", config.getAppender("rolling"));
assertEquals("Unexpected Configuration", "RollingBuilder", config.getName());
// Initialize the new configuration
- LoggerContext ctx = Configurator.initialize( config );
+ final LoggerContext ctx = Configurator.initialize( config );
Configurator.shutdown(ctx);
}
@Test
public void testBuilderWithScripts() throws Exception {
- String script = "if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" +
+ final String script = "if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" +
" return \"NoLocation\";\n" +
" } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n" +
" return \"Flow\";\n" +
" } else {\n" +
" return null;\n" +
" }";
- ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
+ final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel(Level.ERROR);
builder.setConfigurationName("BuilderTest");
builder.add(builder.newScriptFile("filter.groovy", "target/test-classes/scripts/filter.groovy").addIsWatched(true));
- AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target",
+ final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target",
ConsoleAppender.Target.SYSTEM_OUT);
appenderBuilder.add(builder.newLayout("PatternLayout").
addComponent(builder.newComponent("ScriptPatternSelector")
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
index ea2c954..99d7518 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
@@ -48,7 +48,7 @@ public class ConfigurationAssemblerTest {
public void testBuildConfiguration() throws Exception {
final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
CustomConfigurationFactory.addTestFixtures("config name", builder);
- Configuration configuration = builder.build();
+ final Configuration configuration = builder.build();
Configurator.initialize(configuration);
validate(configuration);
}
@@ -58,7 +58,7 @@ public class ConfigurationAssemblerTest {
try {
System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY,
"org.apache.logging.log4j.core.config.builder.CustomConfigurationFactory");
- Configuration config = ((LoggerContext) LogManager.getContext(false)).getConfiguration();
+ final Configuration config = ((LoggerContext) LogManager.getContext(false)).getConfiguration();
validate(config);
} finally {
System.getProperties().remove(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY);
@@ -71,16 +71,16 @@ public class ConfigurationAssemblerTest {
assertFalse(config.getName().isEmpty());
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
- Map<String, Appender> appenders = config.getAppenders();
+ final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
- Map<String, LoggerConfig> loggers = config.getLoggers();
+ final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
- Filter filter = config.getFilter();
+ final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
- Logger logger = LogManager.getLogger(getClass());
+ final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
index 659f163..cd65bfb 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
@@ -42,7 +42,7 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true));
builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
.addAttribute("level", Level.DEBUG));
- AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
+ final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
appenderBuilder.add(builder.newLayout("PatternLayout").
addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY,
@@ -62,7 +62,7 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
@Override
public Configuration getConfiguration(final String name, final URI configLocation) {
- ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder();
+ final ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder();
return addTestFixtures(name, builder);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
index 5a8be67..acc5220 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationRootLoggerOnlyTest.java
@@ -42,19 +42,19 @@ public class PropertiesConfigurationRootLoggerOnlyTest {
@Test
public void testPropertiesConfiguration() {
- Configuration config = context.getConfiguration();
+ final Configuration config = context.getConfiguration();
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
- Map<String, Appender> appenders = config.getAppenders();
+ final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
- Map<String, LoggerConfig> loggers = config.getLoggers();
+ final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 1);
- Filter filter = config.getFilter();
+ final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
- Logger logger = LogManager.getLogger(getClass());
+ final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
index dfe24a5..0e3c2c1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationTest.java
@@ -42,19 +42,19 @@ public class PropertiesConfigurationTest {
@Test
public void testPropertiesConfiguration() {
- Configuration config = context.getConfiguration();
+ final Configuration config = context.getConfiguration();
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
- Map<String, Appender> appenders = config.getAppenders();
+ final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
- Map<String, LoggerConfig> loggers = config.getLoggers();
+ final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
- Filter filter = config.getFilter();
+ final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
- Logger logger = LogManager.getLogger(getClass());
+ final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/RollingFilePropertiesTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/RollingFilePropertiesTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/RollingFilePropertiesTest.java
index e216ff8..9baf89b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/RollingFilePropertiesTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/properties/RollingFilePropertiesTest.java
@@ -42,19 +42,19 @@ public class RollingFilePropertiesTest {
@Test
public void testPropertiesConfiguration() {
- Configuration config = context.getConfiguration();
+ final Configuration config = context.getConfiguration();
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
- Map<String, Appender> appenders = config.getAppenders();
+ final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 3);
- Map<String, LoggerConfig> loggers = config.getLoggers();
+ final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
- Filter filter = config.getFilter();
+ final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
- Logger logger = LogManager.getLogger(getClass());
+ final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
}
[6/6] logging-log4j2 git commit: Use final.
Posted by gg...@apache.org.
Use final.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ce4492f6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ce4492f6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ce4492f6
Branch: refs/heads/master
Commit: ce4492f633fb7e54805fd8a2b98cf2bc7c44a725
Parents: 018ca8a
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 11:17:55 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 11:17:55 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/Logger.java | 2 +-
.../log4j/core/appender/AbstractManager.java | 2 +-
.../log4j/core/appender/SocketAppender.java | 2 +-
.../core/appender/mom/kafka/KafkaAppender.java | 226 +++++++-------
.../appender/rolling/CronTriggeringPolicy.java | 4 +-
.../rolling/DefaultRolloverStrategy.java | 6 +-
.../appender/rolling/RollingFileManager.java | 4 +-
.../appender/rolling/action/DeleteAction.java | 2 +-
.../core/appender/rolling/action/Duration.java | 22 +-
.../rolling/action/FileRenameAction.java | 2 +-
.../core/appender/rolling/action/IfAll.java | 2 +-
.../core/appender/rolling/action/IfAny.java | 172 +++++------
.../core/appender/routing/IdlePurgePolicy.java | 12 +-
.../core/appender/routing/RoutingAppender.java | 2 +-
...syncLoggerConfigDefaultExceptionHandler.java | 4 +-
.../AsyncLoggerDefaultExceptionHandler.java | 4 +-
.../logging/log4j/core/async/DisruptorUtil.java | 2 +-
.../log4j/core/async/RingBufferLogEvent.java | 6 +-
.../core/config/AbstractConfiguration.java | 8 +-
.../log4j/core/config/AppenderControl.java | 2 +-
...AwaitUnconditionallyReliabilityStrategy.java | 2 +-
.../log4j/core/config/ConfigurationFactory.java | 8 +-
.../core/config/ConfigurationScheduler.java | 14 +-
.../log4j/core/config/ConfigurationSource.java | 6 +-
.../logging/log4j/core/config/Configurator.java | 8 +-
.../core/config/ReliabilityStrategyFactory.java | 140 ++++-----
.../config/builder/impl/BuiltConfiguration.java | 6 +-
.../composite/CompositeConfiguration.java | 44 +--
.../config/composite/DefaultMergeStrategy.java | 60 ++--
.../core/config/json/JsonConfiguration.java | 2 +-
.../PropertiesConfigurationBuilder.java | 30 +-
.../PropertiesConfigurationFactory.java | 2 +-
.../log4j/core/config/xml/XmlConfiguration.java | 4 +-
.../logging/log4j/core/filter/BurstFilter.java | 2 +-
.../log4j/core/filter/CompositeFilter.java | 8 +-
.../logging/log4j/core/filter/ScriptFilter.java | 16 +-
.../logging/log4j/core/filter/TimeFilter.java | 2 +-
.../log4j/core/impl/Log4jContextFactory.java | 8 +-
.../logging/log4j/core/impl/Log4jLogEvent.java | 2 +-
.../log4j/core/impl/MutableLogEvent.java | 4 +-
.../logging/log4j/core/layout/GelfLayout.java | 8 +-
.../core/layout/MarkerPatternSelector.java | 18 +-
.../log4j/core/layout/PatternLayout.java | 4 +-
.../core/layout/ScriptPatternSelector.java | 20 +-
.../log4j/core/layout/TextEncoderHelper.java | 2 +-
.../ExtendedThrowablePatternConverter.java | 2 +-
.../core/pattern/MessagePatternConverter.java | 2 +-
.../pattern/RootThrowablePatternConverter.java | 2 +-
.../VariablesNotEmptyReplacementConverter.java | 2 +-
.../logging/log4j/core/script/ScriptFile.java | 10 +-
.../log4j/core/script/ScriptManager.java | 12 +-
.../logging/log4j/core/script/ScriptRef.java | 4 +-
.../logging/log4j/core/util/CronExpression.java | 132 ++++----
.../logging/log4j/core/util/FileUtils.java | 2 +-
.../logging/log4j/core/util/JsonUtils.java | 8 +-
.../logging/log4j/core/util/StringEncoder.java | 8 +-
.../logging/log4j/core/util/WatchManager.java | 12 +-
.../core/util/datetime/FixedDateFormat.java | 2 +-
.../log4j/core/GcFreeLoggingTestUtil.java | 2 +-
.../logging/log4j/core/Log4j1222Test.java | 2 +-
.../apache/logging/log4j/core/LogEventTest.java | 4 +-
.../apache/logging/log4j/core/LoggerTest.java | 14 +-
.../logging/log4j/core/PatternSelectorTest.java | 16 +-
.../log4j/core/PropertiesFileConfigTest.java | 2 +-
.../AsyncAppenderQueueFullPolicyTest.java | 4 +-
.../log4j/core/appender/HangingAppender.java | 6 +-
.../log4j/core/appender/SocketAppenderTest.java | 2 +-
.../appender/XmlCompleteFileAppenderTest.java | 2 +-
.../appender/mom/kafka/KafkaAppenderTest.java | 8 +-
.../rolling/RollingAppenderCronTest.java | 10 +-
.../RollingAppenderCustomDeleteActionTest.java | 10 +-
...lingAppenderDeleteAccumulatedCount1Test.java | 20 +-
...lingAppenderDeleteAccumulatedCount2Test.java | 20 +-
...ollingAppenderDeleteAccumulatedSizeTest.java | 4 +-
.../RollingAppenderDeleteMaxDepthTest.java | 20 +-
.../RollingAppenderDeleteNestedTest.java | 20 +-
.../RollingAppenderDeleteScriptFri13thTest.java | 8 +-
.../RollingAppenderDeleteScriptTest.java | 8 +-
...ollingAppenderNoUnconditionalDeleteTest.java | 4 +-
.../rolling/RollingAppenderSizeTest.java | 14 +-
.../rolling/action/DeleteActionTest.java | 36 +--
.../rolling/action/DeletingVisitorTest.java | 46 +--
.../appender/rolling/action/DurationTest.java | 298 +++++++++----------
.../action/IfAccumulatedFileCountTest.java | 150 +++++-----
.../action/IfAccumulatedFileSizeTest.java | 260 ++++++++--------
.../rolling/action/IfLastModifiedTest.java | 194 ++++++------
.../action/PathSortByModificationTimeTest.java | 20 +-
.../rolling/action/ScriptConditionTest.java | 260 ++++++++--------
.../rolling/action/SortingVisitorTest.java | 188 ++++++------
.../routing/RoutingAppenderWithPurgingTest.java | 4 +-
.../core/async/AsyncLoggerTestNanoTime.java | 2 +-
.../async/AsyncQueueFullPolicyFactoryTest.java | 4 +-
.../async/DefaultAsyncQueueFullPolicyTest.java | 4 +-
.../DiscardingAsyncQueueFullPolicyTest.java | 22 +-
.../core/async/perftest/ResponseTimeTest.java | 22 +-
.../core/async/perftest/SimplePerfTest.java | 26 +-
.../core/config/AbstractLog4j2_1100Test.java | 136 ++++-----
.../config/AppenderControlArraySetTest.java | 12 +-
.../core/config/CompositeConfigurationTest.java | 6 +-
.../log4j/core/config/TestConfigurator.java | 20 +-
.../builder/ConfigurationAssemblerTest.java | 12 +-
.../builder/CustomConfigurationFactory.java | 4 +-
...opertiesConfigurationRootLoggerOnlyTest.java | 10 +-
.../properties/PropertiesConfigurationTest.java | 10 +-
.../properties/RollingFilePropertiesTest.java | 10 +-
.../core/filter/AbstractFilterableTest.java | 86 +++---
.../core/filter/AbstractScriptFilterTest.java | 8 +-
.../core/impl/Log4jLogEventNanoTimeTest.java | 2 +-
.../log4j/core/impl/Log4jLogEventTest.java | 12 +-
.../log4j/core/impl/MutableLogEventTest.java | 12 +-
.../core/impl/ReusableLogEventFactoryTest.java | 12 +-
.../layout/CsvParameterLayoutAllAsyncTest.java | 6 +-
.../core/layout/CsvParameterLayoutTest.java | 6 +-
.../log4j/core/layout/GelfLayoutTest.java | 2 +-
.../layout/PatternLayoutMainMapLookupTest.java | 128 ++++----
.../log4j/core/layout/PatternLayoutTest.java | 8 +-
.../log4j/core/layout/PatternSelectorTest.java | 4 +-
.../core/layout/StringBuilderEncoderTest.java | 6 +-
.../server/UdpSerializedSocketServerTest.java | 2 +
.../core/net/ssl/SslConfigurationTest.java | 4 +-
.../pattern/EqualsReplacementConverterTest.java | 2 +-
.../log4j/core/pattern/PatternParserTest.java | 8 +-
.../log4j/core/util/CronExpressionTest.java | 32 +-
.../log4j/core/util/WatchManagerTest.java | 16 +-
.../apache/logging/log4j/junit/CleanFiles.java | 6 +-
.../logging/log4j/junit/LoggerContextRule.java | 2 +-
...MutableLogEventWithReusableParamMsgTest.java | 4 +-
.../log4j/test/appender/BlockingAppender.java | 2 +-
.../test/appender/EncodingListAppender.java | 8 +-
.../log4j/flume/appender/FlumeAppenderTest.java | 2 +-
.../nosql/appender/mongodb/MongoDbProvider.java | 4 +-
.../message/ParameterFormatterBenchmark.java | 40 +--
...ractStringLayoutStringEncodingBenchmark.java | 32 +-
.../log4j/perf/jmh/CollectionsBenchmark.java | 12 +-
.../log4j/perf/jmh/FileAppenderBenchmark.java | 10 +-
.../perf/jmh/FileAppenderParamsBenchmark.java | 10 +-
.../jmh/Log4j2AppenderComparisonBenchmark.java | 6 +-
.../log4j/perf/jmh/LoggerConfigBenchmark.java | 2 +-
.../jmh/MemoryHandlerJULLocationBenchmark.java | 2 +-
.../perf/jmh/ParameterizedMessageBenchmark.java | 2 +-
.../ParameterizedMessageInliningBenchmark.java | 20 +-
.../jmh/PatternLayoutComparisonBenchmark.java | 2 +-
.../log4j/perf/jmh/StringEncodingBenchmark.java | 30 +-
.../perf/jmh/TextEncoderHelperBenchmark.java | 12 +-
...ThreadLocalVsConcurrentHashMapBenchmark.java | 6 +-
.../perf/jmh/ThreadLocalVsPoolBenchmark.java | 14 +-
.../perf/jmh/ThreadsafeDateFormatBenchmark.java | 4 +-
.../log4j/perf/jmh/VarargsBenchmark.java | 6 +-
.../logging/log4j/perf/nogc/AbstractLogger.java | 6 +-
.../logging/log4j/perf/nogc/ClassicLogger.java | 2 +-
.../logging/log4j/perf/nogc/DemoAppender.java | 12 +-
.../logging/log4j/perf/nogc/NoGcLayout.java | 16 +-
.../logging/log4j/perf/nogc/NoGcLogger.java | 2 +-
.../logging/log4j/perf/nogc/NoGcMessage.java | 10 +-
.../log4j/perf/nogc/ParameterizedMessage.java | 6 +-
.../apache/logging/log4j/perf/nogc/Test.java | 24 +-
.../logging/log4j/perf/util/DemoAppender.java | 10 +-
.../configuration/CustomConfiguration.java | 2 +-
.../logging/log4j/lookup/CustomLookup.java | 8 +-
.../logging/log4j/lookup/CustomMapMessage.java | 2 +-
.../logging/log4j/lookup/MapMessageLookup.java | 10 +-
.../logging/log4j/CustomPropertiesTest.java | 8 +-
.../log4j/taglib/Log4jTaglibLoggerContext.java | 4 +-
.../logging/slf4j/SLF4JLoggerContext.java | 4 +-
.../log4j/web/ServletRequestThreadContext.java | 8 +-
165 files changed, 1895 insertions(+), 1893 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
index 99f4207..ef90b40 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/Logger.java
@@ -604,7 +604,7 @@ public class Logger extends AbstractLogger implements Supplier<LoggerConfig> {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append("PrivateConfig [loggerConfig=");
builder.append(loggerConfig);
builder.append(", config=");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
index fd15f17..9c67f24 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
@@ -151,7 +151,7 @@ public abstract class AbstractManager {
}
protected void log(final Level level, final String message, final Throwable throwable) {
- Message m = LOGGER.getMessageFactory().newMessage("{} {} {}: {}",
+ final Message m = LOGGER.getMessageFactory().newMessage("{} {} {}: {}",
getClass().getSimpleName(), getName(), message, throwable);
LOGGER.log(level, m, throwable);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
index c49ed46..3b610bc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
@@ -204,7 +204,7 @@ public class SocketAppender extends AbstractOutputStreamAppender<AbstractSocketM
final String advertise,
final Configuration config) {
// @formatter:on
- boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
+ final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final boolean fail = Booleans.parseBoolean(immediateFail, true);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
index 18f5c52..8619f3d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java
@@ -1,113 +1,113 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.mom.kafka;
-
-import java.io.Serializable;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.appender.AppenderLoggingException;
-import org.apache.logging.log4j.core.config.Node;
-import org.apache.logging.log4j.core.config.Property;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-import org.apache.logging.log4j.core.util.StringEncoder;
-
-/**
- * Sends log events to an Apache Kafka topic.
- */
-@Plugin(name = "Kafka", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
-public final class KafkaAppender extends AbstractAppender {
-
- @PluginFactory
- public static KafkaAppender createAppender(
- @PluginElement("Layout") final Layout<? extends Serializable> layout,
- @PluginElement("Filter") final Filter filter,
- @Required(message = "No name provided for KafkaAppender") @PluginAttribute("name") final String name,
- @PluginAttribute(value = "ignoreExceptions", defaultBoolean = true) final boolean ignoreExceptions,
- @Required(message = "No topic provided for KafkaAppender") @PluginAttribute("topic") final String topic,
- @PluginElement("Properties") final Property[] properties) {
- final KafkaManager kafkaManager = new KafkaManager(name, topic, properties);
- return new KafkaAppender(name, layout, filter, ignoreExceptions, kafkaManager);
- }
-
- private final KafkaManager manager;
-
- private KafkaAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter, final boolean ignoreExceptions, final KafkaManager manager) {
- super(name, filter, layout, ignoreExceptions);
- this.manager = manager;
- }
-
- @Override
- public void append(final LogEvent event) {
- if (event.getLoggerName().startsWith("org.apache.kafka")) {
- LOGGER.warn("Recursive logging from [{}] for appender [{}].", event.getLoggerName(), getName());
- } else {
- try {
- Layout<? extends Serializable> layout = getLayout();
- byte[] data;
- if (layout != null) {
- if (layout instanceof SerializedLayout) {
- byte[] header = layout.getHeader();
- byte[] body = layout.toByteArray(event);
- data = new byte[header.length + body.length];
- System.arraycopy(header, 0, data, 0, header.length);
- System.arraycopy(body, 0, data, header.length, body.length);
- } else {
- data = layout.toByteArray(event);
- }
- } else {
- data = StringEncoder.toBytes(event.getMessage().getFormattedMessage(), StandardCharsets.UTF_8);
- }
- manager.send(data);
- } catch (final Exception e) {
- LOGGER.error("Unable to write to Kafka [{}] for appender [{}].", manager.getName(), getName(), e);
- throw new AppenderLoggingException("Unable to write to Kafka in appender: " + e.getMessage(), e);
- }
- }
- }
-
- @Override
- public void start() {
- super.start();
- manager.startup();
- }
-
- @Override
- public void stop() {
- super.stop();
- manager.release();
- }
-
- @Override
- public String toString() {
- return "KafkaAppender{" +
- "name=" + getName() +
- ", state=" + getState() +
- ", topic=" + manager.getTopic() +
- '}';
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.mom.kafka;
+
+import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AppenderLoggingException;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.SerializedLayout;
+import org.apache.logging.log4j.core.util.StringEncoder;
+
+/**
+ * Sends log events to an Apache Kafka topic.
+ */
+@Plugin(name = "Kafka", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public final class KafkaAppender extends AbstractAppender {
+
+ @PluginFactory
+ public static KafkaAppender createAppender(
+ @PluginElement("Layout") final Layout<? extends Serializable> layout,
+ @PluginElement("Filter") final Filter filter,
+ @Required(message = "No name provided for KafkaAppender") @PluginAttribute("name") final String name,
+ @PluginAttribute(value = "ignoreExceptions", defaultBoolean = true) final boolean ignoreExceptions,
+ @Required(message = "No topic provided for KafkaAppender") @PluginAttribute("topic") final String topic,
+ @PluginElement("Properties") final Property[] properties) {
+ final KafkaManager kafkaManager = new KafkaManager(name, topic, properties);
+ return new KafkaAppender(name, layout, filter, ignoreExceptions, kafkaManager);
+ }
+
+ private final KafkaManager manager;
+
+ private KafkaAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter, final boolean ignoreExceptions, final KafkaManager manager) {
+ super(name, filter, layout, ignoreExceptions);
+ this.manager = manager;
+ }
+
+ @Override
+ public void append(final LogEvent event) {
+ if (event.getLoggerName().startsWith("org.apache.kafka")) {
+ LOGGER.warn("Recursive logging from [{}] for appender [{}].", event.getLoggerName(), getName());
+ } else {
+ try {
+ final Layout<? extends Serializable> layout = getLayout();
+ byte[] data;
+ if (layout != null) {
+ if (layout instanceof SerializedLayout) {
+ final byte[] header = layout.getHeader();
+ final byte[] body = layout.toByteArray(event);
+ data = new byte[header.length + body.length];
+ System.arraycopy(header, 0, data, 0, header.length);
+ System.arraycopy(body, 0, data, header.length, body.length);
+ } else {
+ data = layout.toByteArray(event);
+ }
+ } else {
+ data = StringEncoder.toBytes(event.getMessage().getFormattedMessage(), StandardCharsets.UTF_8);
+ }
+ manager.send(data);
+ } catch (final Exception e) {
+ LOGGER.error("Unable to write to Kafka [{}] for appender [{}].", manager.getName(), getName(), e);
+ throw new AppenderLoggingException("Unable to write to Kafka in appender: " + e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ manager.startup();
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ manager.release();
+ }
+
+ @Override
+ public String toString() {
+ return "KafkaAppender{" +
+ "name=" + getName() +
+ ", state=" + getState() +
+ ", topic=" + manager.getTopic() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicy.java
index b4d1b1b..863ea9d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CronTriggeringPolicy.java
@@ -58,7 +58,7 @@ public final class CronTriggeringPolicy implements TriggeringPolicy {
public void initialize(final RollingFileManager aManager) {
this.manager = aManager;
if (checkOnStartup) {
- Date nextDate = cronExpression.getNextValidTimeAfter(new Date(this.manager.getFileTime()));
+ final Date nextDate = cronExpression.getNextValidTimeAfter(new Date(this.manager.getFileTime()));
if (nextDate.getTime() < System.currentTimeMillis()) {
manager.rollover();
}
@@ -110,7 +110,7 @@ public final class CronTriggeringPolicy implements TriggeringPolicy {
private static CronExpression getSchedule(final String expression) {
try {
return new CronExpression(expression);
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
LOGGER.error("Invalid cron expression - " + expression, pe);
return null;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
index 6097586..2a83861 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
@@ -132,7 +132,7 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
};
static FileExtensions lookup(final String fileExtension) {
- for (FileExtensions ext : values()) {
+ for (final FileExtensions ext : values()) {
if (ext.isExtensionFor(fileExtension)) {
return ext;
}
@@ -537,7 +537,7 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
final String compressedName = renameTo;
Action compressAction = null;
- for (FileExtensions ext : FileExtensions.values()) { // LOG4J2-1077 support other compression formats
+ for (final FileExtensions ext : FileExtensions.values()) { // LOG4J2-1077 support other compression formats
if (ext.isExtensionFor(renameTo)) {
renameTo = renameTo.substring(0, renameTo.length() - ext.length()); // LOG4J2-1135 omit extension!
compressAction = ext.createCompressAction(renameTo, compressedName, true, compressionLevel);
@@ -552,7 +552,7 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
}
private int suffixLength(final String lowFilename) {
- for (FileExtensions extension : FileExtensions.values()) {
+ for (final FileExtensions extension : FileExtensions.values()) {
if (extension.isExtensionFor(lowFilename)) {
return extension.length();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
index 9c573eb..ade19b3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
@@ -289,7 +289,7 @@ public class RollingFileManager extends FileManager {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(super.toString());
builder.append("[action=");
builder.append(action);
@@ -354,7 +354,7 @@ public class RollingFileManager extends FileManager {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(super.toString());
builder.append("[pattern=");
builder.append(pattern);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java
index 8176470..1d0b75a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java
@@ -131,7 +131,7 @@ public class DeleteAction extends AbstractPathAction {
final List<PathWithAttributes> sortedPaths = getSortedPaths();
trace("Sorted paths:", sortedPaths);
- for (PathWithAttributes element : sortedPaths) {
+ for (final PathWithAttributes element : sortedPaths) {
try {
visitor.visitFile(element.getPath(), element.getAttributes());
} catch (final IOException ioex) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java
index a5103f7..5305c91 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java
@@ -116,22 +116,22 @@ public class Duration implements Serializable, Comparable<Duration> {
*/
public static Duration parse(final CharSequence text) {
Objects.requireNonNull(text, "text");
- Matcher matcher = PATTERN.matcher(text);
+ final Matcher matcher = PATTERN.matcher(text);
if (matcher.matches()) {
// check for letter T but no time sections
if ("T".equals(matcher.group(2)) == false) {
- String dayMatch = matcher.group(1);
- String hourMatch = matcher.group(3);
- String minuteMatch = matcher.group(4);
- String secondMatch = matcher.group(5);
+ final String dayMatch = matcher.group(1);
+ final String hourMatch = matcher.group(3);
+ final String minuteMatch = matcher.group(4);
+ final String secondMatch = matcher.group(5);
if (dayMatch != null || hourMatch != null || minuteMatch != null || secondMatch != null) {
- long daysAsSecs = parseNumber(text, dayMatch, SECONDS_PER_DAY, "days");
- long hoursAsSecs = parseNumber(text, hourMatch, SECONDS_PER_HOUR, "hours");
- long minsAsSecs = parseNumber(text, minuteMatch, SECONDS_PER_MINUTE, "minutes");
- long seconds = parseNumber(text, secondMatch, 1, "seconds");
+ final long daysAsSecs = parseNumber(text, dayMatch, SECONDS_PER_DAY, "days");
+ final long hoursAsSecs = parseNumber(text, hourMatch, SECONDS_PER_HOUR, "hours");
+ final long minsAsSecs = parseNumber(text, minuteMatch, SECONDS_PER_MINUTE, "minutes");
+ final long seconds = parseNumber(text, secondMatch, 1, "seconds");
try {
return create(daysAsSecs, hoursAsSecs, minsAsSecs, seconds);
- } catch (ArithmeticException ex) {
+ } catch (final ArithmeticException ex) {
throw new IllegalArgumentException("Text cannot be parsed to a Duration (overflow) " + text, ex);
}
}
@@ -188,7 +188,7 @@ public class Duration implements Serializable, Comparable<Duration> {
if (!(obj instanceof Duration)) {
return false;
}
- Duration other = (Duration) obj;
+ final Duration other = (Duration) obj;
return other.seconds == this.seconds;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
index 83f7caf..142b7e3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
@@ -115,7 +115,7 @@ public class FileRenameAction extends AbstractAction {
return false;
}
}
- Path sourcePath = source.toPath();
+ final Path sourcePath = source.toPath();
try {
Files.move(sourcePath, destination.toPath());
return true;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java
index 9591804..2b3088c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java
@@ -92,7 +92,7 @@ public final class IfAll implements PathCondition {
* @param nestedConditions the conditions to call {@link #beforeFileTreeWalk()} on
*/
public static void beforeFileTreeWalk(final PathCondition[] nestedConditions) {
- for (PathCondition condition : nestedConditions) {
+ for (final PathCondition condition : nestedConditions) {
condition.beforeFileTreeWalk();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java
index 30529d4..6b71542 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java
@@ -1,86 +1,86 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Arrays;
-import java.util.Objects;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- * Composite {@code PathCondition} that accepts objects that are accepted by <em>any</em> component conditions.
- * Corresponds to logical "OR".
- */
-@Plugin(name = "IfAny", category = "Core", printObject = true)
-public final class IfAny implements PathCondition {
-
- private final PathCondition[] components;
-
- private IfAny(final PathCondition... filters) {
- this.components = Objects.requireNonNull(filters, "filters");
- }
-
- public PathCondition[] getDeleteFilters() {
- return components;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes)
- */
- @Override
- public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
- for (final PathCondition component : components) {
- if (component.accept(baseDir, relativePath, attrs)) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
- */
- @Override
- public void beforeFileTreeWalk() {
- for (PathCondition condition : components) {
- condition.beforeFileTreeWalk();
- }
- }
-
- /**
- * Create a Composite PathCondition: accepts if any of the nested conditions accepts.
- *
- * @param components The component conditions.
- * @return A Composite PathCondition.
- */
- @PluginFactory
- public static IfAny createOrCondition( //
- @PluginElement("PathConditions") final PathCondition... components) {
- return new IfAny(components);
- }
-
- @Override
- public String toString() {
- return "IfAny" + Arrays.toString(components);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+
+/**
+ * Composite {@code PathCondition} that accepts objects that are accepted by <em>any</em> component conditions.
+ * Corresponds to logical "OR".
+ */
+@Plugin(name = "IfAny", category = "Core", printObject = true)
+public final class IfAny implements PathCondition {
+
+ private final PathCondition[] components;
+
+ private IfAny(final PathCondition... filters) {
+ this.components = Objects.requireNonNull(filters, "filters");
+ }
+
+ public PathCondition[] getDeleteFilters() {
+ return components;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes)
+ */
+ @Override
+ public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
+ for (final PathCondition component : components) {
+ if (component.accept(baseDir, relativePath, attrs)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
+ */
+ @Override
+ public void beforeFileTreeWalk() {
+ for (final PathCondition condition : components) {
+ condition.beforeFileTreeWalk();
+ }
+ }
+
+ /**
+ * Create a Composite PathCondition: accepts if any of the nested conditions accepts.
+ *
+ * @param components The component conditions.
+ * @return A Composite PathCondition.
+ */
+ @PluginFactory
+ public static IfAny createOrCondition( //
+ @PluginElement("PathConditions") final PathCondition... components) {
+ return new IfAny(components);
+ }
+
+ @Override
+ public String toString() {
+ return "IfAny" + Arrays.toString(components);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
index e9e7469..f4f6e35 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
@@ -69,8 +69,8 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
*/
@Override
public void purge() {
- long createTime = System.currentTimeMillis() - timeToLive;
- for (Entry<String, Long> entry : appendersUsage.entrySet()) {
+ final long createTime = System.currentTimeMillis() - timeToLive;
+ for (final Entry<String, Long> entry : appendersUsage.entrySet()) {
if (entry.getValue() < createTime) {
LOGGER.debug("Removing appender " + entry.getKey());
appendersUsage.remove(entry.getKey());
@@ -81,7 +81,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
@Override
public void update(final String key, final LogEvent event) {
- long now = System.currentTimeMillis();
+ final long now = System.currentTimeMillis();
appendersUsage.put(key, now);
if (future == null) {
synchronized (this) {
@@ -101,13 +101,13 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
private void scheduleNext() {
long createTime = Long.MAX_VALUE;
- for (Entry<String, Long> entry : appendersUsage.entrySet()) {
+ for (final Entry<String, Long> entry : appendersUsage.entrySet()) {
if (entry.getValue() < createTime) {
createTime = entry.getValue();
}
}
if (createTime < Long.MAX_VALUE) {
- long interval = timeToLive - (System.currentTimeMillis() - createTime);
+ final long interval = timeToLive - (System.currentTimeMillis() - createTime);
future = scheduler.schedule(this, interval, TimeUnit.MILLISECONDS);
}
}
@@ -135,7 +135,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
} else {
try {
units = TimeUnit.valueOf(timeUnit.toUpperCase());
- } catch (Exception ex) {
+ } catch (final Exception ex) {
LOGGER.error("Invalid time unit {}", timeUnit);
units = TimeUnit.MINUTES;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
index 02f2d33..0df19eb 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
@@ -183,7 +183,7 @@ public final class RoutingAppender extends AbstractAppender {
*/
public void deleteAppender(final String key) {
LOGGER.debug("Stopping route with key" + key);
- AppenderControl control = appenders.remove(key);
+ final AppenderControl control = appenders.remove(key);
control.getAppender().stop();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.java
index fa647c6..961c349 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.java
@@ -27,11 +27,11 @@ public class AsyncLoggerConfigDefaultExceptionHandler
@Override
public void handleEventException(final Throwable throwable, final long sequence,
final AsyncLoggerConfigDisruptor.Log4jEventWrapper event) {
- StringBuilder sb = new StringBuilder(512);
+ final StringBuilder sb = new StringBuilder(512);
sb.append("AsyncLogger error handling event seq=").append(sequence).append(", value='");
try {
sb.append(event);
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
sb.append("[ERROR calling ").append(event.getClass()).append(".toString(): ");
sb.append(ignored).append("]");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.java
index 081a097..e224e1e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.java
@@ -25,11 +25,11 @@ public class AsyncLoggerDefaultExceptionHandler implements ExceptionHandler<Ring
@Override
public void handleEventException(final Throwable throwable, final long sequence, final RingBufferLogEvent event) {
- StringBuilder sb = new StringBuilder(512);
+ final StringBuilder sb = new StringBuilder(512);
sb.append("AsyncLogger error handling event seq=").append(sequence).append(", value='");
try {
sb.append(event);
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
sb.append("[ERROR calling ").append(event.getClass()).append(".toString(): ");
sb.append(ignored).append("]");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
index 774a1cc..4fc5ea0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
@@ -133,7 +133,7 @@ final class DisruptorUtil {
* @return the thread ID of the background appender thread
*/
public static long getExecutorThreadId(final ExecutorService executor) {
- Future<Long> result = executor.submit(new Callable<Long>() {
+ final Future<Long> result = executor.submit(new Callable<Long>() {
@Override
public Long call() {
return Thread.currentThread().getId();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index 5d8d4fd..463536c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -58,7 +58,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
@Override
public RingBufferLogEvent newInstance() {
- RingBufferLogEvent result = new RingBufferLogEvent();
+ final RingBufferLogEvent result = new RingBufferLogEvent();
if (Constants.ENABLE_THREADLOCALS) {
result.messageText = new StringBuilder(Constants.INITIAL_REUSABLE_MESSAGE_SIZE);
result.parameters = new Object[10];
@@ -114,7 +114,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
private void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
- ReusableMessage reusable = (ReusableMessage) msg;
+ final ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
if (parameters != null) {
parameters = reusable.swapParameters(parameters);
@@ -271,7 +271,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
if (message != null) {
return message;
}
- Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
+ final Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
return new ParameterizedMessage(messageText.toString(), params);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index 3562ce4..a152ea7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -317,7 +317,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
if (!async.isEmpty()) {
// LOG4J2-511, LOG4J2-392 stop AsyncAppenders first
LOGGER.trace("{} stopping {} AsyncAppenders.", cls, async.size());
- for (Appender appender : async) {
+ for (final Appender appender : async) {
appender.stop();
}
}
@@ -441,13 +441,13 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
LOGGER.error("Unable to locate plugin type for " + child.getName());
continue;
}
- Class<?> clazz = child.getType().getPluginClass();
+ final Class<?> clazz = child.getType().getPluginClass();
if (clazz.isAnnotationPresent(Scheduled.class)) {
configurationScheduler.incrementScheduledItems();
}
preConfigure(child);
}
- } catch (Exception ex) {
+ } catch (final Exception ex) {
LOGGER.error("Error capturing node data for node " + node.getName(), ex);
}
}
@@ -481,7 +481,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
continue;
}
if (child.getName().equalsIgnoreCase("Scripts")) {
- for (AbstractScript script : child.getObject(AbstractScript[].class)) {
+ for (final AbstractScript script : child.getObject(AbstractScript[].class)) {
if (script instanceof ScriptRef) {
LOGGER.error("Script reference to {} not added. Scripts definition cannot contain script references",
script.getName());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
index 6b91bd6..68d4db1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
@@ -108,7 +108,7 @@ public class AppenderControl extends AbstractFilterable {
}
private String appenderErrorHandlerMessage(final String prefix) {
- String result = createErrorMsg(prefix);
+ final String result = createErrorMsg(prefix);
appender.getHandler().error(result);
return result;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
index 806a1f3..357f18b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
@@ -114,7 +114,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat
if (loggerConfig == configuration.getRootLogger()) {
try {
Thread.sleep(SLEEP_MILLIS);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
StatusLogger.getLogger().warn("Sleep before stop configuration was interrupted.");
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index 05c5823..6497253 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -393,11 +393,11 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
final String configLocationStr = this.substitutor.replace(PropertiesUtil.getProperties()
.getStringProperty(CONFIGURATION_FILE_PROPERTY));
if (configLocationStr != null) {
- String[] sources = configLocationStr.split(",");
+ final String[] sources = configLocationStr.split(",");
if (sources.length > 1) {
- List<AbstractConfiguration> configs = new ArrayList<>();
- for (String sourceLocation : sources) {
- Configuration config = getConfiguration(sourceLocation.trim());
+ final List<AbstractConfiguration> configs = new ArrayList<>();
+ for (final String sourceLocation : sources) {
+ final Configuration config = getConfiguration(sourceLocation.trim());
if (config != null && config instanceof AbstractConfiguration) {
configs.add((AbstractConfiguration) config);
} else {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
index 50b8194..3364ca4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java
@@ -115,9 +115,9 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @return a ScheduledFuture representing the next time the command will run.
*/
public CronScheduledFuture<?> scheduleWithCron(final CronExpression cronExpression, final Runnable command) {
- CronRunnable runnable = new CronRunnable(command, cronExpression);
- ScheduledFuture<?> future = schedule(runnable, nextFireInterval(cronExpression), TimeUnit.MILLISECONDS);
- CronScheduledFuture<?> cronScheduledFuture = new CronScheduledFuture<>(future);
+ final CronRunnable runnable = new CronRunnable(command, cronExpression);
+ final ScheduledFuture<?> future = schedule(runnable, nextFireInterval(cronExpression), TimeUnit.MILLISECONDS);
+ final CronScheduledFuture<?> cronScheduledFuture = new CronScheduledFuture<>(future);
runnable.setScheduledFuture(cronScheduledFuture);
return cronScheduledFuture;
}
@@ -171,18 +171,18 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
public void run() {
try {
runnable.run();
- } catch(Throwable ex) {
+ } catch(final Throwable ex) {
LOGGER.error("Error running command", ex);
} finally {
- ScheduledFuture<?> future = schedule(this, nextFireInterval(cronExpression), TimeUnit.MILLISECONDS);
+ final ScheduledFuture<?> future = schedule(this, nextFireInterval(cronExpression), TimeUnit.MILLISECONDS);
scheduledFuture.setScheduledFuture(future);
}
}
}
private long nextFireInterval(final CronExpression cronExpression) {
- Date now = new Date();
- Date fireDate = cronExpression.getNextValidTimeAfter(now);
+ final Date now = new Date();
+ final Date fireDate = cronExpression.getNextValidTimeAfter(now);
return fireDate.getTime() - now.getTime();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
index f1627bb..a3b1580 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
@@ -141,7 +141,7 @@ public class ConfigurationSource {
if (url != null) {
try {
sourceURI = url.toURI();
- } catch (URISyntaxException ex) {
+ } catch (final URISyntaxException ex) {
/* Ignore the exception */
}
}
@@ -151,11 +151,11 @@ public class ConfigurationSource {
if (sourceURI == null && location != null) {
try {
sourceURI = new URI(location);
- } catch (URISyntaxException ex) {
+ } catch (final URISyntaxException ex) {
// Assume the scheme was missing.
try {
sourceURI = new URI("file://" + location);
- } catch (URISyntaxException uriEx) {
+ } catch (final URISyntaxException uriEx) {
/* Ignore the exception */
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
index f152ac3..6de2506 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
@@ -115,11 +115,11 @@ public final class Configurator {
return initialize(name, loader, (URI) null, externalContext);
}
if (configLocation.contains(",")) {
- String[] parts = configLocation.split(",");
+ final String[] parts = configLocation.split(",");
String scheme = null;
- List<URI> uris = new ArrayList<>(parts.length);
- for (String part : parts) {
- URI uri = NetUtils.toURI(scheme != null ? scheme + ":" + part.trim() : part.trim());
+ final List<URI> uris = new ArrayList<>(parts.length);
+ for (final String part : parts) {
+ final URI uri = NetUtils.toURI(scheme != null ? scheme + ":" + part.trim() : part.trim());
if (scheme == null && uri.getScheme() != null) {
scheme = uri.getScheme();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
index 637341b..1e9fc05 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
@@ -1,70 +1,70 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.config;
-
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.PropertiesUtil;
-
-/**
- * Factory for ReliabilityStrategies.
- */
-public final class ReliabilityStrategyFactory {
- private ReliabilityStrategyFactory() {
- }
-
- /**
- * Returns a new {@code ReliabilityStrategy} instance based on the value of system property
- * {@code log4j.ReliabilityStrategy}. If not value was specified this method returns a new
- * {@code AwaitUnconditionallyReliabilityStrategy}.
- * <p>
- * Valid values for this system property are {@code "AwaitUnconditionally"} (use
- * {@code AwaitUnconditionallyReliabilityStrategy}), {@code "Locking"} (use {@code LockingReliabilityStrategy}) and
- * {@code "AwaitCompletion"} (use the default {@code AwaitCompletionReliabilityStrategy}).
- * <p>
- * Users may also use this system property to specify the fully qualified class name of a class that implements the
- * {@code ReliabilityStrategy} and has a constructor that accepts a single {@code LoggerConfig} argument.
- *
- * @param loggerConfig the LoggerConfig the resulting {@code ReliabilityStrategy} is associated with
- * @return a ReliabilityStrategy that helps the specified LoggerConfig to log events reliably during or after a
- * configuration change
- */
- public static ReliabilityStrategy getReliabilityStrategy(final LoggerConfig loggerConfig) {
-
- String strategy = PropertiesUtil.getProperties().getStringProperty("log4j.ReliabilityStrategy",
- "AwaitCompletion");
- if ("AwaitCompletion".equals(strategy)) {
- return new AwaitCompletionReliabilityStrategy(loggerConfig);
- }
- if ("AwaitUnconditionally".equals(strategy)) {
- return new AwaitUnconditionallyReliabilityStrategy(loggerConfig);
- }
- if ("Locking".equals(strategy)) {
- return new LockingReliabilityStrategy(loggerConfig);
- }
- try {
- final Class<? extends ReliabilityStrategy> cls = LoaderUtil.loadClass(strategy).asSubclass(
- ReliabilityStrategy.class);
- return cls.getConstructor(LoggerConfig.class).newInstance(loggerConfig);
- } catch (Exception dynamicFailed) {
- StatusLogger.getLogger().warn(
- "Could not create ReliabilityStrategy for '{}', using default AwaitCompletionReliabilityStrategy: {}", strategy, dynamicFailed);
- return new AwaitCompletionReliabilityStrategy(loggerConfig);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.config;
+
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+import org.apache.logging.log4j.util.PropertiesUtil;
+
+/**
+ * Factory for ReliabilityStrategies.
+ */
+public final class ReliabilityStrategyFactory {
+ private ReliabilityStrategyFactory() {
+ }
+
+ /**
+ * Returns a new {@code ReliabilityStrategy} instance based on the value of system property
+ * {@code log4j.ReliabilityStrategy}. If not value was specified this method returns a new
+ * {@code AwaitUnconditionallyReliabilityStrategy}.
+ * <p>
+ * Valid values for this system property are {@code "AwaitUnconditionally"} (use
+ * {@code AwaitUnconditionallyReliabilityStrategy}), {@code "Locking"} (use {@code LockingReliabilityStrategy}) and
+ * {@code "AwaitCompletion"} (use the default {@code AwaitCompletionReliabilityStrategy}).
+ * <p>
+ * Users may also use this system property to specify the fully qualified class name of a class that implements the
+ * {@code ReliabilityStrategy} and has a constructor that accepts a single {@code LoggerConfig} argument.
+ *
+ * @param loggerConfig the LoggerConfig the resulting {@code ReliabilityStrategy} is associated with
+ * @return a ReliabilityStrategy that helps the specified LoggerConfig to log events reliably during or after a
+ * configuration change
+ */
+ public static ReliabilityStrategy getReliabilityStrategy(final LoggerConfig loggerConfig) {
+
+ final String strategy = PropertiesUtil.getProperties().getStringProperty("log4j.ReliabilityStrategy",
+ "AwaitCompletion");
+ if ("AwaitCompletion".equals(strategy)) {
+ return new AwaitCompletionReliabilityStrategy(loggerConfig);
+ }
+ if ("AwaitUnconditionally".equals(strategy)) {
+ return new AwaitUnconditionallyReliabilityStrategy(loggerConfig);
+ }
+ if ("Locking".equals(strategy)) {
+ return new LockingReliabilityStrategy(loggerConfig);
+ }
+ try {
+ final Class<? extends ReliabilityStrategy> cls = LoaderUtil.loadClass(strategy).asSubclass(
+ ReliabilityStrategy.class);
+ return cls.getConstructor(LoggerConfig.class).newInstance(loggerConfig);
+ } catch (final Exception dynamicFailed) {
+ StatusLogger.getLogger().warn(
+ "Could not create ReliabilityStrategy for '{}', using default AwaitCompletionReliabilityStrategy: {}", strategy, dynamicFailed);
+ return new AwaitCompletionReliabilityStrategy(loggerConfig);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
index f096f84..4dcd293 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
@@ -123,12 +123,12 @@ public class BuiltConfiguration extends AbstractConfiguration {
byte[] buffer = null;
try {
if (configSource != null) {
- InputStream is = configSource.getInputStream();
+ final InputStream is = configSource.getInputStream();
if (is != null) {
buffer = toByteArray(is);
}
}
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
LOGGER.warn("Unable to read configuration source " + configSource.toString());
}
super.createAdvertiser(advertiserString, configSource, buffer, contentType);
@@ -154,7 +154,7 @@ public class BuiltConfiguration extends AbstractConfiguration {
if (intervalSeconds > 0) {
getWatchManager().setIntervalSeconds(intervalSeconds);
if (configFile != null) {
- FileWatcher watcher = new ConfiguratonFileWatcher((Reconfigurable) this, listeners);
+ final FileWatcher watcher = new ConfiguratonFileWatcher((Reconfigurable) this, listeners);
getWatchManager().watchFile(configFile, watcher);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
index b29e60b..f272fc1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
@@ -65,7 +65,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
super(ConfigurationSource.NULL_SOURCE);
rootNode = configurations.get(0).getRootNode();
this.configurations = configurations;
- String mergeStrategyClassName = PropertiesUtil.getProperties().getStringProperty(MERGE_STRATEGY_PROPERTY,
+ final String mergeStrategyClassName = PropertiesUtil.getProperties().getStringProperty(MERGE_STRATEGY_PROPERTY,
DefaultMergeStrategy.class.getName());
try {
mergeStrategy = LoaderUtil.newInstanceOf(mergeStrategyClassName);
@@ -73,7 +73,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
InstantiationException ex) {
mergeStrategy = new DefaultMergeStrategy();
}
- for (AbstractConfiguration config : configurations) {
+ for (final AbstractConfiguration config : configurations) {
mergeStrategy.mergeRootProperties(rootNode, config);
}
final StatusConfiguration statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES)
@@ -100,38 +100,38 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
@Override
public void setup() {
- AbstractConfiguration targetConfiguration = configurations.get(0);
+ final AbstractConfiguration targetConfiguration = configurations.get(0);
staffChildConfiguration(targetConfiguration);
- WatchManager watchManager = getWatchManager();
- WatchManager targetWatchManager = targetConfiguration.getWatchManager();
- FileWatcher fileWatcher = new ConfiguratonFileWatcher(this, listeners);
+ final WatchManager watchManager = getWatchManager();
+ final WatchManager targetWatchManager = targetConfiguration.getWatchManager();
+ final FileWatcher fileWatcher = new ConfiguratonFileWatcher(this, listeners);
if (targetWatchManager.getIntervalSeconds() > 0) {
watchManager.setIntervalSeconds(targetWatchManager.getIntervalSeconds());
- Map<File, FileWatcher> watchers = targetWatchManager.getWatchers();
- for (Map.Entry<File, FileWatcher> entry : watchers.entrySet()) {
+ final Map<File, FileWatcher> watchers = targetWatchManager.getWatchers();
+ for (final Map.Entry<File, FileWatcher> entry : watchers.entrySet()) {
if (entry.getValue() instanceof ConfiguratonFileWatcher) {
watchManager.watchFile(entry.getKey(), fileWatcher);
}
}
}
- for (AbstractConfiguration sourceConfiguration : configurations.subList(1, configurations.size())) {
+ for (final AbstractConfiguration sourceConfiguration : configurations.subList(1, configurations.size())) {
staffChildConfiguration(sourceConfiguration);
- Node sourceRoot = sourceConfiguration.getRootNode();
+ final Node sourceRoot = sourceConfiguration.getRootNode();
mergeStrategy.mergConfigurations(rootNode, sourceRoot, getPluginManager());
if (LOGGER.isEnabled(Level.ALL)) {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
printNodes("", rootNode, sb);
System.out.println(sb.toString());
}
- int monitorInterval = sourceConfiguration.getWatchManager().getIntervalSeconds();
+ final int monitorInterval = sourceConfiguration.getWatchManager().getIntervalSeconds();
if (monitorInterval > 0) {
- int currentInterval = watchManager.getIntervalSeconds();
+ final int currentInterval = watchManager.getIntervalSeconds();
if (currentInterval <= 0 || monitorInterval < currentInterval) {
watchManager.setIntervalSeconds(monitorInterval);
}
- WatchManager sourceWatchManager = sourceConfiguration.getWatchManager();
- Map<File, FileWatcher> watchers = sourceWatchManager.getWatchers();
- for (Map.Entry<File, FileWatcher> entry : watchers.entrySet()) {
+ final WatchManager sourceWatchManager = sourceConfiguration.getWatchManager();
+ final Map<File, FileWatcher> watchers = sourceWatchManager.getWatchers();
+ for (final Map.Entry<File, FileWatcher> entry : watchers.entrySet()) {
if (entry.getValue() instanceof ConfiguratonFileWatcher) {
watchManager.watchFile(entry.getKey(), fileWatcher);
}
@@ -143,11 +143,11 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
@Override
public Configuration reconfigure() {
LOGGER.debug("Reconfiguring composite configuration");
- List<AbstractConfiguration> configs = new ArrayList<>();
- ConfigurationFactory factory = ConfigurationFactory.getInstance();
- for (AbstractConfiguration config : configurations) {
- ConfigurationSource source = config.getConfigurationSource();
- URI sourceURI = source.getURI();
+ final List<AbstractConfiguration> configs = new ArrayList<>();
+ final ConfigurationFactory factory = ConfigurationFactory.getInstance();
+ for (final AbstractConfiguration config : configurations) {
+ final ConfigurationSource source = config.getConfigurationSource();
+ final URI sourceURI = source.getURI();
Configuration currentConfig;
if (sourceURI != null) {
LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored",
@@ -176,7 +176,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
private void printNodes(final String indent, final Node node, final StringBuilder sb) {
sb.append(indent).append(node.getName()).append(" type: ").append(node.getType()).append("\n");
sb.append(indent).append(node.getAttributes().toString()).append("\n");
- for (Node child : node.getChildren()) {
+ for (final Node child : node.getChildren()) {
printNodes(indent + " ", child, sb);
}
}
[5/6] logging-log4j2 git commit: Use final.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java
index e188efa..0eaa9f6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java
@@ -69,13 +69,13 @@ public class DefaultMergeStrategy implements MergeStrategy {
*/
@Override
public void mergeRootProperties(final Node rootNode, final AbstractConfiguration configuration) {
- for (Map.Entry<String, String> attribute : configuration.getRootNode().getAttributes().entrySet()) {
+ for (final Map.Entry<String, String> attribute : configuration.getRootNode().getAttributes().entrySet()) {
boolean isFound = false;
- for (Map.Entry<String, String> targetAttribute : rootNode.getAttributes().entrySet()) {
+ for (final Map.Entry<String, String> targetAttribute : rootNode.getAttributes().entrySet()) {
if (targetAttribute.getKey().equalsIgnoreCase(attribute.getKey())) {
if (attribute.getKey().equalsIgnoreCase(STATUS)) {
- Level targetLevel = Level.getLevel(targetAttribute.getValue().toUpperCase());
- Level sourceLevel = Level.getLevel(attribute.getValue().toUpperCase());
+ final Level targetLevel = Level.getLevel(targetAttribute.getValue().toUpperCase());
+ final Level sourceLevel = Level.getLevel(attribute.getValue().toUpperCase());
if (targetLevel != null && sourceLevel != null) {
if (sourceLevel.isLessSpecificThan(targetLevel)) {
targetAttribute.setValue(attribute.getValue());
@@ -86,8 +86,8 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
} else {
if (attribute.getKey().equalsIgnoreCase("monitorInterval")) {
- int sourceInterval = Integer.parseInt(attribute.getValue());
- int targetInterval = Integer.parseInt(targetAttribute.getValue());
+ final int sourceInterval = Integer.parseInt(attribute.getValue());
+ final int targetInterval = Integer.parseInt(targetAttribute.getValue());
if (targetInterval == 0 || sourceInterval < targetInterval) {
targetAttribute.setValue(attribute.getValue());
}
@@ -113,10 +113,10 @@ public class DefaultMergeStrategy implements MergeStrategy {
*/
@Override
public void mergConfigurations(final Node target, final Node source, final PluginManager pluginManager) {
- for (Node sourceChildNode : source.getChildren()) {
- boolean isFilter = isFilterNode(sourceChildNode);
+ for (final Node sourceChildNode : source.getChildren()) {
+ final boolean isFilter = isFilterNode(sourceChildNode);
boolean isMerged = false;
- for (Node targetChildNode : target.getChildren()) {
+ for (final Node targetChildNode : target.getChildren()) {
if (isFilter) {
if (isFilterNode(targetChildNode)) {
updateFilterNode(target, targetChildNode, sourceChildNode, pluginManager);
@@ -135,8 +135,8 @@ public class DefaultMergeStrategy implements MergeStrategy {
case PROPERTIES:
case SCRIPTS:
case APPENDERS: {
- for (Node node : sourceChildNode.getChildren()) {
- for (Node targetNode : targetChildNode.getChildren()) {
+ for (final Node node : sourceChildNode.getChildren()) {
+ for (final Node targetNode : targetChildNode.getChildren()) {
if (targetNode.getAttributes().get(NAME).equals(node.getAttributes().get(NAME))) {
targetChildNode.getChildren().remove(targetNode);
break;
@@ -148,18 +148,18 @@ public class DefaultMergeStrategy implements MergeStrategy {
break;
}
case LOGGERS: {
- Map<String, Node> targetLoggers = new HashMap<>();
- for (Node node : targetChildNode.getChildren()) {
+ final Map<String, Node> targetLoggers = new HashMap<>();
+ for (final Node node : targetChildNode.getChildren()) {
targetLoggers.put(node.getName(), node);
}
- for (Node node : sourceChildNode.getChildren()) {
- Node targetNode = getLoggerNode(targetChildNode, node.getAttributes().get(NAME));
- Node loggerNode = new Node(targetChildNode, node.getName(), node.getType());
+ for (final Node node : sourceChildNode.getChildren()) {
+ final Node targetNode = getLoggerNode(targetChildNode, node.getAttributes().get(NAME));
+ final Node loggerNode = new Node(targetChildNode, node.getName(), node.getType());
if (targetNode != null) {
- for (Node sourceLoggerChild : node.getChildren()) {
+ for (final Node sourceLoggerChild : node.getChildren()) {
if (isFilterNode(sourceLoggerChild)) {
boolean foundFilter = false;
- for (Node targetChild : targetNode.getChildren()) {
+ for (final Node targetChild : targetNode.getChildren()) {
if (isFilterNode(targetChild)) {
updateFilterNode(loggerNode, targetChild, sourceLoggerChild,
pluginManager);
@@ -168,23 +168,23 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
}
if (!foundFilter) {
- Node childNode = new Node(loggerNode, sourceLoggerChild.getName(),
+ final Node childNode = new Node(loggerNode, sourceLoggerChild.getName(),
sourceLoggerChild.getType());
targetNode.getChildren().add(childNode);
}
} else {
- Node childNode = new Node(loggerNode, sourceLoggerChild.getName(),
+ final Node childNode = new Node(loggerNode, sourceLoggerChild.getName(),
sourceLoggerChild.getType());
childNode.getAttributes().putAll(sourceLoggerChild.getAttributes());
if (childNode.getName().equalsIgnoreCase("AppenderRef")) {
- for (Node targetChild : targetNode.getChildren()) {
+ for (final Node targetChild : targetNode.getChildren()) {
if (isSameReference(targetChild, childNode)) {
targetNode.getChildren().remove(targetChild);
break;
}
}
} else {
- for (Node targetChild : targetNode.getChildren()) {
+ for (final Node targetChild : targetNode.getChildren()) {
if (isSameName(targetChild, childNode)) {
targetNode.getChildren().remove(targetChild);
break;
@@ -223,8 +223,8 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
private Node getLoggerNode(final Node parentNode, final String name) {
- for (Node node : parentNode.getChildren()) {
- String nodeName = node.getAttributes().get(NAME);
+ for (final Node node : parentNode.getChildren()) {
+ final String nodeName = node.getAttributes().get(NAME);
if (name == null && nodeName == null) {
return node;
}
@@ -238,19 +238,19 @@ public class DefaultMergeStrategy implements MergeStrategy {
private void updateFilterNode(final Node target, final Node targetChildNode, final Node sourceChildNode,
final PluginManager pluginManager) {
if (CompositeFilter.class.isAssignableFrom(targetChildNode.getType().getPluginClass())) {
- Node node = new Node(targetChildNode, sourceChildNode.getName(), sourceChildNode.getType());
+ final Node node = new Node(targetChildNode, sourceChildNode.getName(), sourceChildNode.getType());
node.getChildren().addAll(sourceChildNode.getChildren());
node.getAttributes().putAll(sourceChildNode.getAttributes());
targetChildNode.getChildren().add(node);
} else {
- PluginType pluginType = pluginManager.getPluginType(FILTERS);
- Node filtersNode = new Node(targetChildNode, FILTERS, pluginType);
- Node node = new Node(filtersNode, sourceChildNode.getName(), sourceChildNode.getType());
+ final PluginType pluginType = pluginManager.getPluginType(FILTERS);
+ final Node filtersNode = new Node(targetChildNode, FILTERS, pluginType);
+ final Node node = new Node(filtersNode, sourceChildNode.getName(), sourceChildNode.getType());
node.getAttributes().putAll(sourceChildNode.getAttributes());
- List<Node> children = filtersNode.getChildren();
+ final List<Node> children = filtersNode.getChildren();
children.add(targetChildNode);
children.add(node);
- List<Node> nodes = target.getChildren();
+ final List<Node> nodes = target.getChildren();
nodes.remove(targetChildNode);
nodes.add(filtersNode);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
index 0efef68..427fa6d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
@@ -90,7 +90,7 @@ public class JsonConfiguration extends AbstractConfiguration implements Reconfig
if (intervalSeconds > 0) {
getWatchManager().setIntervalSeconds(intervalSeconds);
if (configFile != null) {
- FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners);
+ final FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners);
getWatchManager().watchFile(configFile, watcher);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
index 66f9bba..0f159ff 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationBuilder.java
@@ -78,8 +78,8 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
@Override
public PropertiesConfiguration build() {
- Map<String, String> rootProps = new HashMap<>();
- for (String key : rootProperties.stringPropertyNames()) {
+ final Map<String, String> rootProps = new HashMap<>();
+ for (final String key : rootProperties.stringPropertyNames()) {
if (!key.contains(".")) {
builder.addRootProperty(key, rootProperties.getProperty(key));
}
@@ -120,11 +120,11 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
}
}
- String filterProp = rootProperties.getProperty("filters");
+ final String filterProp = rootProperties.getProperty("filters");
if (filterProp != null) {
- String[] filterNames = filterProp.split(",");
- for (String filterName : filterNames) {
- String name = filterName.trim();
+ final String[] filterNames = filterProp.split(",");
+ for (final String filterName : filterNames) {
+ final String name = filterName.trim();
builder.add(createFilter(name, PropertiesUtil.extractSubset(rootProperties, "filter." + name)));
}
} else {
@@ -136,11 +136,11 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
}
}
- String appenderProp = rootProperties.getProperty("appenders");
+ final String appenderProp = rootProperties.getProperty("appenders");
if (appenderProp != null) {
- String[] appenderNames = appenderProp.split(",");
- for (String appenderName : appenderNames) {
- String name = appenderName.trim();
+ final String[] appenderNames = appenderProp.split(",");
+ for (final String appenderName : appenderNames) {
+ final String name = appenderName.trim();
builder.add(createAppender(appenderName.trim(),
PropertiesUtil.extractSubset(rootProperties, "appender." + name)));
}
@@ -152,11 +152,11 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
}
}
- String loggerProp = rootProperties.getProperty("loggers");
+ final String loggerProp = rootProperties.getProperty("loggers");
if (loggerProp != null) {
- String[] loggerNames = loggerProp.split(",");
- for (String loggerName : loggerNames) {
- String name = loggerName.trim();
+ final String[] loggerNames = loggerProp.split(",");
+ for (final String loggerName : loggerNames) {
+ final String name = loggerName.trim();
if (!name.equals(LoggerConfig.ROOT)) {
builder.add(createLogger(name, PropertiesUtil.extractSubset(rootProperties, "logger." +
name)));
@@ -332,7 +332,7 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
final Properties properties) {
while (properties.size() > 0) {
final String propertyName = properties.stringPropertyNames().iterator().next();
- int index = propertyName.indexOf('.');
+ final int index = propertyName.indexOf('.');
if (index > 0) {
final String prefix = propertyName.substring(0, index);
final Properties componentProperties = PropertiesUtil.extractSubset(properties, prefix);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
index 63cb323..8eda63a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
@@ -46,7 +46,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
final Properties properties = new Properties();
try {
properties.load(configStream);
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new ConfigurationException("Unable to load " + source.toString(), ioe);
}
return new PropertiesConfigurationBuilder().setConfigurationSource(source)
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
index ea1c12b..ea3f753 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
@@ -95,7 +95,7 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
document = documentBuilder.parse(source);
} catch (final Exception e) {
// LOG4J2-1127
- Throwable throwable = Throwables.getRootCause(e);
+ final Throwable throwable = Throwables.getRootCause(e);
if (throwable instanceof UnsupportedOperationException) {
LOGGER.warn(
"The DocumentBuilder {} does not support an operation: {}."
@@ -134,7 +134,7 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
if (intervalSeconds > 0) {
getWatchManager().setIntervalSeconds(intervalSeconds);
if (configFile != null) {
- FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners);
+ final FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners);
getWatchManager().watchFile(configFile, watcher);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
index 8c78d1d..f5b18f5 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
@@ -153,7 +153,7 @@ public final class BurstFilter extends AbstractFilter {
* Clear the history. Used for unit testing.
*/
public void clear() {
- for (LogDelay delay : history) {
+ for (final LogDelay delay : history) {
history.remove(delay);
available.add(delay);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
index 3933fa0..2b0a400 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
@@ -57,10 +57,10 @@ public final class CompositeFilter extends AbstractLifeCycle implements Iterable
return this;
}
if (filter instanceof CompositeFilter) {
- int size = this.filters.length + ((CompositeFilter) filter).size();
+ final int size = this.filters.length + ((CompositeFilter) filter).size();
final Filter[] copy = Arrays.copyOf(this.filters, size);
- int index = this.filters.length;
- for (Filter currentFilter : ((CompositeFilter) filter).filters) {
+ final int index = this.filters.length;
+ for (final Filter currentFilter : ((CompositeFilter) filter).filters) {
copy[index] = currentFilter;
}
return new CompositeFilter(copy);
@@ -81,7 +81,7 @@ public final class CompositeFilter extends AbstractLifeCycle implements Iterable
// which is OK since removing a filter should not be on the critical path.
final List<Filter> filterList = new ArrayList<>(Arrays.asList(this.filters));
if (filter instanceof CompositeFilter) {
- for (Filter currentFilter : ((CompositeFilter) filter).filters) {
+ for (final Filter currentFilter : ((CompositeFilter) filter).filters) {
filterList.remove(currentFilter);
}
} else {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java
index 7607f26..12fb1ac 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java
@@ -61,7 +61,7 @@ public final class ScriptFilter extends AbstractFilter {
@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
final Object... params) {
- SimpleBindings bindings = new SimpleBindings();
+ final SimpleBindings bindings = new SimpleBindings();
bindings.put("logger", logger);
bindings.put("level", level);
bindings.put("marker", marker);
@@ -70,14 +70,14 @@ public final class ScriptFilter extends AbstractFilter {
bindings.put("throwable", null);
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
- Object object = configuration.getScriptManager().execute(script.getName(), bindings);
+ final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}
@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Object msg,
final Throwable t) {
- SimpleBindings bindings = new SimpleBindings();
+ final SimpleBindings bindings = new SimpleBindings();
bindings.put("logger", logger);
bindings.put("level", level);
bindings.put("marker", marker);
@@ -86,14 +86,14 @@ public final class ScriptFilter extends AbstractFilter {
bindings.put("throwable", t);
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
- Object object = configuration.getScriptManager().execute(script.getName(), bindings);
+ final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}
@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg,
final Throwable t) {
- SimpleBindings bindings = new SimpleBindings();
+ final SimpleBindings bindings = new SimpleBindings();
bindings.put("logger", logger);
bindings.put("level", level);
bindings.put("marker", marker);
@@ -102,17 +102,17 @@ public final class ScriptFilter extends AbstractFilter {
bindings.put("throwable", t);
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
- Object object = configuration.getScriptManager().execute(script.getName(), bindings);
+ final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}
@Override
public Result filter(final LogEvent event) {
- SimpleBindings bindings = new SimpleBindings();
+ final SimpleBindings bindings = new SimpleBindings();
bindings.put("logEvent", event);
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
- Object object = configuration.getScriptManager().execute(script.getName(), bindings);
+ final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
index 41d22d6..123cb6c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
@@ -127,7 +127,7 @@ public final class TimeFilter extends AbstractFilter {
stf.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
return stf.parse(timestamp).getTime();
- } catch (ParseException e) {
+ } catch (final ParseException e) {
LOGGER.warn("Error parsing TimeFilter timestamp value {}", timestamp, e);
return defaultValue;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
index b504838..12b1204 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
@@ -258,9 +258,9 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
if (ctx.getState() == LifeCycle.State.INITIALIZED) {
if ((configLocations != null && !configLocations.isEmpty())) {
ContextAnchor.THREAD_CONTEXT.set(ctx);
- List<AbstractConfiguration> configurations = new ArrayList<>(configLocations.size());
- for (URI configLocation : configLocations) {
- Configuration currentReadConfiguration = ConfigurationFactory.getInstance()
+ final List<AbstractConfiguration> configurations = new ArrayList<>(configLocations.size());
+ for (final URI configLocation : configLocations) {
+ final Configuration currentReadConfiguration = ConfigurationFactory.getInstance()
.getConfiguration(name, configLocation);
if (currentReadConfiguration instanceof AbstractConfiguration) {
configurations.add((AbstractConfiguration) currentReadConfiguration);
@@ -270,7 +270,7 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
configLocation);
}
}
- CompositeConfiguration compositeConfiguration = new CompositeConfiguration(configurations);
+ final CompositeConfiguration compositeConfiguration = new CompositeConfiguration(configurations);
LOGGER.debug("Starting LoggerContext[name={}] from configurations at {}", ctx.getName(),
configLocations);
ctx.start(compositeConfiguration);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
index d7588a6..7efc8dd 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
@@ -120,7 +120,7 @@ public class Log4jLogEvent implements LogEvent {
// Avoid unnecessarily initializing thrownProxy, threadName and source if possible
if (other instanceof Log4jLogEvent) {
- Log4jLogEvent evt = (Log4jLogEvent) other;
+ final Log4jLogEvent evt = (Log4jLogEvent) other;
this.thrownProxy = evt.thrownProxy;
this.source = evt.source;
this.threadId = evt.threadId;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
index b89dc04..fc44acc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
@@ -191,7 +191,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
public void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
- ReusableMessage reusable = (ReusableMessage) msg;
+ final ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
if (parameters != null) {
parameters = reusable.swapParameters(parameters);
@@ -282,7 +282,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
if (message != null) {
return message;
}
- Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
+ final Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
return new ParameterizedMessage(messageText.toString(), params);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
index b679fcd..13a14f9 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
@@ -143,7 +143,7 @@ public final class GelfLayout extends AbstractStringLayout {
@Override
public byte[] toByteArray(final LogEvent event) {
- StringBuilder text = toText(event, getStringBuilder(), false);
+ final StringBuilder text = toText(event, getStringBuilder(), false);
final byte[] bytes = getBytes(text.toString());
return compressionType != CompressionType.OFF && bytes.length > compressionThreshold ? compress(bytes) : bytes;
}
@@ -226,11 +226,11 @@ public final class GelfLayout extends AbstractStringLayout {
}
builder.append("\"short_message\":\"");
- Message message = event.getMessage();
+ final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
- StringBuilder messageBuffer = getMessageStringBuilder();
+ final StringBuilder messageBuffer = getMessageStringBuilder();
((StringBuilderFormattable)message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} else {
@@ -264,7 +264,7 @@ public final class GelfLayout extends AbstractStringLayout {
if (timeMillis < 1000) {
return "0";
}
- StringBuilder builder = getTimestampStringBuilder();
+ final StringBuilder builder = getTimestampStringBuilder();
builder.append(timeMillis);
builder.insert(builder.length() - 3, '.');
return builder;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/MarkerPatternSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
index 1a98313..5295899 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
@@ -55,31 +55,31 @@ public class MarkerPatternSelector implements PatternSelector {
final boolean alwaysWriteExceptions, final boolean noConsoleNoAnsi,
final Configuration config) {
final PatternParser parser = PatternLayout.createPatternParser(config);
- for (PatternMatch property : properties) {
+ for (final PatternMatch property : properties) {
try {
- List<PatternFormatter> list = parser.parse(property.getPattern(), alwaysWriteExceptions, noConsoleNoAnsi);
+ final List<PatternFormatter> list = parser.parse(property.getPattern(), alwaysWriteExceptions, noConsoleNoAnsi);
formatterMap.put(property.getKey(), list.toArray(new PatternFormatter[list.size()]));
patternMap.put(property.getKey(), property.getPattern());
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw new IllegalArgumentException("Cannot parse pattern '" + property.getPattern() + "'", ex);
}
}
try {
- List<PatternFormatter> list = parser.parse(defaultPattern, alwaysWriteExceptions, noConsoleNoAnsi);
+ final List<PatternFormatter> list = parser.parse(defaultPattern, alwaysWriteExceptions, noConsoleNoAnsi);
defaultFormatters = list.toArray(new PatternFormatter[list.size()]);
this.defaultPattern = defaultPattern;
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw new IllegalArgumentException("Cannot parse pattern '" + defaultPattern + "'", ex);
}
}
@Override
public PatternFormatter[] getFormatters(final LogEvent event) {
- Marker marker = event.getMarker();
+ final Marker marker = event.getMarker();
if (marker == null) {
return defaultFormatters;
}
- for (String key : formatterMap.keySet()) {
+ for (final String key : formatterMap.keySet()) {
if (marker.isInstanceOf(key)) {
return formatterMap.get(key);
}
@@ -106,9 +106,9 @@ public class MarkerPatternSelector implements PatternSelector {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
boolean first = true;
- for (Map.Entry<String, String> entry : patternMap.entrySet()) {
+ for (final Map.Entry<String, String> entry : patternMap.entrySet()) {
if (!first) {
sb.append(", ");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
index 67466be..1e854dd 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
@@ -298,7 +298,7 @@ public final class PatternLayout extends AbstractStringLayout {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(super.toString());
builder.append("[formatters=");
builder.append(Arrays.toString(formatters));
@@ -343,7 +343,7 @@ public final class PatternLayout extends AbstractStringLayout {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(super.toString());
builder.append("[patternSelector=");
builder.append(patternSelector);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ScriptPatternSelector.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ScriptPatternSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ScriptPatternSelector.java
index 01ade28..b74f3b1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ScriptPatternSelector.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/ScriptPatternSelector.java
@@ -64,35 +64,35 @@ public class ScriptPatternSelector implements PatternSelector {
config.getScriptManager().addScript(script);
}
final PatternParser parser = PatternLayout.createPatternParser(config);
- for (PatternMatch property : properties) {
+ for (final PatternMatch property : properties) {
try {
- List<PatternFormatter> list = parser.parse(property.getPattern(), alwaysWriteExceptions, noConsoleNoAnsi);
+ final List<PatternFormatter> list = parser.parse(property.getPattern(), alwaysWriteExceptions, noConsoleNoAnsi);
formatterMap.put(property.getKey(), list.toArray(new PatternFormatter[list.size()]));
patternMap.put(property.getKey(), property.getPattern());
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw new IllegalArgumentException("Cannot parse pattern '" + property.getPattern() + "'", ex);
}
}
try {
- List<PatternFormatter> list = parser.parse(defaultPattern, alwaysWriteExceptions, noConsoleNoAnsi);
+ final List<PatternFormatter> list = parser.parse(defaultPattern, alwaysWriteExceptions, noConsoleNoAnsi);
defaultFormatters = list.toArray(new PatternFormatter[list.size()]);
this.defaultPattern = defaultPattern;
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
throw new IllegalArgumentException("Cannot parse pattern '" + defaultPattern + "'", ex);
}
}
@Override
public PatternFormatter[] getFormatters(final LogEvent event) {
- SimpleBindings bindings = new SimpleBindings();
+ final SimpleBindings bindings = new SimpleBindings();
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
bindings.put("logEvent", event);
- Object object = configuration.getScriptManager().execute(script.getName(), bindings);
+ final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
if (object == null) {
return defaultFormatters;
}
- PatternFormatter[] patternFormatter = formatterMap.get(object.toString());
+ final PatternFormatter[] patternFormatter = formatterMap.get(object.toString());
return patternFormatter == null ? defaultFormatters : patternFormatter;
}
@@ -126,9 +126,9 @@ public class ScriptPatternSelector implements PatternSelector {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
boolean first = true;
- for (Map.Entry<String, String> entry : patternMap.entrySet()) {
+ for (final Map.Entry<String, String> entry : patternMap.entrySet()) {
if (!first) {
sb.append(", ");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/TextEncoderHelper.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/TextEncoderHelper.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/TextEncoderHelper.java
index 8778acb..0b9bf92 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/TextEncoderHelper.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/TextEncoderHelper.java
@@ -80,7 +80,7 @@ public class TextEncoderHelper {
boolean endOfInput = true;
do {
charBuf.clear(); // reset character buffer position to zero, limit to capacity
- int copied = copy(text, start, charBuf);
+ final int copied = copy(text, start, charBuf);
start += copied;
todoChars -= copied;
endOfInput = todoChars <= 0;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
index 2a74a46..6eafaae 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
@@ -58,7 +58,7 @@ public final class ExtendedThrowablePatternConverter extends ThrowablePatternCon
*/
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
- ThrowableProxy proxy = event.getThrownProxy();
+ final ThrowableProxy proxy = event.getThrownProxy();
final Throwable throwable = event.getThrown();
if ((throwable != null || proxy != null) && options.anyLines()) {
if (proxy == null) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
index 4565e21..1315663 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
@@ -61,7 +61,7 @@ public final class MessagePatternConverter extends LogEventPatternConverter {
public void format(final LogEvent event, final StringBuilder toAppendTo) {
final Message msg = event.getMessage();
if (msg instanceof StringBuilderFormattable) {
- int offset = toAppendTo.length();
+ final int offset = toAppendTo.length();
((StringBuilderFormattable) msg).formatTo(toAppendTo);
// TODO can we optimize this?
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
index 317842d..ce7ff64 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
@@ -58,7 +58,7 @@ public final class RootThrowablePatternConverter extends ThrowablePatternConvert
*/
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
- ThrowableProxy proxy = event.getThrownProxy();
+ final ThrowableProxy proxy = event.getThrownProxy();
final Throwable throwable = event.getThrown();
if (throwable != null && options.anyLines()) {
if (proxy == null) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverter.java
index 9a58f79..8824f9e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverter.java
@@ -76,7 +76,7 @@ public final class VariablesNotEmptyReplacementConverter extends LogEventPattern
int emptyVars = 0;
int vars = 0;
for (final PatternFormatter formatter : formatters) {
- int start = buf.length();
+ final int start = buf.length();
formatter.format(event, buf);
final boolean isVariable = formatter.getConverter().isVariable();
vars += isVariable ? 1 : 0;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptFile.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptFile.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptFile.java
index 31f11d9..84f8a8f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptFile.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptFile.java
@@ -81,9 +81,9 @@ public class ScriptFile extends AbstractScript {
final URI uri = NetUtils.toURI(filePathOrUri);
final File file = FileUtils.fileFromUri(uri);
if (language == null && file != null) {
- String fileExtension = FileUtils.getFileExtension(file);
+ final String fileExtension = FileUtils.getFileExtension(file);
if (fileExtension != null) {
- ExtensionLanguageMapping mapping = ExtensionLanguageMapping.getByExtension(fileExtension);
+ final ExtensionLanguageMapping mapping = ExtensionLanguageMapping.getByExtension(fileExtension);
if (mapping != null) {
language = mapping.getLanguage();
}
@@ -99,12 +99,12 @@ public class ScriptFile extends AbstractScript {
try (final Reader reader = new InputStreamReader(
file != null ? new FileInputStream(file) : uri.toURL().openStream(), actualCharset)) {
scriptText = IOUtils.toString(reader);
- } catch (IOException e) {
+ } catch (final IOException e) {
LOGGER.error("{}: language={}, path={}, actualCharset={}", e.getClass().getSimpleName(),
language, filePathOrUri, actualCharset);
return null;
}
- Path path = file != null ? Paths.get(file.toURI()) : Paths.get(uri);
+ final Path path = file != null ? Paths.get(file.toURI()) : Paths.get(uri);
if (path == null) {
LOGGER.error("Unable to convert {} to a Path", uri.toString());
return null;
@@ -114,7 +114,7 @@ public class ScriptFile extends AbstractScript {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
if (!(getName().equals(filePath.toString()))) {
sb.append("name=").append(getName()).append(", ");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptManager.java
index 1cad47c..62b82c2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptManager.java
@@ -108,8 +108,8 @@ public class ScriptManager implements FileWatcher, Serializable {
}
if (script instanceof ScriptFile) {
- ScriptFile scriptFile = (ScriptFile)script;
- Path path = scriptFile.getPath();
+ final ScriptFile scriptFile = (ScriptFile)script;
+ final Path path = scriptFile.getPath();
if (scriptFile.isWatched() && path != null) {
watchManager.watchFile(path.toFile(), this);
}
@@ -117,19 +117,19 @@ public class ScriptManager implements FileWatcher, Serializable {
}
public AbstractScript getScript(final String name) {
- ScriptRunner runner = scripts.get(name);
+ final ScriptRunner runner = scripts.get(name);
return runner != null ? runner.getScript() : null;
}
@Override
public void fileModified(final File file) {
- ScriptRunner runner = scripts.get(file.toString());
+ final ScriptRunner runner = scripts.get(file.toString());
if (runner == null) {
logger.info("{} is not a running script");
return;
}
- ScriptEngine engine = runner.getScriptEngine();
- AbstractScript script = runner.getScript();
+ final ScriptEngine engine = runner.getScriptEngine();
+ final AbstractScript script = runner.getScript();
if (engine.getFactory().getParameter(KEY_THREADING) == null) {
scripts.put(script.getName(), new ThreadLocalScriptRunner(script));
} else {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptRef.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptRef.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptRef.java
index d70da09..974efbd 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptRef.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/ScriptRef.java
@@ -41,14 +41,14 @@ public class ScriptRef extends AbstractScript {
@Override
public String getLanguage() {
- AbstractScript script = this.scriptManager.getScript(getName());
+ final AbstractScript script = this.scriptManager.getScript(getName());
return script != null ? script.getLanguage() : null;
}
@Override
public String getScriptText() {
- AbstractScript script = this.scriptManager.getScript(getName());
+ final AbstractScript script = this.scriptManager.getScript(getName());
return script != null ? script.getScriptText() : null;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
index 2c0bfe4..542f8d9 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CronExpression.java
@@ -282,14 +282,14 @@ public final class CronExpression {
* expression
*/
public boolean isSatisfiedBy(final Date date) {
- Calendar testDateCal = Calendar.getInstance(getTimeZone());
+ final Calendar testDateCal = Calendar.getInstance(getTimeZone());
testDateCal.setTime(date);
testDateCal.set(Calendar.MILLISECOND, 0);
- Date originalDate = testDateCal.getTime();
+ final Date originalDate = testDateCal.getTime();
testDateCal.add(Calendar.SECOND, -1);
- Date timeAfter = getTimeAfter(testDateCal.getTime());
+ final Date timeAfter = getTimeAfter(testDateCal.getTime());
return ((timeAfter != null) && (timeAfter.equals(originalDate)));
}
@@ -318,7 +318,7 @@ public final class CronExpression {
long difference = 1000;
//move back to the nearest second so differences will be accurate
- Calendar adjustCal = Calendar.getInstance(getTimeZone());
+ final Calendar adjustCal = Calendar.getInstance(getTimeZone());
adjustCal.setTime(date);
adjustCal.set(Calendar.MILLISECOND, 0);
Date lastDate = adjustCal.getTime();
@@ -388,7 +388,7 @@ public final class CronExpression {
try {
new CronExpression(cronExpression);
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
return false;
}
@@ -436,11 +436,11 @@ public final class CronExpression {
int exprOn = SECOND;
- StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
+ final StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
false);
while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
- String expr = exprsTok.nextToken().trim();
+ final String expr = exprsTok.nextToken().trim();
// throw an exception if L is used with other days of the month
if (exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
@@ -454,9 +454,9 @@ public final class CronExpression {
throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1);
}
- StringTokenizer vTok = new StringTokenizer(expr, ",");
+ final StringTokenizer vTok = new StringTokenizer(expr, ",");
while (vTok.hasMoreTokens()) {
- String v = vTok.nextToken();
+ final String v = vTok.nextToken();
storeExpressionVals(0, v, exprOn);
}
@@ -472,12 +472,12 @@ public final class CronExpression {
storeExpressionVals(0, "*", YEAR);
}
- TreeSet<Integer> dow = getSet(DAY_OF_WEEK);
- TreeSet<Integer> dom = getSet(DAY_OF_MONTH);
+ final TreeSet<Integer> dow = getSet(DAY_OF_WEEK);
+ final TreeSet<Integer> dom = getSet(DAY_OF_MONTH);
// Copying the logic from the UnsupportedOperationException below
- boolean dayOfMSpec = !dom.contains(NO_SPEC);
- boolean dayOfWSpec = !dow.contains(NO_SPEC);
+ final boolean dayOfMSpec = !dom.contains(NO_SPEC);
+ final boolean dayOfWSpec = !dow.contains(NO_SPEC);
if (!dayOfMSpec || dayOfWSpec) {
if (!dayOfWSpec || dayOfMSpec) {
@@ -485,9 +485,9 @@ public final class CronExpression {
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0);
}
}
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
throw pe;
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParseException("Illegal cron expression format ("
+ e.toString() + ")", 0);
}
@@ -546,7 +546,7 @@ public final class CronExpression {
if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {
throw new Exception();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParseException(
"A numeric value between 1 and 5 must follow the '#' option",
i);
@@ -582,7 +582,7 @@ public final class CronExpression {
i);
}
if (type == DAY_OF_WEEK && !lastdayOfMonth) {
- int val = daysOfMonth.last();
+ final int val = daysOfMonth.last();
if (val == NO_SPEC_INT) {
throw new ParseException(
"'?' can only be specfied for Day-of-Month -OR- Day-of-Week.",
@@ -646,7 +646,7 @@ public final class CronExpression {
if (type == DAY_OF_MONTH && s.length() > i) {
c = s.charAt(i);
if (c == '-') {
- ValueSet vs = getValue(0, s, i + 1);
+ final ValueSet vs = getValue(0, s, i + 1);
lastdayOffset = vs.value;
if (lastdayOffset > 30) {
throw new ParseException("Offset from last day must be <= 30", i + 1);
@@ -670,7 +670,7 @@ public final class CronExpression {
} else {
c = s.charAt(i);
if (c >= '0' && c <= '9') {
- ValueSet vs = getValue(val, s, i);
+ final ValueSet vs = getValue(val, s, i);
val = vs.value;
i = vs.pos;
}
@@ -706,7 +706,7 @@ public final class CronExpression {
} else {
throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i);
}
- TreeSet<Integer> set = getSet(type);
+ final TreeSet<Integer> set = getSet(type);
set.add(val);
i++;
return i;
@@ -721,7 +721,7 @@ public final class CronExpression {
if (val > 31) {
throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
}
- TreeSet<Integer> set = getSet(type);
+ final TreeSet<Integer> set = getSet(type);
set.add(val);
i++;
return i;
@@ -737,13 +737,13 @@ public final class CronExpression {
if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {
throw new Exception();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParseException(
"A numeric value between 1 and 5 must follow the '#' option",
i);
}
- TreeSet<Integer> set = getSet(type);
+ final TreeSet<Integer> set = getSet(type);
set.add(val);
i++;
return i;
@@ -752,7 +752,7 @@ public final class CronExpression {
if (c == '-') {
i++;
c = s.charAt(i);
- int v = Integer.parseInt(String.valueOf(c));
+ final int v = Integer.parseInt(String.valueOf(c));
end = v;
i++;
if (i >= s.length()) {
@@ -761,14 +761,14 @@ public final class CronExpression {
}
c = s.charAt(i);
if (c >= '0' && c <= '9') {
- ValueSet vs = getValue(v, s, i);
+ final ValueSet vs = getValue(v, s, i);
end = vs.value;
i = vs.pos;
}
if (i < s.length() && ((c = s.charAt(i)) == '/')) {
i++;
c = s.charAt(i);
- int v2 = Integer.parseInt(String.valueOf(c));
+ final int v2 = Integer.parseInt(String.valueOf(c));
i++;
if (i >= s.length()) {
addToSet(val, end, v2, type);
@@ -776,8 +776,8 @@ public final class CronExpression {
}
c = s.charAt(i);
if (c >= '0' && c <= '9') {
- ValueSet vs = getValue(v2, s, i);
- int v3 = vs.value;
+ final ValueSet vs = getValue(v2, s, i);
+ final int v3 = vs.value;
addToSet(val, end, v3, type);
i = vs.pos;
return i;
@@ -794,7 +794,7 @@ public final class CronExpression {
if (c == '/') {
i++;
c = s.charAt(i);
- int v2 = Integer.parseInt(String.valueOf(c));
+ final int v2 = Integer.parseInt(String.valueOf(c));
i++;
if (i >= s.length()) {
addToSet(val, end, v2, type);
@@ -802,8 +802,8 @@ public final class CronExpression {
}
c = s.charAt(i);
if (c >= '0' && c <= '9') {
- ValueSet vs = getValue(v2, s, i);
- int v3 = vs.value;
+ final ValueSet vs = getValue(v2, s, i);
+ final int v3 = vs.value;
addToSet(val, end, v3, type);
i = vs.pos;
return i;
@@ -822,7 +822,7 @@ public final class CronExpression {
}
public String getExpressionSummary() {
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append("seconds: ");
buf.append(getExpressionSetSummary(seconds));
@@ -870,13 +870,13 @@ public final class CronExpression {
return "*";
}
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
- Iterator<Integer> itr = set.iterator();
+ final Iterator<Integer> itr = set.iterator();
boolean first = true;
while (itr.hasNext()) {
- Integer iVal = itr.next();
- String val = iVal.toString();
+ final Integer iVal = itr.next();
+ final String val = iVal.toString();
if (!first) {
buf.append(",");
}
@@ -896,13 +896,13 @@ public final class CronExpression {
return "*";
}
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
- Iterator<Integer> itr = list.iterator();
+ final Iterator<Integer> itr = list.iterator();
boolean first = true;
while (itr.hasNext()) {
- Integer iVal = itr.next();
- String val = iVal.toString();
+ final Integer iVal = itr.next();
+ final String val = iVal.toString();
if (!first) {
buf.append(",");
}
@@ -932,7 +932,7 @@ public final class CronExpression {
protected void addToSet(final int val, final int end, int incr, final int type)
throws ParseException {
- TreeSet<Integer> set = getSet(type);
+ final TreeSet<Integer> set = getSet(type);
if (type == SECOND || type == MINUTE) {
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
@@ -1099,7 +1099,7 @@ public final class CronExpression {
protected ValueSet getValue(final int v, final String s, int i) {
char c = s.charAt(i);
- StringBuilder s1 = new StringBuilder(String.valueOf(v));
+ final StringBuilder s1 = new StringBuilder(String.valueOf(v));
while (c >= '0' && c <= '9') {
s1.append(c);
i++;
@@ -1108,7 +1108,7 @@ public final class CronExpression {
}
c = s.charAt(i);
}
- ValueSet val = new ValueSet();
+ final ValueSet val = new ValueSet();
val.pos = (i < s.length()) ? i : i + 1;
val.value = Integer.parseInt(s1.toString());
@@ -1116,13 +1116,13 @@ public final class CronExpression {
}
protected int getNumericValue(final String s, final int i) {
- int endOfVal = findNextWhiteSpace(i, s);
- String val = s.substring(i, endOfVal);
+ final int endOfVal = findNextWhiteSpace(i, s);
+ final String val = s.substring(i, endOfVal);
return Integer.parseInt(val);
}
protected int getMonthNumber(final String s) {
- Integer integer = monthMap.get(s);
+ final Integer integer = monthMap.get(s);
if (integer == null) {
return -1;
@@ -1132,7 +1132,7 @@ public final class CronExpression {
}
protected int getDayOfWeekNumber(final String s) {
- Integer integer = dayMap.get(s);
+ final Integer integer = dayMap.get(s);
if (integer == null) {
return -1;
@@ -1150,7 +1150,7 @@ public final class CronExpression {
public Date getTimeAfter(Date afterTime) {
// Computation is based on Gregorian year only.
- Calendar cl = new java.util.GregorianCalendar(getTimeZone());
+ final Calendar cl = new java.util.GregorianCalendar(getTimeZone());
// move ahead one second, since we're computing the time *after* the
// given time
@@ -1236,8 +1236,8 @@ public final class CronExpression {
int tmon = mon;
// get day...................................................
- boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
- boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
+ final boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
+ final boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule
st = daysOfMonth.tailSet(day);
if (lastdayOfMonth) {
@@ -1259,7 +1259,7 @@ public final class CronExpression {
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
day -= lastdayOffset;
- java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
+ final java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
tcal.set(Calendar.SECOND, 0);
tcal.set(Calendar.MINUTE, 0);
tcal.set(Calendar.HOUR_OF_DAY, 0);
@@ -1267,8 +1267,8 @@ public final class CronExpression {
tcal.set(Calendar.MONTH, mon - 1);
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
- int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
- int dow = tcal.get(Calendar.DAY_OF_WEEK);
+ final int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+ final int dow = tcal.get(Calendar.DAY_OF_WEEK);
if (dow == Calendar.SATURDAY && day == 1) {
day += 2;
@@ -1285,7 +1285,7 @@ public final class CronExpression {
tcal.set(Calendar.HOUR_OF_DAY, hr);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
- Date nTime = tcal.getTime();
+ final Date nTime = tcal.getTime();
if (nTime.before(afterTime)) {
day = 1;
mon++;
@@ -1295,7 +1295,7 @@ public final class CronExpression {
t = day;
day = daysOfMonth.first();
- java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
+ final java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
tcal.set(Calendar.SECOND, 0);
tcal.set(Calendar.MINUTE, 0);
tcal.set(Calendar.HOUR_OF_DAY, 0);
@@ -1303,8 +1303,8 @@ public final class CronExpression {
tcal.set(Calendar.MONTH, mon - 1);
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
- int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
- int dow = tcal.get(Calendar.DAY_OF_WEEK);
+ final int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+ final int dow = tcal.get(Calendar.DAY_OF_WEEK);
if (dow == Calendar.SATURDAY && day == 1) {
day += 2;
@@ -1322,7 +1322,7 @@ public final class CronExpression {
tcal.set(Calendar.HOUR_OF_DAY, hr);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
- Date nTime = tcal.getTime();
+ final Date nTime = tcal.getTime();
if (nTime.before(afterTime)) {
day = daysOfMonth.first();
mon++;
@@ -1331,7 +1331,7 @@ public final class CronExpression {
t = day;
day = st.first();
// make sure we don't over-run a short month, such as february
- int lastDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+ final int lastDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
if (day > lastDay) {
day = daysOfMonth.first();
mon++;
@@ -1354,9 +1354,9 @@ public final class CronExpression {
} else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule
if (lastdayOfWeek) { // are we looking for the last XXX day of
// the month?
- int dow = daysOfWeek.first(); // desired
+ final int dow = daysOfWeek.first(); // desired
// d-o-w
- int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+ final int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
int daysToAdd = 0;
if (cDow < dow) {
daysToAdd = dow - cDow;
@@ -1365,7 +1365,7 @@ public final class CronExpression {
daysToAdd = dow + (7 - cDow);
}
- int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+ final int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
if (day + daysToAdd > lDay) { // did we already miss the
// last one?
@@ -1397,9 +1397,9 @@ public final class CronExpression {
} else if (nthdayOfWeek != 0) {
// are we looking for the Nth XXX day in the month?
- int dow = daysOfWeek.first(); // desired
+ final int dow = daysOfWeek.first(); // desired
// d-o-w
- int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+ final int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
int daysToAdd = 0;
if (cDow < dow) {
daysToAdd = dow - cDow;
@@ -1440,7 +1440,7 @@ public final class CronExpression {
continue;
}
} else {
- int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+ final int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
int dow = daysOfWeek.first(); // desired
// d-o-w
st = daysOfWeek.tailSet(cDow);
@@ -1456,7 +1456,7 @@ public final class CronExpression {
daysToAdd = dow + (7 - cDow);
}
- int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+ final int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
if (day + daysToAdd > lDay) { // will we pass the end of
// the month?
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
index 258773f..5a1c839 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
@@ -94,7 +94,7 @@ public final class FileUtils {
}
public static String getFileExtension(final File file) {
- String fileName = file.getName();
+ final String fileName = file.getName();
if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
return fileName.substring(fileName.lastIndexOf(".") + 1);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
index 685d12f..74fe079 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
@@ -57,7 +57,7 @@ public final class JsonUtils {
while (inPtr < inputLen) {
tight_loop:
while (true) {
- char c = input.charAt(inPtr);
+ final char c = input.charAt(inPtr);
if (c < escCodeCount && escCodes[c] != 0) {
break tight_loop;
}
@@ -67,9 +67,9 @@ public final class JsonUtils {
}
}
// something to escape; 2 or 6-char variant?
- char d = input.charAt(inPtr++);
- int escCode = escCodes[d];
- int length = (escCode < 0)
+ final char d = input.charAt(inPtr++);
+ final int escCode = escCodes[d];
+ final int length = (escCode < 0)
? _appendNumeric(d, qbuf)
: _appendNamed(escCode, qbuf);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringEncoder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringEncoder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringEncoder.java
index a9c3548..bd82c28 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringEncoder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringEncoder.java
@@ -45,7 +45,7 @@ public final class StringEncoder {
final Charset actual = charset != null ? charset : Charset.defaultCharset();
try { // LOG4J2-935: String.getBytes(String) gives better performance
return str.getBytes(actual.name());
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
return str.getBytes(actual);
}
}
@@ -74,7 +74,7 @@ public final class StringEncoder {
public static int encodeIsoChars(final CharSequence charArray, int charIndex, final byte[] byteArray, int byteIndex, final int length) {
int i = 0;
for (; i < length; i++) {
- char c = charArray.charAt(charIndex++);
+ final char c = charArray.charAt(charIndex++);
if (c > 255) {
break;
}
@@ -89,11 +89,11 @@ public final class StringEncoder {
int length = Math.min(charLength, byteArray.length);
int charDoneIndex = charOffset + length;
while (charOffset < charDoneIndex) {
- int done = encodeIsoChars(charArray, charOffset, byteArray, byteOffset, length);
+ final int done = encodeIsoChars(charArray, charOffset, byteArray, byteOffset, length);
charOffset += done;
byteOffset += done;
if (done != length) {
- char c = charArray.charAt(charOffset++);
+ final char c = charArray.charAt(charOffset++);
if ((Character.isHighSurrogate(c)) && (charOffset < charDoneIndex)
&& (Character.isLowSurrogate(charArray.charAt(charOffset)))) {
if (charLength > byteArray.length) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java
index 746c2d5..1004f81 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java
@@ -80,8 +80,8 @@ public class WatchManager extends AbstractLifeCycle {
}
public Map<File, FileWatcher> getWatchers() {
- Map<File, FileWatcher> map = new HashMap<>();
- for (Map.Entry<File, FileMonitor> entry : watchers.entrySet()) {
+ final Map<File, FileWatcher> map = new HashMap<>();
+ for (final Map.Entry<File, FileMonitor> entry : watchers.entrySet()) {
map.put(entry.getKey(), entry.getValue().fileWatcher);
}
return map;
@@ -91,10 +91,10 @@ public class WatchManager extends AbstractLifeCycle {
@Override
public void run() {
- for (Map.Entry<File, FileMonitor> entry : watchers.entrySet()) {
- File file = entry.getKey();
- FileMonitor fileMonitor = entry.getValue();
- long lastModfied = file.lastModified();
+ for (final Map.Entry<File, FileMonitor> entry : watchers.entrySet()) {
+ final File file = entry.getKey();
+ final FileMonitor fileMonitor = entry.getValue();
+ final long lastModfied = file.lastModified();
if (fileModified(fileMonitor, lastModfied)) {
logger.info("File {} was modified", file.toString());
fileMonitor.lastModified = lastModfied;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
index e36bba1..25a5127 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormat.java
@@ -266,7 +266,7 @@ public class FixedDateFormat {
// 28 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
public String format(final long time) {
final char[] result = new char[length << 1]; // double size for locales with lengthy DateFormatSymbols
- int written = format(time, result, 0);
+ final int written = format(time, result, 0);
return new String(result, 0, written);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
index af12699..1394b9f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
@@ -48,7 +48,7 @@ public class GcFreeLoggingTestUtil {
assertTrue("Constants.ENABLE_DIRECT_ENCODERS", Constants.ENABLE_DIRECT_ENCODERS);
assertFalse("Constants.IS_WEB_APP", Constants.IS_WEB_APP);
- MyCharSeq myCharSeq = new MyCharSeq();
+ final MyCharSeq myCharSeq = new MyCharSeq();
MarkerManager.getMarker("test"); // initial creation, value is cached
// initialize LoggerContext etc.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/Log4j1222Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/Log4j1222Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/Log4j1222Test.java
index 7e88f77..1e3f5d5 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/Log4j1222Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/Log4j1222Test.java
@@ -55,7 +55,7 @@ public class Log4j1222Test
if (((TestLogger) Holder.LOGGER).getEntries().size() == 0) {
System.out.println("Logger contains no messages");
}
- for (String msg : ((TestLogger) Holder.LOGGER).getEntries()) {
+ for (final String msg : ((TestLogger) Holder.LOGGER).getEntries()) {
System.out.println(msg);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
index 722c5a1..64589ae 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
@@ -92,7 +92,7 @@ public class LogEventTest {
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new ObjectInputStream(bais);
- LogEvent actual = (LogEvent) ois.readObject();
+ final LogEvent actual = (LogEvent) ois.readObject();
assertNotEquals("Different event: nanoTime", copy, actual);
assertNotEquals("Different nanoTime", copy.getNanoTime(), actual.getNanoTime());
assertEquals("deserialized nanoTime is zero", 0, actual.getNanoTime());
@@ -119,7 +119,7 @@ public class LogEventTest {
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new ObjectInputStream(bais);
- LogEvent actual = (LogEvent) ois.readObject();
+ final LogEvent actual = (LogEvent) ois.readObject();
assertEquals("both zero nanoTime", event2, actual);
}
[2/6] logging-log4j2 git commit: Use final.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
index beba5d3..86cce8d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java
@@ -35,7 +35,7 @@ public class AbstractFilterableTest {
@Test
public void testAddSimpleFilter() throws Exception {
- Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
assertSame(filter, filterable.getFilter());
@@ -43,7 +43,7 @@ public class AbstractFilterableTest {
@Test
public void testAddMultipleSimpleFilters() throws Exception {
- Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
assertSame(filter, filterable.getFilter());
@@ -56,7 +56,7 @@ public class AbstractFilterableTest {
@Test
public void testAddMultipleEqualSimpleFilter() throws Exception {
- Filter filter = new EqualFilter("test");
+ final Filter filter = new EqualFilter("test");
filterable.addFilter(filter);
assertSame(filter, filterable.getFilter());
@@ -69,9 +69,9 @@ public class AbstractFilterableTest {
@Test
public void testAddCompositeFilter() throws Exception {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[] {filter1, filter2});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[] {filter1, filter2});
filterable.addFilter(compositeFilter);
assertSame(compositeFilter, filterable.getFilter());
@@ -79,10 +79,10 @@ public class AbstractFilterableTest {
@Test
public void testAddMultipleCompositeFilters() throws Exception {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter3 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2, filter3});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter3 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2, filter3});
filterable.addFilter(compositeFilter);
assertSame(compositeFilter, filterable.getFilter());
@@ -95,10 +95,10 @@ public class AbstractFilterableTest {
@Test
public void testAddSimpleFilterAndCompositeFilter() throws Exception {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
filterable.addFilter(notInCompositeFilterFilter);
assertSame(notInCompositeFilterFilter, filterable.getFilter());
@@ -111,10 +111,10 @@ public class AbstractFilterableTest {
@Test
public void testAddCompositeFilterAndSimpleFilter() throws Exception {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter notInCompositeFilterFilter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
filterable.addFilter(compositeFilter);
assertSame(compositeFilter, filterable.getFilter());
@@ -127,7 +127,7 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleFilterFromSimpleFilter() throws Exception {
- Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
filterable.removeFilter(filter);
@@ -136,8 +136,8 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleEqualFilterFromSimpleFilter() throws Exception {
- Filter filterOriginal = new EqualFilter("test");
- Filter filterCopy = new EqualFilter("test");
+ final Filter filterOriginal = new EqualFilter("test");
+ final Filter filterCopy = new EqualFilter("test");
filterable.addFilter(filterOriginal);
filterable.removeFilter(filterCopy);
@@ -146,8 +146,8 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleEqualFilterFromTwoSimpleFilters() throws Exception {
- Filter filterOriginal = new EqualFilter("test");
- Filter filterCopy = new EqualFilter("test");
+ final Filter filterOriginal = new EqualFilter("test");
+ final Filter filterCopy = new EqualFilter("test");
filterable.addFilter(filterOriginal);
filterable.addFilter(filterOriginal);
@@ -159,8 +159,8 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleEqualFilterFromMultipleSimpleFilters() throws Exception {
- Filter filterOriginal = new EqualFilter("test");
- Filter filterCopy = new EqualFilter("test");
+ final Filter filterOriginal = new EqualFilter("test");
+ final Filter filterCopy = new EqualFilter("test");
filterable.addFilter(filterOriginal);
filterable.addFilter(filterOriginal);
@@ -176,7 +176,7 @@ public class AbstractFilterableTest {
@Test
public void testRemoveNullFromSingleSimpleFilter() throws Exception {
- Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
filterable.addFilter(filter);
filterable.removeFilter(null);
@@ -186,8 +186,8 @@ public class AbstractFilterableTest {
@Test
public void testRemoveNonExistingFilterFromSingleSimpleFilter() throws Exception {
- Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter newFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
+ final Filter filter = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter newFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
filterable.addFilter(filter);
filterable.removeFilter(newFilter);
@@ -196,9 +196,9 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleFilterFromCompositeFilter() {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
filterable.addFilter(compositeFilter);
@@ -211,10 +211,10 @@ public class AbstractFilterableTest {
@Test
public void testRemoveSimpleFilterFromCompositeAndSimpleFilter() {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
- Filter anotherFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter anotherFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
filterable.addFilter(compositeFilter);
@@ -228,9 +228,9 @@ public class AbstractFilterableTest {
@Test
public void testRemoveCompositeFilterFromCompositeFilter() {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
filterable.addFilter(compositeFilter);
filterable.removeFilter(compositeFilter);
@@ -239,10 +239,10 @@ public class AbstractFilterableTest {
@Test
public void testRemoveFiltersFromComposite() {
- Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
- Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
- Filter anotherFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
+ final Filter filter1 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter filter2 = ThresholdFilter.createFilter(Level.ERROR, null, null);
+ final Filter compositeFilter = CompositeFilter.createFilters(new Filter[]{filter1, filter2});
+ final Filter anotherFilter = ThresholdFilter.createFilter(Level.WARN, null, null);
filterable.addFilter(compositeFilter);
filterable.addFilter(anotherFilter);
@@ -266,7 +266,7 @@ public class AbstractFilterableTest {
if (this == o) return true;
if (!(o instanceof EqualFilter)) return false;
- EqualFilter that = (EqualFilter) o;
+ final EqualFilter that = (EqualFilter) o;
if (key != null ? !key.equals(that.key) : that.key != null) return false;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
index a2e949c..53f9cd7 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractScriptFilterTest.java
@@ -37,7 +37,7 @@ public abstract class AbstractScriptFilterTest {
@Test
public void testGroovyFilter() throws Exception {
- Logger logger = LogManager.getLogger("TestGroovyFilter");
+ final Logger logger = LogManager.getLogger("TestGroovyFilter");
logger.traceEntry();
logger.info("This should not be logged");
ThreadContext.put("UserId", "JohnDoe");
@@ -45,7 +45,7 @@ public abstract class AbstractScriptFilterTest {
ThreadContext.clearMap();
final ListAppender app = getContext().getListAppender("List");
try {
- List<String> messages = app.getMessages();
+ final List<String> messages = app.getMessages();
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 2, Actual " + messages.size(), messages.size() == 2);
} finally {
@@ -55,14 +55,14 @@ public abstract class AbstractScriptFilterTest {
@Test
public void testJavascriptFilter() throws Exception {
- Logger logger = LogManager.getLogger("TestJavaScriptFilter");
+ final Logger logger = LogManager.getLogger("TestJavaScriptFilter");
logger.traceEntry();
logger.info("This should not be logged");
ThreadContext.put("UserId", "JohnDoe");
logger.info("This should be logged");
ThreadContext.clearMap();
final ListAppender app = getContext().getListAppender("List");
- List<String> messages = app.getMessages();
+ final List<String> messages = app.getMessages();
try {
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 2, Actual " + messages.size(), messages.size() == 2);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
index b4d37dd..93d60c4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java
@@ -80,7 +80,7 @@ public class Log4jLogEventNanoTimeTest {
final String[] line1Parts = line1.split(" AND ");
assertEquals("Use actual System.nanoTime()", line1Parts[2]);
assertEquals(line1Parts[0], line1Parts[1]);
- long loggedNanoTime = Long.parseLong(line1Parts[0]);
+ final long loggedNanoTime = Long.parseLong(line1Parts[0]);
assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1));
final String[] line2Parts = line2.split(" AND ");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
index f5f2e87..d57a058 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventTest.java
@@ -279,7 +279,7 @@ public class Log4jLogEventTest {
assertSame(exception, event.getThrown());
assertEquals(987654321L, event.getTimeMillis());
- LogEvent event2 = new Log4jLogEvent.Builder(event).build();
+ final LogEvent event2 = new Log4jLogEvent.Builder(event).build();
assertEquals("copy constructor builder", event2, event);
assertEquals("same hashCode", event2.hashCode(), event.hashCode());
}
@@ -327,7 +327,7 @@ public class Log4jLogEventTest {
assertSame(exception, event.getThrown());
assertEquals(987654321L, event.getTimeMillis());
- LogEvent e2 = new Log4jLogEvent.Builder(event).build();
+ final LogEvent e2 = new Log4jLogEvent.Builder(event).build();
assertSame(contextMap, e2.getContextMap());
assertSame(contextStack, e2.getContextStack());
assertEquals(true, e2.isEndOfBatch());
@@ -345,9 +345,9 @@ public class Log4jLogEventTest {
// use reflection to get value of source field in log event copy:
// invoking the getSource() method would initialize the field
- Field fieldSource = Log4jLogEvent.class.getDeclaredField("source");
+ final Field fieldSource = Log4jLogEvent.class.getDeclaredField("source");
fieldSource.setAccessible(true);
- Object value = fieldSource.get(e2);
+ final Object value = fieldSource.get(e2);
assertNull("source in copy", value);
}
@@ -437,7 +437,7 @@ public class Log4jLogEventTest {
try { // TODO null logger name throws NPE in equals. Use Objects.requireNonNull in constructor?
different("null name", builder(event).setLoggerName(null), event);
fail("Expected NullPointerException");
- } catch (NullPointerException ok) {
+ } catch (final NullPointerException ok) {
}
different("different marker", builder(event).setMarker(MarkerManager.getMarker("different")), event);
@@ -447,7 +447,7 @@ public class Log4jLogEventTest {
try { // TODO null message throws NPE in equals(). Use Objects.requireNonNull in constructor?
different("null message", builder(event).setMessage(null), event);
fail("Expected NullPointerException");
- } catch (NullPointerException ok) {
+ } catch (final NullPointerException ok) {
}
different("different nanoTime", builder(event).setNanoTime(135), event);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
index fa3a055..3980a54 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
@@ -45,7 +45,7 @@ public class MutableLogEventTest {
private static final ThreadContext.ContextStack STACK = new MutableThreadContextStack(Arrays.asList("abc", "xyz"));
private static Map<String,String> createContextMap() {
- Map<String,String> result = new HashMap<>();
+ final Map<String,String> result = new HashMap<>();
result.put("a", "1");
result.put("b", "2");
return result;
@@ -54,7 +54,7 @@ public class MutableLogEventTest {
@Test
public void testInitFromCopiesAllFields() {
// private ThrowableProxy thrownProxy;
- Log4jLogEvent source = Log4jLogEvent.newBuilder() //
+ final Log4jLogEvent source = Log4jLogEvent.newBuilder() //
.setContextMap(CONTEXTMAP) //
.setContextStack(STACK) //
.setEndOfBatch(true) //
@@ -70,7 +70,7 @@ public class MutableLogEventTest {
.setThrown(new RuntimeException("run")) //
.setTimeMillis(987654321)
.build();
- MutableLogEvent mutable = new MutableLogEvent();
+ final MutableLogEvent mutable = new MutableLogEvent();
mutable.initFrom(source);
assertEquals("contextMap", CONTEXTMAP, mutable.getContextMap());
assertEquals("stack", STACK, mutable.getContextStack());
@@ -93,7 +93,7 @@ public class MutableLogEventTest {
@Test
public void testClear() {
- MutableLogEvent mutable = new MutableLogEvent();
+ final MutableLogEvent mutable = new MutableLogEvent();
assertNull("context map", mutable.getContextMap());
assertNull("context stack", mutable.getContextStack());
assertFalse("end of batch", mutable.isEndOfBatch());
@@ -175,7 +175,7 @@ public class MutableLogEventTest {
@Test
public void testJavaIoSerializable() throws Exception {
- MutableLogEvent evt = new MutableLogEvent();
+ final MutableLogEvent evt = new MutableLogEvent();
evt.setContextMap(CONTEXTMAP);
evt.setContextStack(STACK);
evt.setEndOfBatch(true);
@@ -218,7 +218,7 @@ public class MutableLogEventTest {
@Test
public void testJavaIoSerializableWithThrown() throws Exception {
final Error thrown = new InternalError("test error");
- MutableLogEvent evt = new MutableLogEvent();
+ final MutableLogEvent evt = new MutableLogEvent();
evt.setContextMap(CONTEXTMAP);
evt.setContextStack(STACK);
evt.setEndOfBatch(true);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
index 2d297f4..78c83ac 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java
@@ -32,20 +32,20 @@ public class ReusableLogEventFactoryTest {
@Test
public void testCreateEventReturnsSameInstance() throws Exception {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
- LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
- LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
+ final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
+ final LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
assertSame(event1, event2);
}
@Test
public void testCreateEventOverwritesFields() throws Exception {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
- LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
+ final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
assertEquals("logger", "a", event1.getLoggerName());
assertEquals("level", Level.DEBUG, event1.getLevel());
assertEquals("msg", new SimpleMessage("abc"), event1.getMessage());
- LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
+ final LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
assertSame(event1, event2);
assertEquals("logger", "b", event1.getLoggerName());
@@ -66,12 +66,12 @@ public class ReusableLogEventFactoryTest {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent[] event1 = new LogEvent[1];
final LogEvent[] event2 = new LogEvent[1];
- Thread t1 = new Thread("THREAD 1") {
+ final Thread t1 = new Thread("THREAD 1") {
public void run() {
event1[0] = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
}
};
- Thread t2 = new Thread("Thread 2") {
+ final Thread t2 = new Thread("Thread 2") {
public void run() {
event2[0] = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
index 0ef2e1d..d90f75b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
@@ -51,19 +51,19 @@ public class CsvParameterLayoutAllAsyncTest {
@Test
public void testLayoutDefaultNormal() throws Exception {
- Logger root = (Logger) LogManager.getRootLogger();
+ final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
}
@Test
public void testLayoutDefaultObjectArrayMessage() throws Exception {
- Logger root = (Logger) LogManager.getRootLogger();
+ final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
}
@Test
public void testLayoutTab() throws Exception {
- Logger root = (Logger) LogManager.getRootLogger();
+ final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
index f1826a2..280cb80 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
@@ -143,19 +143,19 @@ public class CsvParameterLayoutTest {
@Test
public void testLayoutDefaultNormal() throws Exception {
- Logger root = this.init.getRootLogger();
+ final Logger root = this.init.getRootLogger();
testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
}
@Test
public void testLayoutDefaultObjectArrayMessage() throws Exception {
- Logger root = this.init.getRootLogger();
+ final Logger root = this.init.getRootLogger();
testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
}
@Test
public void testLayoutTab() throws Exception {
- Logger root = this.init.getRootLogger();
+ final Logger root = this.init.getRootLogger();
testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
index 7e7c9a9..8bcdd14 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
@@ -176,7 +176,7 @@ public class GelfLayoutTest {
final String uncompressedString = new String(uncompressed, layout.getCharset());
final String uncompressedString2 = new String(uncompressed2, layout.getCharset());
//@formatter:off
- String expected = "{" +
+ final String expected = "{" +
"\"version\": \"1.1\"," +
"\"host\": \"" + HOSTNAME + "\"," +
"\"timestamp\": " + GelfLayout.formatTimestamp(events.get(2).getTimeMillis()) + "," +
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
index 08386ba..a2881df 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
@@ -1,64 +1,64 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.layout;
-
-import java.util.List;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.lookup.MainMapLookup;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Tests LOG4j2-962.
- */
-public class PatternLayoutMainMapLookupTest {
-
- static {
- // Must be set before Log4j writes the header to the appenders.
- MainMapLookup.setMainArguments("value0", "value1", "value2");
- }
-
- @ClassRule
- public static LoggerContextRule context = new LoggerContextRule("log4j2-962.xml");
-
- @Test
- public void testFileName() {
- FileAppender fileApp = (FileAppender) context.getRequiredAppender("File");
- final String name = fileApp.getFileName();
- Assert.assertEquals("target/value0.log", name);
- }
-
- @Test
- public void testHeader() {
- ListAppender listApp = context.getListAppender("List");
- Logger logger = context.getLogger(this.getClass().getName());
- logger.info("Hello World");
- final List<String> messages = listApp.getMessages();
- Assert.assertFalse(messages.isEmpty());
- final String messagesStr = messages.toString();
- Assert.assertEquals(messagesStr, "Header: value0", messages.get(0));
- listApp.stop();
- Assert.assertEquals(messagesStr, "Footer: value1", messages.get(2));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.layout;
+
+import java.util.List;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.appender.FileAppender;
+import org.apache.logging.log4j.core.lookup.MainMapLookup;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/**
+ * Tests LOG4j2-962.
+ */
+public class PatternLayoutMainMapLookupTest {
+
+ static {
+ // Must be set before Log4j writes the header to the appenders.
+ MainMapLookup.setMainArguments("value0", "value1", "value2");
+ }
+
+ @ClassRule
+ public static LoggerContextRule context = new LoggerContextRule("log4j2-962.xml");
+
+ @Test
+ public void testFileName() {
+ final FileAppender fileApp = (FileAppender) context.getRequiredAppender("File");
+ final String name = fileApp.getFileName();
+ Assert.assertEquals("target/value0.log", name);
+ }
+
+ @Test
+ public void testHeader() {
+ final ListAppender listApp = context.getListAppender("List");
+ final Logger logger = context.getLogger(this.getClass().getName());
+ logger.info("Hello World");
+ final List<String> messages = listApp.getMessages();
+ Assert.assertFalse(messages.isEmpty());
+ final String messagesStr = messages.toString();
+ Assert.assertEquals(messagesStr, "Header: value0", messages.get(0));
+ listApp.stop();
+ Assert.assertEquals(messagesStr, "Footer: value1", messages.get(2));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
index 5b51e96..07bde21 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
@@ -227,9 +227,9 @@ public class PatternLayoutTest {
@Test
public void testPatternSelector() throws Exception {
- PatternMatch[] patterns = new PatternMatch[1];
+ final PatternMatch[] patterns = new PatternMatch[1];
patterns[0] = new PatternMatch("FLOW", "%d %-5p [%t]: ====== %C{1}.%M:%L %m ======%n");
- PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration());
+ final PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration());
final PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector)
.withConfiguration(ctx.getConfiguration()).build();
final LogEvent event1 = Log4jLogEvent.newBuilder() //
@@ -499,7 +499,7 @@ public class PatternLayoutTest {
.setLevel(Level.INFO)
.setMessage(new SimpleMessage("Hello, world 1!")).build();
final String result1 = layout.toSerializable(event1);
- String name = this.getClass().getName().substring(this.getClass().getName().indexOf(".") + 1);
+ final String name = this.getClass().getName().substring(this.getClass().getName().indexOf(".") + 1);
assertEquals(name + " Hello, world 1!", new String(result1));
}
{
@@ -553,7 +553,7 @@ public class PatternLayoutTest {
.setSource(new StackTraceElement(this.getClass().getName(), "testCallersFqcnTruncationByDroppingPartsFromFront", this.getClass().getCanonicalName() + ".java", 546))
.build();
final String result1 = layout.toSerializable(event1);
- String name = this.getClass().getName().substring(this.getClass().getName().indexOf(".") + 1);
+ final String name = this.getClass().getName().substring(this.getClass().getName().indexOf(".") + 1);
assertEquals(name + " Hello, world 1!", new String(result1));
}
{
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java
index 82f710f..152c605 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java
@@ -39,9 +39,9 @@ public class PatternSelectorTest {
@Test
public void testPatternSelector() throws Exception {
- PatternMatch[] patterns = new PatternMatch[1];
+ final PatternMatch[] patterns = new PatternMatch[1];
patterns[0] = new PatternMatch("FLOW", "%d %-5p [%t]: ====== %C{1}.%M:%L %m ======%n");
- PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration());
+ final PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration());
final PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector)
.withConfiguration(ctx.getConfiguration()).build();
final LogEvent event1 = Log4jLogEvent.newBuilder() //
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/StringBuilderEncoderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/StringBuilderEncoderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/StringBuilderEncoderTest.java
index 40c9db8..972d30b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/StringBuilderEncoderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/StringBuilderEncoderTest.java
@@ -61,7 +61,7 @@ public class StringBuilderEncoderTest {
assertEquals("char at " + i, (byte) text.charAt(i), destination.drained.get(i));
}
for (int i = destination.buffer.capacity(); i < text.length(); i++) {
- int bufIx = i - destination.buffer.capacity();
+ final int bufIx = i - destination.buffer.capacity();
assertEquals("char at " + i, (byte) text.charAt(i), destination.buffer.get(bufIx));
}
}
@@ -90,7 +90,7 @@ public class StringBuilderEncoderTest {
assertEquals("char at " + i, (byte) text.charAt(i), destination.drained.get(i));
}
for (int i = 3 * destination.buffer.capacity(); i < text.length(); i++) {
- int bufIx = i - 3 * destination.buffer.capacity();
+ final int bufIx = i - 3 * destination.buffer.capacity();
assertEquals("char at " + i, (byte) text.charAt(i), destination.buffer.get(bufIx));
}
}
@@ -260,7 +260,7 @@ public class StringBuilderEncoderTest {
final int DESTINATION_SIZE = 1024 * 1024;
final SpyByteBufferDestination destination = new SpyByteBufferDestination(256 * 1024, DESTINATION_SIZE);
- int max = DESTINATION_SIZE / text.length();
+ final int max = DESTINATION_SIZE / text.length();
for (int i = 0; i < max; i++) {
helper.encode(text, destination);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
index 718aa57..3e7ecad 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
@@ -24,7 +24,9 @@ import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.net.Protocol;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
+@Ignore
public class UdpSerializedSocketServerTest extends AbstractSocketServerTest {
private static UdpSocketServer<ObjectInputStream> server;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
index e830604..80e9bd5 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationTest.java
@@ -46,7 +46,7 @@ public class SslConfigurationTest {
Assert.assertNotNull(clientSocket);
clientSocket.close();
}
- } catch (UnknownHostException offline) {
+ } catch (final UnknownHostException offline) {
// this exception is thrown on Windows when offline
}
}
@@ -65,7 +65,7 @@ public class SslConfigurationTest {
// Expected, do nothing.
}
}
- } catch (UnknownHostException offline) {
+ } catch (final UnknownHostException offline) {
// this exception is thrown on Windows when offline
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverterTest.java
index 642ed16..ec5106f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverterTest.java
@@ -79,7 +79,7 @@ public class EqualsReplacementConverterTest {
@Test
public void testParseSubstitutionWithoutPattern() {
- String substitution = "test";
+ final String substitution = "test";
testParseSubstitution(substitution, substitution);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
index 69e0ec3..92f62d4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
@@ -305,10 +305,10 @@ public class PatternParserTest {
@Test
public void testNanoPatternShortChangesConfigurationNanoClock() {
- Configuration config = new NullConfiguration();
+ final Configuration config = new NullConfiguration();
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
- PatternParser pp = new PatternParser(config, KEY, null);
+ final PatternParser pp = new PatternParser(config, KEY, null);
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
pp.parse("%m");
@@ -320,10 +320,10 @@ public class PatternParserTest {
@Test
public void testNanoPatternLongChangesNanoClockFactoryMode() {
- Configuration config = new NullConfiguration();
+ final Configuration config = new NullConfiguration();
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
- PatternParser pp = new PatternParser(config, KEY, null);
+ final PatternParser pp = new PatternParser(config, KEY, null);
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
pp.parse("%m");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
index d76ef4e..db586b7 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/CronExpressionTest.java
@@ -31,37 +31,37 @@ public class CronExpressionTest {
@Test
public void testDayOfMonth() throws Exception {
- CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 * * ?");
- Date date = new GregorianCalendar(2015, 11, 2).getTime();
- Date fireDate = parser.getNextValidTimeAfter(date);
- Date expected = new GregorianCalendar(2015, 11, 2, 7, 0, 0).getTime();
+ final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 * * ?");
+ final Date date = new GregorianCalendar(2015, 11, 2).getTime();
+ final Date fireDate = parser.getNextValidTimeAfter(date);
+ final Date expected = new GregorianCalendar(2015, 11, 2, 7, 0, 0).getTime();
assertEquals("Dates not equal.", expected, fireDate);
}
@Test
public void testDayOfWeek() throws Exception {
- CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 ? * Fri");
- Date date = new GregorianCalendar(2015, 11, 2).getTime();
- Date fireDate = parser.getNextValidTimeAfter(date);
- Date expected = new GregorianCalendar(2015, 11, 4, 7, 0, 0).getTime();
+ final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 ? * Fri");
+ final Date date = new GregorianCalendar(2015, 11, 2).getTime();
+ final Date fireDate = parser.getNextValidTimeAfter(date);
+ final Date expected = new GregorianCalendar(2015, 11, 4, 7, 0, 0).getTime();
assertEquals("Dates not equal.", expected, fireDate);
}
@Test
public void testNextMonth() throws Exception {
- CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 1 * ?");
- Date date = new GregorianCalendar(2015, 11, 2).getTime();
- Date fireDate = parser.getNextValidTimeAfter(date);
- Date expected = new GregorianCalendar(2016, 0, 1, 7, 0, 0).getTime();
+ final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 1 * ?");
+ final Date date = new GregorianCalendar(2015, 11, 2).getTime();
+ final Date fireDate = parser.getNextValidTimeAfter(date);
+ final Date expected = new GregorianCalendar(2016, 0, 1, 7, 0, 0).getTime();
assertEquals("Dates not equal.", expected, fireDate);
}
@Test
public void testLastDayOfMonth() throws Exception {
- CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 L * ?");
- Date date = new GregorianCalendar(2015, 10, 2).getTime();
- Date fireDate = parser.getNextValidTimeAfter(date);
- Date expected = new GregorianCalendar(2015, 10, 30, 7, 0, 0).getTime();
+ final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 L * ?");
+ final Date date = new GregorianCalendar(2015, 10, 2).getTime();
+ final Date fireDate = parser.getNextValidTimeAfter(date);
+ final Date expected = new GregorianCalendar(2015, 10, 30, 7, 0, 0).getTime();
assertEquals("Dates not equal.", expected, fireDate);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java
index 8b98134..89d4f68 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java
@@ -48,26 +48,26 @@ public class WatchManagerTest {
@Test
public void testWatchManager() throws Exception {
Assume.assumeFalse(IS_WINDOWS);
- ConfigurationScheduler scheduler = new ConfigurationScheduler();
+ final ConfigurationScheduler scheduler = new ConfigurationScheduler();
scheduler.incrementScheduledItems();
- WatchManager watchManager = new WatchManager(scheduler);
+ final WatchManager watchManager = new WatchManager(scheduler);
watchManager.setIntervalSeconds(1);
scheduler.start();
watchManager.start();
try {
- File sourceFile = new File(originalFile);
- FileOutputStream targetStream = new FileOutputStream(testFile);
- File updateFile = new File(newFile);
+ final File sourceFile = new File(originalFile);
+ final FileOutputStream targetStream = new FileOutputStream(testFile);
+ final File updateFile = new File(newFile);
Path source = Paths.get(sourceFile.toURI());
Files.copy(source, targetStream);
- File targetFile = new File(testFile);
- BlockingQueue<File> queue = new LinkedBlockingQueue<>();
+ final File targetFile = new File(testFile);
+ final BlockingQueue<File> queue = new LinkedBlockingQueue<>();
watchManager.watchFile(targetFile, new TestWatcher(queue));
Thread.sleep(1000);
source = Paths.get(updateFile.toURI());
Files.copy(source, Paths.get(targetFile.toURI()), StandardCopyOption.REPLACE_EXISTING);
Thread.sleep(1000);
- File f = queue.poll(1, TimeUnit.SECONDS);
+ final File f = queue.poll(1, TimeUnit.SECONDS);
assertNotNull("File change not detected", f);
} finally {
watchManager.stop();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
index 00615b8..afbccff 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
@@ -51,13 +51,13 @@ public class CleanFiles extends ExternalResource {
if (file.exists()) {
try {
FileSystems.getDefault().provider().delete(file.toPath());
- } catch (IOException e) {
+ } catch (final IOException e) {
fail(e.toString());
}
}
try {
Thread.sleep(200);
- } catch (InterruptedException ignored) {
+ } catch (final InterruptedException ignored) {
}
}
}
@@ -70,7 +70,7 @@ public class CleanFiles extends ExternalResource {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append("CleanFiles [");
builder.append(files);
builder.append("]");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
index 8c15ef2..c2836a2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
@@ -217,7 +217,7 @@ public class LoggerContextRule implements TestRule {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append("LoggerContextRule [configLocation=");
builder.append(configLocation);
builder.append(", contextSelectorClass=");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java
index 6e50c01..3cf523e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java
@@ -26,8 +26,8 @@ import org.junit.Test;
public class MutableLogEventWithReusableParamMsgTest {
@Test
public void testInteractionWithReusableParameterizedMessage() {
- MutableLogEvent evt = new MutableLogEvent();
- ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
+ final MutableLogEvent evt = new MutableLogEvent();
+ final ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
msg.set("Hello {} {} {}", 1, 2, 3);
evt.setMessage(msg);
evt.clear();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/BlockingAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/BlockingAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/BlockingAppender.java
index 1564317..4d3c7d8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/BlockingAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/BlockingAppender.java
@@ -42,7 +42,7 @@ public class BlockingAppender extends AbstractAppender {
while (running) {
try {
Thread.sleep(10L);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
Thread.currentThread().interrupt(); // set interrupt status
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java
index 1174174..74f8a21 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java
@@ -60,18 +60,18 @@ public class EncodingListAppender extends ListAppender {
if (layout == null) {
events.add(event);
} else if (layout instanceof SerializedLayout) {
- Destination content = new Destination();
+ final Destination content = new Destination();
content.byteBuffer.put(layout.getHeader());
layout.encode(event, content);
content.getByteBuffer().flip();
- byte[] record = new byte[content.getByteBuffer().remaining()];
+ final byte[] record = new byte[content.getByteBuffer().remaining()];
content.getByteBuffer().get(record);
data.add(record);
} else {
- Destination content = new Destination();
+ final Destination content = new Destination();
layout.encode(event, content);
content.getByteBuffer().flip();
- byte[] record = new byte[content.getByteBuffer().remaining()];
+ final byte[] record = new byte[content.getByteBuffer().remaining()];
content.getByteBuffer().get(record);
write(record);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAppenderTest.java b/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAppenderTest.java
index 6bfd168..a6704d7 100644
--- a/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAppenderTest.java
+++ b/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAppenderTest.java
@@ -280,7 +280,7 @@ public class FlumeAppenderTest {
avroLogger.info("Test message 2");
avroAppender.stop();
for (int i = 0; i < 3; ++i) {
- Event event = channel.take();
+ final Event event = channel.take();
Assert.assertNotNull("No event for item " + i, event);
Assert.assertTrue("Channel contained event, but not expected message. Received : " + getBody(event),
getBody(event).endsWith("Test message " + i));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java
----------------------------------------------------------------------
diff --git a/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java b/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java
index be9d9f4..142a73a 100644
--- a/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java
+++ b/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java
@@ -155,7 +155,7 @@ public final class MongoDbProvider implements NoSqlProvider<MongoDbConnection> {
return null;
}
} else if (Strings.isNotEmpty(databaseName)) {
- List<MongoCredential> credentials = new ArrayList<>();
+ final List<MongoCredential> credentials = new ArrayList<>();
description = "database=" + databaseName;
if (Strings.isNotEmpty(userName) && Strings.isNotEmpty(password)) {
description += ", username=" + userName + ", passwordHash="
@@ -195,7 +195,7 @@ public final class MongoDbProvider implements NoSqlProvider<MongoDbConnection> {
return null;
}
- WriteConcern writeConcern = toWriteConcern(writeConcernConstant, writeConcernConstantClassName);
+ final WriteConcern writeConcern = toWriteConcern(writeConcernConstant, writeConcernConstantClassName);
return new MongoDbProvider(database, writeConcern, collectionName, description);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java
index 49bc9ea..a2a24e9 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java
@@ -57,10 +57,10 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency3ParamsV3(final ThreadState state) {
state.buffer.setLength(0);
- String STR = "p1={}, p2={}, p3={}";
- int length = STR.length();
+ final String STR = "p1={}, p2={}, p3={}";
+ final int length = STR.length();
STR.getChars(0, length, state.copy, 0);
- int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
ParameterFormatter.formatMessage3(state.buffer, state.copy, length, ARGS, count, state.indices);
return state.buffer.length();
}
@@ -70,10 +70,10 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency5ParamsV3(final ThreadState state) {
state.buffer.setLength(0);
- String STR = "p1={}, p2={}, p3={}, p4={}, p5={}";
- int length = STR.length();
+ final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}";
+ final int length = STR.length();
STR.getChars(0, length, state.copy, 0);
- int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
ParameterFormatter.formatMessage3(state.buffer, state.copy, length, ARGS, count, state.indices);
return state.buffer.length();
}
@@ -83,10 +83,10 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency7ParamsV3(final ThreadState state) {
state.buffer.setLength(0);
- String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}";
- int length = STR.length();
+ final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}";
+ final int length = STR.length();
STR.getChars(0, length, state.copy, 0);
- int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
ParameterFormatter.formatMessage3(state.buffer, state.copy, length, ARGS, count, state.indices);
return state.buffer.length();
}
@@ -96,10 +96,10 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency9ParamsV3(final ThreadState state) {
state.buffer.setLength(0);
- String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}";
- int length = STR.length();
+ final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}";
+ final int length = STR.length();
STR.getChars(0, length, state.copy, 0);
- int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders3(state.copy, length, state.indices);
ParameterFormatter.formatMessage3(state.buffer, state.copy, length, ARGS, count, state.indices);
return state.buffer.length();
}
@@ -109,7 +109,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency3ParamsV2(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}", state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}", state.indices);
ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={}", ARGS, count, state.indices);
return state.buffer.length();
}
@@ -119,7 +119,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency5ParamsV2(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}", state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}", state.indices);
ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}", ARGS, count, state.indices);
return state.buffer.length();
}
@@ -129,7 +129,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency7ParamsV2(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}", state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}", state.indices);
ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}", ARGS, count, state.indices);
return state.buffer.length();
}
@@ -139,7 +139,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency9ParamsV2(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", state.indices);
+ final int count = ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", state.indices);
ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", ARGS, count, state.indices);
return state.buffer.length();
}
@@ -149,7 +149,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency3Params(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}");
+ final int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}");
ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={}", ARGS, count);
return state.buffer.length();
}
@@ -159,7 +159,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency5Params(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}");
+ final int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}");
ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}", ARGS, count);
return state.buffer.length();
}
@@ -169,7 +169,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency7Params(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}");
+ final int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}");
ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}", ARGS, count);
return state.buffer.length();
}
@@ -179,7 +179,7 @@ public class ParameterFormatterBenchmark {
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int latency9Params(final ThreadState state) {
state.buffer.setLength(0);
- int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}");
+ final int count = ParameterFormatter.countArgumentPlaceholders("p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}");
ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", ARGS, count);
return state.buffer.length();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java
index ed6bb68..540c264 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java
@@ -85,7 +85,7 @@ public class AbstractStringLayoutStringEncodingBenchmark {
utf8EncodeLayout = new EncodeLayout(Charset.forName("UTF-8"));
utf16EncodeLayout = new EncodeLayout(Charset.forName("UTF-16"));
- StringBuilder msg = new StringBuilder();
+ final StringBuilder msg = new StringBuilder();
msg.append(MESSAGE);
logEvent = createLogEvent(new SimpleMessage(msg));
@@ -93,7 +93,7 @@ public class AbstractStringLayoutStringEncodingBenchmark {
destination = new Destination();
}
- private static LogEvent createLogEvent(Message message) {
+ private static LogEvent createLogEvent(final Message message) {
final Marker marker = null;
final String fqcn = "com.mycom.myproject.mypackage.MyClass";
final org.apache.logging.log4j.Level level = org.apache.logging.log4j.Level.DEBUG;
@@ -186,13 +186,13 @@ public class AbstractStringLayoutStringEncodingBenchmark {
utf16EncodeLayout.encode(logEvent, destination);
}
- private static long consume(byte[] bytes) {
+ private static long consume(final byte[] bytes) {
long checksum = 0;
- for (byte b : bytes) checksum += b;
+ for (final byte b : bytes) checksum += b;
return checksum;
}
- private static long consume(byte[] bytes, int offset, int length) {
+ private static long consume(final byte[] bytes, final int offset, final int length) {
long checksum = 0;
for (int i = offset; i < length; i++) {
checksum += bytes[i];
@@ -201,43 +201,43 @@ public class AbstractStringLayoutStringEncodingBenchmark {
}
private static class GetBytesLayout extends AbstractStringLayout {
- public GetBytesLayout(Charset charset) {
+ public GetBytesLayout(final Charset charset) {
super(charset);
}
@Override
- public String toSerializable(LogEvent event) {
+ public String toSerializable(final LogEvent event) {
return null;
}
@Override
- public byte[] toByteArray(LogEvent event) {
- StringBuilder sb = getStringBuilder();
+ public byte[] toByteArray(final LogEvent event) {
+ final StringBuilder sb = getStringBuilder();
((StringBuilderFormattable) event.getMessage()).formatTo(sb);
return getBytes(sb.toString());
}
}
private static class EncodeLayout extends AbstractStringLayout {
- public EncodeLayout(Charset charset) {
+ public EncodeLayout(final Charset charset) {
super(charset);
}
@Override
- public String toSerializable(LogEvent event) {
+ public String toSerializable(final LogEvent event) {
return null;
}
@Override
- public byte[] toByteArray(LogEvent event) {
+ public byte[] toByteArray(final LogEvent event) {
return null;
}
@Override
- public void encode(LogEvent event, ByteBufferDestination destination) {
- StringBuilder sb = getStringBuilder();
+ public void encode(final LogEvent event, final ByteBufferDestination destination) {
+ final StringBuilder sb = getStringBuilder();
((StringBuilderFormattable) event.getMessage()).formatTo(sb);
- Encoder<StringBuilder> helper = getStringBuilderEncoder();
+ final Encoder<StringBuilder> helper = getStringBuilderEncoder();
helper.encode(sb, destination);
}
}
@@ -251,7 +251,7 @@ public class AbstractStringLayoutStringEncodingBenchmark {
}
@Override
- public ByteBuffer drain(ByteBuffer buf) {
+ public ByteBuffer drain(final ByteBuffer buf) {
buf.flip();
consume(buf.array(), buf.position(), buf.limit());
buf.clear();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/CollectionsBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/CollectionsBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/CollectionsBenchmark.java
index ea40dac..9caa5f2 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/CollectionsBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/CollectionsBenchmark.java
@@ -65,7 +65,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterMap1Element() {
long total = 0;
- for (Long value : map1.values()) {
+ for (final Long value : map1.values()) {
total += value;
}
return total;
@@ -74,7 +74,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterArraySet1Element() {
long total = 0;
- for (Long value : arraySet1) {
+ for (final Long value : arraySet1) {
total += value;
}
return total;
@@ -83,7 +83,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterArrayList1Element() {
long total = 0;
- for (Long value : arrayList1) {
+ for (final Long value : arrayList1) {
total += value;
}
return total;
@@ -92,7 +92,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterMap3Elements() {
long total = 0;
- for (Long value : map3.values()) {
+ for (final Long value : map3.values()) {
total += value;
}
return total;
@@ -101,7 +101,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterArraySet3Element() {
long total = 0;
- for (Long value : arraySet3) {
+ for (final Long value : arraySet3) {
total += value;
}
return total;
@@ -110,7 +110,7 @@ public class CollectionsBenchmark {
@Benchmark
public long iterArrayList3Element() {
long total = 0;
- for (Long value : arrayList3) {
+ for (final Long value : arrayList3) {
total += value;
}
return total;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
index daccb12..cab0163 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
@@ -84,15 +84,15 @@ public class FileAppenderBenchmark {
}
private void deleteLogFiles() {
- File logbackFile = new File("target/testlogback.log");
+ final File logbackFile = new File("target/testlogback.log");
logbackFile.delete();
- File log4jFile = new File ("target/testlog4j.log");
+ final File log4jFile = new File ("target/testlog4j.log");
log4jFile.delete();
- File log4jRandomFile = new File ("target/testRandomlog4j2.log");
+ final File log4jRandomFile = new File ("target/testRandomlog4j2.log");
log4jRandomFile.delete();
- File log4j2File = new File ("target/testlog4j2.log");
+ final File log4j2File = new File ("target/testlog4j2.log");
log4j2File.delete();
- File julFile = new File("target/testJulLog.log");
+ final File julFile = new File("target/testJulLog.log");
julFile.delete();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
index c0602c3..ebffcc8 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
@@ -83,15 +83,15 @@ public class FileAppenderParamsBenchmark {
}
private void deleteLogFiles() {
- File logbackFile = new File("target/testlogback.log");
+ final File logbackFile = new File("target/testlogback.log");
logbackFile.delete();
- File log4jFile = new File ("target/testlog4j.log");
+ final File log4jFile = new File ("target/testlog4j.log");
log4jFile.delete();
- File log4jRandomFile = new File ("target/testRandomlog4j2.log");
+ final File log4jRandomFile = new File ("target/testRandomlog4j2.log");
log4jRandomFile.delete();
- File log4j2File = new File ("target/testlog4j2.log");
+ final File log4j2File = new File ("target/testlog4j2.log");
log4j2File.delete();
- File julFile = new File("target/testJulLog.log");
+ final File julFile = new File("target/testJulLog.log");
julFile.delete();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4j2AppenderComparisonBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4j2AppenderComparisonBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4j2AppenderComparisonBenchmark.java
index 0527709..bb8cd16 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4j2AppenderComparisonBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4j2AppenderComparisonBenchmark.java
@@ -120,11 +120,11 @@ public class Log4j2AppenderComparisonBenchmark {
}
private void deleteLogFiles() {
- File log4j2File = new File ("target/testlog4j2.log");
+ final File log4j2File = new File ("target/testlog4j2.log");
log4j2File.delete();
- File log4jRandomFile = new File ("target/testRandomlog4j2.log");
+ final File log4jRandomFile = new File ("target/testRandomlog4j2.log");
log4jRandomFile.delete();
- File mmapFile = new File ("target/MemoryMappedFileAppenderTest.log");
+ final File mmapFile = new File ("target/MemoryMappedFileAppenderTest.log");
mmapFile.delete();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
index 0321b04..bf64b19 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
@@ -72,7 +72,7 @@ public class LoggerConfigBenchmark {
}
@Override
- public void append(LogEvent event) {
+ public void append(final LogEvent event) {
count.incrementAndGet();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/MemoryHandlerJULLocationBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/MemoryHandlerJULLocationBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/MemoryHandlerJULLocationBenchmark.java
index bdf1378..b91203f 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/MemoryHandlerJULLocationBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/MemoryHandlerJULLocationBenchmark.java
@@ -67,7 +67,7 @@ public class MemoryHandlerJULLocationBenchmark {
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public void throughputSimple() {
- LogRecord logRecord = new LogRecord(java.util.logging.Level.INFO, BenchmarkMessageParams.TEST);
+ final LogRecord logRecord = new LogRecord(java.util.logging.Level.INFO, BenchmarkMessageParams.TEST);
logRecord.getSourceClassName(); // force location
logger.log(logRecord);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageBenchmark.java
index 463ba92..962a1e3 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ParameterizedMessageBenchmark.java
@@ -68,7 +68,7 @@ public class ParameterizedMessageBenchmark {
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int refactoredFormatTo(ThreadState state) {
+ public int refactoredFormatTo(final ThreadState state) {
state.buffer.setLength(0);
new ParameterizedMessage("pattern {} with {} two parameters and some text", ARGS).
formatTo(state.buffer);
[4/6] logging-log4j2 git commit: Use final.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
index 7a2e01e..ba213ff 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
@@ -191,7 +191,7 @@ public class LoggerTest {
@Test
public void debugChangeLevelsChildLoggers() {
- org.apache.logging.log4j.Logger loggerChild = context.getLogger(logger.getName() + ".child");
+ final org.apache.logging.log4j.Logger loggerChild = context.getLogger(logger.getName() + ".child");
// Use logger AND loggerChild
logger.debug("Debug message 1");
loggerChild.debug("Debug message 1 child");
@@ -213,7 +213,7 @@ public class LoggerTest {
logger.debug("Debug message 1");
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 1);
- Map<String, Level> map = new HashMap<>();
+ final Map<String, Level> map = new HashMap<>();
map.put(logger.getName(), Level.OFF);
Configurator.setLevel(map);
logger.debug("Debug message 2");
@@ -231,7 +231,7 @@ public class LoggerTest {
loggerGrandchild.debug("Debug message 1 GC");
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 3);
- Map<String, Level> map = new HashMap<>();
+ final Map<String, Level> map = new HashMap<>();
map.put(logger.getName(), Level.OFF);
map.put(loggerChild.getName(), Level.DEBUG);
map.put(loggerGrandchild.getName(), Level.WARN);
@@ -413,13 +413,13 @@ public class LoggerTest {
@Test
public void paramWithExceptionTest() throws Exception {
logger.error("Throwing with parameters {}", "TestParam", new NullPointerException("Test Exception"));
- List<LogEvent> events = app.getEvents();
+ final List<LogEvent> events = app.getEvents();
assertNotNull("Log event list not returned", events);
assertTrue("Incorrect number of log events: expected 1, actual " + events.size(), events.size() == 1);
- LogEvent event = events.get(0);
- Throwable thrown = event.getThrown();
+ final LogEvent event = events.get(0);
+ final Throwable thrown = event.getThrown();
assertNotNull("No throwable present in log event", thrown);
- Message msg = event.getMessage();
+ final Message msg = event.getMessage();
assertTrue("Incorrect message type. Expected ParameterizedMessage/ReusableParameterizedMessage, actual " + msg.getClass().getSimpleName(),
msg instanceof ParameterizedMessage || msg instanceof ReusableParameterizedMessage);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java
index 1214e4e..572ce4c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java
@@ -39,13 +39,13 @@ public class PatternSelectorTest {
@Test
public void testMarkerPatternSelector() throws Exception {
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestMarkerPatternSelector");
+ final org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestMarkerPatternSelector");
logger.traceEntry();
logger.info("Hello World");
logger.traceExit();
final ListAppender app = (ListAppender) context.getRequiredAppender("List");
assertNotNull("No ListAppender", app);
- List<String> messages = app.getMessages();
+ final List<String> messages = app.getMessages();
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 3, Actual " + messages.size() + ": " + messages, messages.size() == 3);
final String expect = String.format("[TRACE] TestMarkerPatternSelector ====== "
@@ -57,15 +57,15 @@ public class PatternSelectorTest {
@Test
public void testScriptPatternSelector() throws Exception {
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestScriptPatternSelector");
- org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("NoLocation");
+ final org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestScriptPatternSelector");
+ final org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("NoLocation");
logger.traceEntry();
logger.info("Hello World");
logger2.info("No location information");
logger.traceExit();
final ListAppender app = (ListAppender) context.getRequiredAppender("List2");
assertNotNull("No ListAppender", app);
- List<String> messages = app.getMessages();
+ final List<String> messages = app.getMessages();
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 4, Actual " + messages.size() + ": " + messages, messages.size() == 4);
String expect = "[TRACE] TestScriptPatternSelector ====== " +
@@ -80,15 +80,15 @@ public class PatternSelectorTest {
@Test
public void testJavaScriptPatternSelector() throws Exception {
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestJavaScriptPatternSelector");
- org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("JavascriptNoLocation");
+ final org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestJavaScriptPatternSelector");
+ final org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("JavascriptNoLocation");
logger.traceEntry();
logger.info("Hello World");
logger2.info("No location information");
logger.traceExit();
final ListAppender app = (ListAppender) context.getRequiredAppender("List3");
assertNotNull("No ListAppender", app);
- List<String> messages = app.getMessages();
+ final List<String> messages = app.getMessages();
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 4, Actual " + messages.size() + ": " + messages, messages.size() == 4);
String expect = "[TRACE] TestJavaScriptPatternSelector ====== " +
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/PropertiesFileConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/PropertiesFileConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/PropertiesFileConfigTest.java
index d943c5e..389c095 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/PropertiesFileConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/PropertiesFileConfigTest.java
@@ -57,7 +57,7 @@ public class PropertiesFileConfigTest {
for (int i = 0; i < 17; ++i) {
logger.debug("Reconfigure");
}
- int loopCount = 0;
+ final int loopCount = 0;
Configuration newConfig;
do {
Thread.sleep(100);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
index c64e7a0..b271d70 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
@@ -84,12 +84,12 @@ public class AsyncAppenderQueueFullPolicyTest {
assertEquals("queue remaining capacity", 0, asyncAppender.getQueueRemainingCapacity());
assertEquals("EventRouter invocations", 0, CountingAsyncQueueFullPolicy.queueFull.get());
- Thread release = new Thread("AsyncAppenderReleaser") {
+ final Thread release = new Thread("AsyncAppenderReleaser") {
public void run() {
while (CountingAsyncQueueFullPolicy.queueFull.get() == 0) {
try {
Thread.sleep(10L);
- } catch (InterruptedException ignored) {
+ } catch (final InterruptedException ignored) {
//ignored
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
index 3d456f2..36a652e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
@@ -47,7 +47,7 @@ public class HangingAppender extends AbstractAppender {
public void append(final LogEvent event) {
try {
Thread.sleep(delay);
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
// ignore
}
}
@@ -69,7 +69,7 @@ public class HangingAppender extends AbstractAppender {
public void start() {
try {
Thread.sleep(startupDelay);
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
// ignore
}
super.start();
@@ -80,7 +80,7 @@ public class HangingAppender extends AbstractAppender {
super.stop();
try {
Thread.sleep(shutdownDelay);
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
// ignore
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
index 9564dd9..cbb01d4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
@@ -151,7 +151,7 @@ public class SocketAppenderTest {
public void testUdpAppender() throws Exception {
try {
udpServer.latch.await();
- } catch (InterruptedException ex) {
+ } catch (final InterruptedException ex) {
ex.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
index 2b7fc92..ae772f2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
@@ -112,7 +112,7 @@ public class XmlCompleteFileAppenderTest {
log.info(secondLogMsg);
CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread
- String[] lines = new String[9];
+ final String[] lines = new String[9];
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
index 83f2476..dfa416c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
@@ -49,7 +49,7 @@ public class KafkaAppenderTest {
public void close() {
try {
Thread.sleep(3000);
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
}
}
@@ -57,7 +57,7 @@ public class KafkaAppenderTest {
public void close(final long timeout, final TimeUnit timeUnit) {
try {
Thread.sleep(timeUnit.toMillis(timeout));
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
}
}
};
@@ -121,7 +121,7 @@ public class KafkaAppenderTest {
@Test
public void testAppendWithSerializedLayout() throws Exception {
final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithSerializedLayout");
- LogEvent logEvent = createLogEvent();
+ final LogEvent logEvent = createLogEvent();
appender.append(logEvent);
final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
assertEquals(1, history.size());
@@ -133,7 +133,7 @@ public class KafkaAppenderTest {
}
private LogEvent deserializeLogEvent(final byte[] data) throws IOException, ClassNotFoundException {
- ByteArrayInputStream bis = new ByteArrayInputStream(data);
+ final ByteArrayInputStream bis = new ByteArrayInputStream(data);
try (ObjectInput ois = new ObjectInputStream(bis)) {
return (LogEvent) ois.readObject();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
index dcdb9fd..7ea8854 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronTest.java
@@ -80,8 +80,8 @@ public class RollingAppenderCronTest {
if (!succeeded) {
fail("No compressed files found");
}
- Path src = FileSystems.getDefault().getPath("target/test-classes/log4j-rolling-cron2.xml");
- OutputStream os = new FileOutputStream("target/test-classes/log4j-rolling-cron.xml");
+ final Path src = FileSystems.getDefault().getPath("target/test-classes/log4j-rolling-cron2.xml");
+ final OutputStream os = new FileOutputStream("target/test-classes/log4j-rolling-cron.xml");
Files.copy(src, os);
Thread.sleep(5000);
// force a reconfiguration
@@ -89,11 +89,11 @@ public class RollingAppenderCronTest {
logger.debug("Adding new event {}", i);
}
Thread.sleep(1000);
- RollingFileAppender app = (RollingFileAppender) ctx.getContext().getConfiguration().getAppender("RollingFile");
- TriggeringPolicy policy = app.getManager().getTriggeringPolicy();
+ final RollingFileAppender app = (RollingFileAppender) ctx.getContext().getConfiguration().getAppender("RollingFile");
+ final TriggeringPolicy policy = app.getManager().getTriggeringPolicy();
assertNotNull("No triggering policy", policy);
assertTrue("Incorrect policy type", policy instanceof CronTriggeringPolicy);
- CronExpression expression = ((CronTriggeringPolicy) policy).getCronExpression();
+ final CronExpression expression = ((CronTriggeringPolicy) policy).getCronExpression();
assertTrue("Incorrect triggering policy", expression.getCronExpression().equals("* * * ? * *"));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
index 56bb8c5..cabd93c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCustomDeleteActionTest.java
@@ -64,11 +64,11 @@ public class RollingAppenderCustomDeleteActionTest {
final int MAX_TRIES = 20;
for (int i = 0; i < MAX_TRIES; i++) {
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file);
}
if (files.length == 3) {
- for (File file : files) {
+ for (final File file : files) {
assertTrue("test-4.log should have been deleted",
Arrays.asList("test-1.log", "test-2.log", "test-3.log").contains(file.getName()));
}
@@ -92,10 +92,10 @@ public class RollingAppenderCustomDeleteActionTest {
}
public static void main(final String[] args) {
- Pattern p = Pattern.compile("test-.?[2,4,6,8,0]\\.log\\.gz");
+ final Pattern p = Pattern.compile("test-.?[2,4,6,8,0]\\.log\\.gz");
for (int i = 0; i < 16; i++) {
- String str = "test-" + i + ".log.gz";
- java.util.regex.Matcher m = p.matcher(str);
+ final String str = "test-" + i + ".log.gz";
+ final java.util.regex.Matcher m = p.matcher(str);
System.out.println(m.matches() + ": " + str);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
index 4595b59..b40d022 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount1Test.java
@@ -58,11 +58,11 @@ public class RollingAppenderDeleteAccumulatedCount1Test {
@Test
public void testAppender() throws Exception {
- Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
- Path p2 = writeTextTo(DIR + "/my-2.log");
- Path p3 = writeTextTo(DIR + "/my-3.log");
- Path p4 = writeTextTo(DIR + "/my-4.log");
- Path p5 = writeTextTo(DIR + "/my-5.log");
+ final Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
+ final Path p2 = writeTextTo(DIR + "/my-2.log");
+ final Path p3 = writeTextTo(DIR + "/my-3.log");
+ final Path p4 = writeTextTo(DIR + "/my-4.log");
+ final Path p5 = writeTextTo(DIR + "/my-5.log");
final Logger logger = ctx.getLogger();
for (int i = 0; i < 10; ++i) {
@@ -78,13 +78,13 @@ public class RollingAppenderDeleteAccumulatedCount1Test {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file + " (" + file.length() + "B) "
+ FixedDateFormat.create(FixedFormat.ABSOLUTE).format(file.lastModified()));
}
- List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
+ final List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
assertEquals(Arrays.toString(files), expected.size() + 6, files.length);
- for (File file : files) {
+ for (final File file : files) {
if (!expected.contains(file.getName()) && !file.getName().startsWith("test-")) {
fail("unexpected file" + file);
}
@@ -92,13 +92,13 @@ public class RollingAppenderDeleteAccumulatedCount1Test {
}
private void updateLastModified(final Path... paths) throws IOException {
- for (Path path : paths) {
+ for (final Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
private Path writeTextTo(final String location) throws IOException {
- Path path = Paths.get(location);
+ final Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
buffy.write("some text");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
index 5d3e736..67a2ccf 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedCount2Test.java
@@ -58,11 +58,11 @@ public class RollingAppenderDeleteAccumulatedCount2Test {
@Test
public void testAppender() throws Exception {
- Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
- Path p2 = writeTextTo(DIR + "/my-2.log");
- Path p3 = writeTextTo(DIR + "/my-3.log");
- Path p4 = writeTextTo(DIR + "/my-4.log");
- Path p5 = writeTextTo(DIR + "/my-5.log");
+ final Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
+ final Path p2 = writeTextTo(DIR + "/my-2.log");
+ final Path p3 = writeTextTo(DIR + "/my-3.log");
+ final Path p4 = writeTextTo(DIR + "/my-4.log");
+ final Path p5 = writeTextTo(DIR + "/my-5.log");
final Logger logger = ctx.getLogger();
for (int i = 0; i < 10; ++i) {
@@ -78,14 +78,14 @@ public class RollingAppenderDeleteAccumulatedCount2Test {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file + " (" + file.length() + "B) "
+ FixedDateFormat.create(FixedFormat.ABSOLUTE).format(file.lastModified()));
}
// sometimes "test-9.log", sometimes "test-10.log" remains
- List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
+ final List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
assertEquals(Arrays.toString(files), expected.size() + 1, files.length);
- for (File file : files) {
+ for (final File file : files) {
if (!expected.contains(file.getName()) && !file.getName().startsWith("test-")) {
fail("unexpected file" + file);
}
@@ -93,13 +93,13 @@ public class RollingAppenderDeleteAccumulatedCount2Test {
}
private void updateLastModified(final Path... paths) throws IOException {
- for (Path path : paths) {
+ for (final Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
private Path writeTextTo(final String location) throws IOException {
- Path path = Paths.get(location);
+ final Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
buffy.write("some text");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
index 96b9357..7f3ae76 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteAccumulatedSizeTest.java
@@ -62,13 +62,13 @@ public class RollingAppenderDeleteAccumulatedSizeTest {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file + " (" + file.length() + "B) "
+ FixedDateFormat.create(FixedFormat.ABSOLUTE).format(file.lastModified()));
}
assertEquals(Arrays.toString(files), 4, files.length);
long total = 0;
- for (File file : files) {
+ for (final File file : files) {
// sometimes test-6.log remains
assertTrue("unexpected file " + file, file.getName().startsWith("test-"));
total += file.length();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
index e185d58..a11cff6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteMaxDepthTest.java
@@ -57,10 +57,10 @@ public class RollingAppenderDeleteMaxDepthTest {
@Test
public void testAppender() throws Exception {
// create some files that match the glob but exceed maxDepth
- Path p1 = writeTextTo(DIR + "/1/test-4.log"); // glob="**/test-4.log"
- Path p2 = writeTextTo(DIR + "/2/test-4.log");
- Path p3 = writeTextTo(DIR + "/1/2/test-4.log");
- Path p4 = writeTextTo(DIR + "/1/2/3/test-4.log");
+ final Path p1 = writeTextTo(DIR + "/1/test-4.log"); // glob="**/test-4.log"
+ final Path p2 = writeTextTo(DIR + "/2/test-4.log");
+ final Path p3 = writeTextTo(DIR + "/1/2/test-4.log");
+ final Path p4 = writeTextTo(DIR + "/1/2/3/test-4.log");
final Logger logger = ctx.getLogger();
for (int i = 0; i < 10; ++i) {
@@ -74,9 +74,9 @@ public class RollingAppenderDeleteMaxDepthTest {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- List<String> expected = Arrays.asList("1", "2", "test-1.log", "test-2.log", "test-3.log");
+ final List<String> expected = Arrays.asList("1", "2", "test-1.log", "test-2.log", "test-3.log");
assertEquals(Arrays.toString(files), expected.size(), files.length);
- for (File file : files) {
+ for (final File file : files) {
assertTrue("test-4.log should have been deleted",
expected.contains(file.getName()));
}
@@ -88,7 +88,7 @@ public class RollingAppenderDeleteMaxDepthTest {
}
private Path writeTextTo(final String location) throws IOException {
- Path path = Paths.get(location);
+ final Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
buffy.write("some text");
@@ -110,10 +110,10 @@ public class RollingAppenderDeleteMaxDepthTest {
}
public static void main(final String[] args) {
- Pattern p = Pattern.compile("test-.?[2,4,6,8,0]\\.log\\.gz");
+ final Pattern p = Pattern.compile("test-.?[2,4,6,8,0]\\.log\\.gz");
for (int i = 0; i < 16; i++) {
- String str = "test-" + i + ".log.gz";
- java.util.regex.Matcher m = p.matcher(str);
+ final String str = "test-" + i + ".log.gz";
+ final java.util.regex.Matcher m = p.matcher(str);
System.out.println(m.matches() + ": " + str);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
index 4fde77e..3022668 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteNestedTest.java
@@ -57,11 +57,11 @@ public class RollingAppenderDeleteNestedTest {
@Test
public void testAppender() throws Exception {
- Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
- Path p2 = writeTextTo(DIR + "/my-2.log");
- Path p3 = writeTextTo(DIR + "/my-3.log");
- Path p4 = writeTextTo(DIR + "/my-4.log");
- Path p5 = writeTextTo(DIR + "/my-5.log");
+ final Path p1 = writeTextTo(DIR + "/my-1.log"); // glob="test-*.log"
+ final Path p2 = writeTextTo(DIR + "/my-2.log");
+ final Path p3 = writeTextTo(DIR + "/my-3.log");
+ final Path p4 = writeTextTo(DIR + "/my-4.log");
+ final Path p5 = writeTextTo(DIR + "/my-5.log");
final Logger logger = ctx.getLogger();
for (int i = 0; i < 10; ++i) {
@@ -77,14 +77,14 @@ public class RollingAppenderDeleteNestedTest {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file + " (" + file.length() + "B) "
+ FixedDateFormat.create(FixedFormat.ABSOLUTE).format(file.lastModified()));
}
- List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
+ final List<String> expected = Arrays.asList("my-1.log", "my-2.log", "my-3.log", "my-4.log", "my-5.log");
assertEquals(Arrays.toString(files), expected.size() + 3, files.length);
- for (File file : files) {
+ for (final File file : files) {
if (!expected.contains(file.getName()) && !file.getName().startsWith("test-")) {
fail("unexpected file" + file);
}
@@ -92,13 +92,13 @@ public class RollingAppenderDeleteNestedTest {
}
private void updateLastModified(final Path... paths) throws IOException {
- for (Path path : paths) {
+ for (final Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
private Path writeTextTo(final String location) throws IOException {
- Path path = Paths.get(location);
+ final Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
buffy.write("some text");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
index 8bb3f7e..652c00d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptFri13thTest.java
@@ -50,7 +50,7 @@ public class RollingAppenderDeleteScriptFri13thTest {
final File dir = new File(DIR);
dir.mkdirs();
for (int i = 1; i <= 30; i++) {
- String day = i < 10 ? "0" + i : "" + i;
+ final String day = i < 10 ? "0" + i : "" + i;
new File(dir, "test-201511" + day + "-0.log").createNewFile();
}
assertEquals("Dir " + DIR + " filecount", 30, dir.listFiles().length);
@@ -64,13 +64,13 @@ public class RollingAppenderDeleteScriptFri13thTest {
}
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file);
}
- for (File file : files) {
+ for (final File file : files) {
assertTrue(file.getName() + " starts with 'test-'", file.getName().startsWith("test-"));
assertTrue(file.getName() + " ends with '.log'", file.getName().endsWith(".log"));
- String strDate = file.getName().substring(5, 13);
+ final String strDate = file.getName().substring(5, 13);
assertFalse(file + " is not Fri 13th", strDate.endsWith("20151113"));
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
index 6f64ebe..0a4ac23 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDeleteScriptTest.java
@@ -60,14 +60,14 @@ public class RollingAppenderDeleteScriptTest {
assertTrue("Dir " + DIR + " should contain files", dir.listFiles().length > 0);
final File[] files = dir.listFiles();
- for (File file : files) {
+ for (final File file : files) {
System.out.println(file);
}
- for (File file : files) {
+ for (final File file : files) {
assertTrue(file.getName() + " starts with 'test-'", file.getName().startsWith("test-"));
assertTrue(file.getName() + " ends with '.log'", file.getName().endsWith(".log"));
- String strIndex = file.getName().substring(5, file.getName().indexOf('.'));
- int index = Integer.parseInt(strIndex);
+ final String strIndex = file.getName().substring(5, file.getName().indexOf('.'));
+ final int index = Integer.parseInt(strIndex);
assertTrue(file + " should have odd index", index % 2 == 1);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
index adcfd68..f354290 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderNoUnconditionalDeleteTest.java
@@ -81,8 +81,8 @@ public class RollingAppenderNoUnconditionalDeleteTest {
assertTrue("Dir " + directory + " should contain files", directory.listFiles().length > 0);
int total = 0;
- for (File file : directory.listFiles()) {
- List<String> lines = Files.readAllLines(file.toPath(), Charset.defaultCharset());
+ for (final File file : directory.listFiles()) {
+ final List<String> lines = Files.readAllLines(file.toPath(), Charset.defaultCharset());
total += lines.size();
}
assertEquals("rolled over lines", LINECOUNT - 1, total);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index 4258cb0..1834105 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -92,26 +92,26 @@ public class RollingAppenderSizeTest {
assertNotNull(files);
assertThat(files, hasItemInArray(that(hasName(that(endsWith(fileExtension))))));
- DefaultRolloverStrategy.FileExtensions ext = DefaultRolloverStrategy.FileExtensions.lookup(fileExtension);
+ final DefaultRolloverStrategy.FileExtensions ext = DefaultRolloverStrategy.FileExtensions.lookup(fileExtension);
if (ext == null || DefaultRolloverStrategy.FileExtensions.ZIP == ext
|| DefaultRolloverStrategy.FileExtensions.PACK200 == ext) {
return; // commons compress cannot deflate zip? TODO test decompressing these formats
}
- for (File file : files) {
+ for (final File file : files) {
if (file.getName().endsWith(fileExtension)) {
CompressorInputStream in = null;
try (FileInputStream fis = new FileInputStream(file)) {
try {
in = new CompressorStreamFactory().createCompressorInputStream(ext.name().toLowerCase(), fis);
- } catch (CompressorException ce) {
+ } catch (final CompressorException ce) {
ce.printStackTrace();
fail("Error creating intput stream from " + file.toString() + ": " + ce.getMessage());
}
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(in, baos);
- String text = new String(baos.toByteArray(), Charset.defaultCharset());
- String[] lines = text.split("[\\r\\n]+");
- for (String line : lines) {
+ final String text = new String(baos.toByteArray(), Charset.defaultCharset());
+ final String[] lines = text.split("[\\r\\n]+");
+ for (final String line : lines) {
assertTrue(line
.contains("DEBUG o.a.l.l.c.a.r.RollingAppenderSizeTest [main] This is test message number"));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
index c745dd3..8f13ae2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteActionTest.java
@@ -40,78 +40,78 @@ import static org.junit.Assert.*;
public class DeleteActionTest {
private static DeleteAction createAnyFilter(final String path, final boolean followLinks, final int maxDepth, final boolean testMode) {
- PathCondition[] pathFilters = {new FixedCondition(true)};
+ final PathCondition[] pathFilters = {new FixedCondition(true)};
return create(path, followLinks, maxDepth, testMode, pathFilters);
}
private static DeleteAction create(final String path, final boolean followLinks, final int maxDepth, final boolean testMode,
final PathCondition[] conditions) {
- Configuration config = new BasicConfigurationFactory().new BasicConfiguration();
- DeleteAction delete = DeleteAction.createDeleteAction(path, followLinks, maxDepth, testMode, null, conditions,
+ final Configuration config = new BasicConfigurationFactory().new BasicConfiguration();
+ final DeleteAction delete = DeleteAction.createDeleteAction(path, followLinks, maxDepth, testMode, null, conditions,
null, config);
return delete;
}
@Test
public void testGetBasePathResolvesLookups() {
- DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
+ final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
- Path actual = delete.getBasePath();
- String expected = System.getProperty("user.home") + "/a/b/c";
+ final Path actual = delete.getBasePath();
+ final String expected = System.getProperty("user.home") + "/a/b/c";
assertEquals(FileSystems.getDefault().getPath(expected), actual);
}
@Test
public void testGetBasePathStringReturnsOriginalParam() {
- DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
+ final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
assertEquals("${sys:user.home}/a/b/c", delete.getBasePathString());
}
@Test
public void testGetMaxDepthReturnsConstructorValue() {
- DeleteAction delete = createAnyFilter("any", false, 23, false);
+ final DeleteAction delete = createAnyFilter("any", false, 23, false);
assertEquals(23, delete.getMaxDepth());
}
@Test
public void testGetOptionsReturnsEmptySetIfNotFollowingLinks() {
- DeleteAction delete = createAnyFilter("any", false, 0, false);
+ final DeleteAction delete = createAnyFilter("any", false, 0, false);
assertEquals(Collections.emptySet(), delete.getOptions());
}
@Test
public void testGetOptionsReturnsSetWithFollowLinksIfFollowingLinks() {
- DeleteAction delete = createAnyFilter("any", true, 0, false);
+ final DeleteAction delete = createAnyFilter("any", true, 0, false);
assertEquals(EnumSet.of(FileVisitOption.FOLLOW_LINKS), delete.getOptions());
}
@Test
public void testGetFiltersReturnsConstructorValue() {
- PathCondition[] filters = {new FixedCondition(true), new FixedCondition(false)};
+ final PathCondition[] filters = {new FixedCondition(true), new FixedCondition(false)};
- DeleteAction delete = create("any", true, 0, false, filters);
+ final DeleteAction delete = create("any", true, 0, false, filters);
assertEquals(Arrays.asList(filters), delete.getPathConditions());
}
@Test
public void testCreateFileVisitorReturnsDeletingVisitor() {
- DeleteAction delete = createAnyFilter("any", true, 0, false);
- FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
+ final DeleteAction delete = createAnyFilter("any", true, 0, false);
+ final FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
assertTrue(visitor instanceof DeletingVisitor);
}
@Test
public void testCreateFileVisitorTestModeIsActionTestMode() {
- DeleteAction delete = createAnyFilter("any", true, 0, false);
+ final DeleteAction delete = createAnyFilter("any", true, 0, false);
assertFalse(delete.isTestMode());
- FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
+ final FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
assertTrue(visitor instanceof DeletingVisitor);
assertFalse(((DeletingVisitor) visitor).isTestMode());
- DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true);
+ final DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true);
assertTrue(deleteTestMode.isTestMode());
- FileVisitor<Path> testVisitor = deleteTestMode.createFileVisitor(delete.getBasePath(),
+ final FileVisitor<Path> testVisitor = deleteTestMode.createFileVisitor(delete.getBasePath(),
delete.getPathConditions());
assertTrue(testVisitor instanceof DeletingVisitor);
assertTrue(((DeletingVisitor) testVisitor).isTestMode());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
index f35f44f..7258c23 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitorTest.java
@@ -53,59 +53,59 @@ public class DeletingVisitorTest {
@Test
public void testAcceptedFilesAreDeleted() throws IOException {
- Path base = Paths.get("/a/b/c");
+ final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(ACCEPT_ALL), false);
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(ACCEPT_ALL), false);
- Path any = Paths.get("/a/b/c/any");
+ final Path any = Paths.get("/a/b/c/any");
visitor.visitFile(any, null);
assertTrue(visitor.deleted.contains(any));
}
@Test
public void testRejectedFilesAreNotDeleted() throws IOException {
- Path base = Paths.get("/a/b/c");
+ final Path base = Paths.get("/a/b/c");
final FixedCondition REJECT_ALL = new FixedCondition(false);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(REJECT_ALL), false);
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(REJECT_ALL), false);
- Path any = Paths.get("/a/b/c/any");
+ final Path any = Paths.get("/a/b/c/any");
visitor.visitFile(any, null);
assertFalse(visitor.deleted.contains(any));
}
@Test
public void testAllFiltersMustAcceptOrFileIsNotDeleted() throws IOException {
- Path base = Paths.get("/a/b/c");
+ final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
final FixedCondition REJECT_ALL = new FixedCondition(false);
- List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, REJECT_ALL);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, false);
+ final List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, REJECT_ALL);
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, false);
- Path any = Paths.get("/a/b/c/any");
+ final Path any = Paths.get("/a/b/c/any");
visitor.visitFile(any, null);
assertFalse(visitor.deleted.contains(any));
}
@Test
public void testIfAllFiltersAcceptFileIsDeleted() throws IOException {
- Path base = Paths.get("/a/b/c");
+ final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
- List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, false);
+ final List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, false);
- Path any = Paths.get("/a/b/c/any");
+ final Path any = Paths.get("/a/b/c/any");
visitor.visitFile(any, null);
assertTrue(visitor.deleted.contains(any));
}
@Test
public void testInTestModeFileIsNotDeletedEvenIfAllFiltersAccept() throws IOException {
- Path base = Paths.get("/a/b/c");
+ final Path base = Paths.get("/a/b/c");
final FixedCondition ACCEPT_ALL = new FixedCondition(true);
- List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, true);
+ final List<? extends PathCondition> filters = Arrays.asList(ACCEPT_ALL, ACCEPT_ALL, ACCEPT_ALL);
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, filters, true);
- Path any = Paths.get("/a/b/c/any");
+ final Path any = Paths.get("/a/b/c/any");
visitor.visitFile(any, null);
assertFalse(visitor.deleted.contains(any));
}
@@ -113,11 +113,11 @@ public class DeletingVisitorTest {
@Test
public void testVisitFileRelativizesAgainstBase() throws IOException {
- PathCondition filter = new PathCondition() {
+ final PathCondition filter = new PathCondition() {
@Override
public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
- Path expected = Paths.get("relative");
+ final Path expected = Paths.get("relative");
assertEquals(expected, relativePath);
return true;
}
@@ -126,10 +126,10 @@ public class DeletingVisitorTest {
public void beforeFileTreeWalk() {
}
};
- Path base = Paths.get("/a/b/c");
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(filter), false);
+ final Path base = Paths.get("/a/b/c");
+ final DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(filter), false);
- Path child = Paths.get("/a/b/c/relative");
+ final Path child = Paths.get("/a/b/c/relative");
visitor.visitFile(child, null);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
index 880a4cf..456f95b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/DurationTest.java
@@ -1,149 +1,149 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import org.apache.logging.log4j.core.appender.rolling.action.Duration;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the Duration class.
- */
-public class DurationTest {
-
- @Test(expected = NullPointerException.class)
- public void testParseFailsIfNullText() {
- Duration.parse(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseFailsIfInvalidPattern() {
- Duration.parse("abc");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseFailsIfSectionsOutOfOrder() {
- Duration.parse("P4DT2M1S3H");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseFailsIfTButMissingTime() {
- Duration.parse("P1dT");
- }
-
- @Test
- public void testParseIsCaseInsensitive() {
- assertEquals("P4DT3H2M1S", Duration.parse("p4dt3h2m1s").toString());
- }
-
- @Test
- public void testParseAllowsOverflows() {
- assertEquals(1000 * 70, Duration.parse("PT70S").toMillis());
- assertEquals(1000 * 70 * 60, Duration.parse("PT70M").toMillis());
- assertEquals(1000 * 25 * 60 * 60, Duration.parse("PT25H").toMillis());
- }
-
- @Test
- public void testToMillis() {
- assertEquals(0, Duration.ZERO.toMillis());
- assertEquals(1000, Duration.parse("PT1S").toMillis());
- assertEquals(1000 * 2 * 60, Duration.parse("PT2M").toMillis());
- assertEquals(1000 * 3 * 60 * 60, Duration.parse("PT3H").toMillis());
- assertEquals(1000 * 4 * 24 * 60 * 60, Duration.parse("P4D").toMillis());
- long expected = (1000 * 4 * 24 * 60 * 60) + (1000 * 3 * 60 * 60) + (1000 * 2 * 60) + 1000;
- assertEquals(expected, Duration.parse("P4DT3H2M1S").toMillis());
- }
-
- @Test
- public void testToString() {
- assertEquals("PT0S", Duration.ZERO.toString());
- assertEquals("PT1S", Duration.parse("PT1S").toString());
- assertEquals("PT2M1S", Duration.parse("PT2M1S").toString());
- assertEquals("PT3H2M1S", Duration.parse("PT3H2M1S").toString());
- assertEquals("P4DT3H2M1S", Duration.parse("P4DT3H2M1S").toString());
- }
-
- @Test
- public void testPrefixPNotRequired() {
- assertEquals("PT1S", Duration.parse("T1S").toString());
- assertEquals("PT2M1S", Duration.parse("T2M1S").toString());
- assertEquals("PT3H2M1S", Duration.parse("T3H2M1S").toString());
- assertEquals("P4DT3H2M1S", Duration.parse("4DT3H2M1S").toString());
- }
-
- @Test
- public void testInfixTNotRequired() {
- assertEquals("PT1S", Duration.parse("P1S").toString());
- assertEquals("PT2M1S", Duration.parse("P2M1S").toString());
- assertEquals("PT3H2M1S", Duration.parse("P3H2M1S").toString());
- assertEquals("P4DT3H2M1S", Duration.parse("P4D3H2M1S").toString());
- }
-
- @Test
- public void testPrefixPAndInfixTNotRequired() {
- assertEquals("PT1S", Duration.parse("1S").toString());
- assertEquals("PT2M1S", Duration.parse("2M1S").toString());
- assertEquals("PT3H2M1S", Duration.parse("3H2M1S").toString());
- assertEquals("P4DT3H2M1S", Duration.parse("4D3H2M1S").toString());
- }
-
- @Test
- public void testCompareTo() {
- assertEquals(-1, Duration.parse("PT1S").compareTo(Duration.parse("PT2S")));
- assertEquals(-1, Duration.parse("PT1M").compareTo(Duration.parse("PT2M")));
- assertEquals(-1, Duration.parse("PT1H").compareTo(Duration.parse("PT2H")));
- assertEquals(-1, Duration.parse("P1D").compareTo(Duration.parse("P2D")));
-
- assertEquals(0, Duration.parse("PT1S").compareTo(Duration.parse("PT1S")));
- assertEquals(0, Duration.parse("PT1M").compareTo(Duration.parse("PT1M")));
- assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT1H")));
- assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("P1D")));
-
- assertEquals(1, Duration.parse("PT2S").compareTo(Duration.parse("PT1S")));
- assertEquals(1, Duration.parse("PT2M").compareTo(Duration.parse("PT1M")));
- assertEquals(1, Duration.parse("PT2H").compareTo(Duration.parse("PT1H")));
- assertEquals(1, Duration.parse("P2D").compareTo(Duration.parse("P1D")));
-
- assertEquals(0, Duration.parse("PT1M").compareTo(Duration.parse("PT60S")));
- assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT60M")));
- assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT3600S")));
- assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("PT24H")));
- assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("PT1440M")));
- }
-
- @Test
- public void testEquals() {
- assertNotEquals(Duration.parse("PT1S"),(Duration.parse("PT2S")));
- assertNotEquals(Duration.parse("PT1M"),(Duration.parse("PT2M")));
- assertNotEquals(Duration.parse("PT1H"),(Duration.parse("PT2H")));
- assertNotEquals(Duration.parse("P1D"),(Duration.parse("P2D")));
-
- assertEquals( Duration.parse("PT1S"),(Duration.parse("PT1S")));
- assertEquals( Duration.parse("PT1M"),(Duration.parse("PT1M")));
- assertEquals( Duration.parse("PT1H"),(Duration.parse("PT1H")));
- assertEquals( Duration.parse("P1D"),(Duration.parse("P1D")));
-
- assertEquals( Duration.parse("PT1M"),(Duration.parse("PT60S")));
- assertEquals( Duration.parse("PT1H"),(Duration.parse("PT60M")));
- assertEquals( Duration.parse("PT1H"),(Duration.parse("PT3600S")));
- assertEquals( Duration.parse("P1D"),(Duration.parse("PT24H")));
- assertEquals(Duration.parse("P1D"), (Duration.parse("PT1440M")));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.core.appender.rolling.action.Duration;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the Duration class.
+ */
+public class DurationTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testParseFailsIfNullText() {
+ Duration.parse(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseFailsIfInvalidPattern() {
+ Duration.parse("abc");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseFailsIfSectionsOutOfOrder() {
+ Duration.parse("P4DT2M1S3H");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseFailsIfTButMissingTime() {
+ Duration.parse("P1dT");
+ }
+
+ @Test
+ public void testParseIsCaseInsensitive() {
+ assertEquals("P4DT3H2M1S", Duration.parse("p4dt3h2m1s").toString());
+ }
+
+ @Test
+ public void testParseAllowsOverflows() {
+ assertEquals(1000 * 70, Duration.parse("PT70S").toMillis());
+ assertEquals(1000 * 70 * 60, Duration.parse("PT70M").toMillis());
+ assertEquals(1000 * 25 * 60 * 60, Duration.parse("PT25H").toMillis());
+ }
+
+ @Test
+ public void testToMillis() {
+ assertEquals(0, Duration.ZERO.toMillis());
+ assertEquals(1000, Duration.parse("PT1S").toMillis());
+ assertEquals(1000 * 2 * 60, Duration.parse("PT2M").toMillis());
+ assertEquals(1000 * 3 * 60 * 60, Duration.parse("PT3H").toMillis());
+ assertEquals(1000 * 4 * 24 * 60 * 60, Duration.parse("P4D").toMillis());
+ final long expected = (1000 * 4 * 24 * 60 * 60) + (1000 * 3 * 60 * 60) + (1000 * 2 * 60) + 1000;
+ assertEquals(expected, Duration.parse("P4DT3H2M1S").toMillis());
+ }
+
+ @Test
+ public void testToString() {
+ assertEquals("PT0S", Duration.ZERO.toString());
+ assertEquals("PT1S", Duration.parse("PT1S").toString());
+ assertEquals("PT2M1S", Duration.parse("PT2M1S").toString());
+ assertEquals("PT3H2M1S", Duration.parse("PT3H2M1S").toString());
+ assertEquals("P4DT3H2M1S", Duration.parse("P4DT3H2M1S").toString());
+ }
+
+ @Test
+ public void testPrefixPNotRequired() {
+ assertEquals("PT1S", Duration.parse("T1S").toString());
+ assertEquals("PT2M1S", Duration.parse("T2M1S").toString());
+ assertEquals("PT3H2M1S", Duration.parse("T3H2M1S").toString());
+ assertEquals("P4DT3H2M1S", Duration.parse("4DT3H2M1S").toString());
+ }
+
+ @Test
+ public void testInfixTNotRequired() {
+ assertEquals("PT1S", Duration.parse("P1S").toString());
+ assertEquals("PT2M1S", Duration.parse("P2M1S").toString());
+ assertEquals("PT3H2M1S", Duration.parse("P3H2M1S").toString());
+ assertEquals("P4DT3H2M1S", Duration.parse("P4D3H2M1S").toString());
+ }
+
+ @Test
+ public void testPrefixPAndInfixTNotRequired() {
+ assertEquals("PT1S", Duration.parse("1S").toString());
+ assertEquals("PT2M1S", Duration.parse("2M1S").toString());
+ assertEquals("PT3H2M1S", Duration.parse("3H2M1S").toString());
+ assertEquals("P4DT3H2M1S", Duration.parse("4D3H2M1S").toString());
+ }
+
+ @Test
+ public void testCompareTo() {
+ assertEquals(-1, Duration.parse("PT1S").compareTo(Duration.parse("PT2S")));
+ assertEquals(-1, Duration.parse("PT1M").compareTo(Duration.parse("PT2M")));
+ assertEquals(-1, Duration.parse("PT1H").compareTo(Duration.parse("PT2H")));
+ assertEquals(-1, Duration.parse("P1D").compareTo(Duration.parse("P2D")));
+
+ assertEquals(0, Duration.parse("PT1S").compareTo(Duration.parse("PT1S")));
+ assertEquals(0, Duration.parse("PT1M").compareTo(Duration.parse("PT1M")));
+ assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT1H")));
+ assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("P1D")));
+
+ assertEquals(1, Duration.parse("PT2S").compareTo(Duration.parse("PT1S")));
+ assertEquals(1, Duration.parse("PT2M").compareTo(Duration.parse("PT1M")));
+ assertEquals(1, Duration.parse("PT2H").compareTo(Duration.parse("PT1H")));
+ assertEquals(1, Duration.parse("P2D").compareTo(Duration.parse("P1D")));
+
+ assertEquals(0, Duration.parse("PT1M").compareTo(Duration.parse("PT60S")));
+ assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT60M")));
+ assertEquals(0, Duration.parse("PT1H").compareTo(Duration.parse("PT3600S")));
+ assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("PT24H")));
+ assertEquals(0, Duration.parse("P1D").compareTo(Duration.parse("PT1440M")));
+ }
+
+ @Test
+ public void testEquals() {
+ assertNotEquals(Duration.parse("PT1S"),(Duration.parse("PT2S")));
+ assertNotEquals(Duration.parse("PT1M"),(Duration.parse("PT2M")));
+ assertNotEquals(Duration.parse("PT1H"),(Duration.parse("PT2H")));
+ assertNotEquals(Duration.parse("P1D"),(Duration.parse("P2D")));
+
+ assertEquals( Duration.parse("PT1S"),(Duration.parse("PT1S")));
+ assertEquals( Duration.parse("PT1M"),(Duration.parse("PT1M")));
+ assertEquals( Duration.parse("PT1H"),(Duration.parse("PT1H")));
+ assertEquals( Duration.parse("P1D"),(Duration.parse("P1D")));
+
+ assertEquals( Duration.parse("PT1M"),(Duration.parse("PT60S")));
+ assertEquals( Duration.parse("PT1H"),(Duration.parse("PT60M")));
+ assertEquals( Duration.parse("PT1H"),(Duration.parse("PT3600S")));
+ assertEquals( Duration.parse("P1D"),(Duration.parse("PT24H")));
+ assertEquals(Duration.parse("P1D"), (Duration.parse("PT1440M")));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
index bb2a0d0..0022b40 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCountTest.java
@@ -1,75 +1,75 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the IfAccumulatedFileCount class.
- */
-public class IfAccumulatedFileCountTest {
-
- @Test
- public void testGetThresholdCount() {
- assertEquals(123, IfAccumulatedFileCount.createFileCountCondition(123).getThresholdCount());
- assertEquals(456, IfAccumulatedFileCount.createFileCountCondition(456).getThresholdCount());
- }
-
- @Test
- public void testAccept() {
- int[] counts = {3, 5, 9};
- for (int count : counts) {
- IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(count);
- for (int i = 0; i < count; i++) {
- assertFalse(condition.accept(null, null, null));
- // exact match: does not accept
- }
- // accept when threshold is exceeded
- assertTrue(condition.accept(null, null, null));
- assertTrue(condition.accept(null, null, null));
- }
- }
-
- @Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
- final CountingCondition counter = new CountingCondition(true);
- IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(3, counter);
-
- for (int i = 1; i < 10; i++) {
- if (i <= 3) {
- assertFalse("i=" + i, condition.accept(null, null, null));
- assertEquals(0, counter.getAcceptCount());
- } else {
- assertTrue(condition.accept(null, null, null));
- assertEquals(i - 3, counter.getAcceptCount());
- }
- }
- }
-
- @Test
- public void testBeforeTreeWalk() {
- final CountingCondition counter = new CountingCondition(true);
- final IfAccumulatedFileCount filter = IfAccumulatedFileCount.createFileCountCondition(30, counter, counter,
- counter);
- filter.beforeFileTreeWalk();
- assertEquals(3, counter.getBeforeFileTreeWalkCount());
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the IfAccumulatedFileCount class.
+ */
+public class IfAccumulatedFileCountTest {
+
+ @Test
+ public void testGetThresholdCount() {
+ assertEquals(123, IfAccumulatedFileCount.createFileCountCondition(123).getThresholdCount());
+ assertEquals(456, IfAccumulatedFileCount.createFileCountCondition(456).getThresholdCount());
+ }
+
+ @Test
+ public void testAccept() {
+ final int[] counts = {3, 5, 9};
+ for (final int count : counts) {
+ final IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(count);
+ for (int i = 0; i < count; i++) {
+ assertFalse(condition.accept(null, null, null));
+ // exact match: does not accept
+ }
+ // accept when threshold is exceeded
+ assertTrue(condition.accept(null, null, null));
+ assertTrue(condition.accept(null, null, null));
+ }
+ }
+
+ @Test
+ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(3, counter);
+
+ for (int i = 1; i < 10; i++) {
+ if (i <= 3) {
+ assertFalse("i=" + i, condition.accept(null, null, null));
+ assertEquals(0, counter.getAcceptCount());
+ } else {
+ assertTrue(condition.accept(null, null, null));
+ assertEquals(i - 3, counter.getAcceptCount());
+ }
+ }
+ }
+
+ @Test
+ public void testBeforeTreeWalk() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfAccumulatedFileCount filter = IfAccumulatedFileCount.createFileCountCondition(30, counter, counter,
+ counter);
+ filter.beforeFileTreeWalk();
+ assertEquals(3, counter.getBeforeFileTreeWalkCount());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ce4492f6/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
index d22df55..740c998 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSizeTest.java
@@ -1,130 +1,130 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the IfAccumulatedFileSize class.
- */
-public class IfAccumulatedFileSizeTest {
-
- @Test
- public void testGetThresholdBytes() {
- assertEquals(2, create("2B").getThresholdBytes());
- assertEquals(3, create("3 B").getThresholdBytes());
- assertEquals(2 * 1024, create("2KB").getThresholdBytes());
- assertEquals(3 * 1024, create("3 KB").getThresholdBytes());
- assertEquals(2 * 1024 * 1024, create("2MB").getThresholdBytes());
- assertEquals(3 * 1024 * 1024, create("3 MB").getThresholdBytes());
- assertEquals(2L * 1024 * 1024 * 1024, create("2GB").getThresholdBytes());
- assertEquals(3L * 1024 * 1024 * 1024, create("3 GB").getThresholdBytes());
- }
-
- private static IfAccumulatedFileSize create(final String size) {
- return IfAccumulatedFileSize.createFileSizeCondition(size);
- }
-
- @Test
- public void testNotAcceptOnExactMatch() {
- String[] sizes = {"2KB", "3MB", "4GB"};
- for (String size : sizes) {
- IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
- DummyFileAttributes attribs = new DummyFileAttributes();
- attribs.size = condition.getThresholdBytes();
- assertFalse(condition.accept(null, null, attribs));
- }
- }
-
- @Test
- public void testAcceptIfExceedThreshold() {
- String[] sizes = {"2KB", "3MB", "4GB"};
- for (String size : sizes) {
- IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
- DummyFileAttributes attribs = new DummyFileAttributes();
- attribs.size = condition.getThresholdBytes() + 1;
- assertTrue(condition.accept(null, null, attribs));
- }
- }
-
- @Test
- public void testNotAcceptIfBelowThreshold() {
- String[] sizes = {"2KB", "3MB", "4GB"};
- for (String size : sizes) {
- IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
- DummyFileAttributes attribs = new DummyFileAttributes();
- attribs.size = condition.getThresholdBytes() - 1;
- assertFalse(condition.accept(null, null, attribs));
- }
- }
-
- @Test
- public void testAcceptOnceThresholdExceeded() {
- DummyFileAttributes attribs = new DummyFileAttributes();
- String[] sizes = {"2KB", "3MB", "4GB"};
- for (String size : sizes) {
- IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
- long quarter = condition.getThresholdBytes() / 4;
- attribs.size = quarter;
- assertFalse(condition.accept(null, null, attribs));
- assertFalse(condition.accept(null, null, attribs));
- assertFalse(condition.accept(null, null, attribs));
- assertFalse(condition.accept(null, null, attribs));
- assertTrue(condition.accept(null, null, attribs));
- }
- }
-
- @Test
- public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
- final CountingCondition counter = new CountingCondition(true);
- IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition("2KB", counter);
- DummyFileAttributes attribs = new DummyFileAttributes();
-
- long quarter = condition.getThresholdBytes() / 4;
- attribs.size = quarter;
- assertFalse(condition.accept(null, null, attribs));
- assertEquals(0, counter.getAcceptCount());
-
- assertFalse(condition.accept(null, null, attribs));
- assertEquals(0, counter.getAcceptCount());
-
- assertFalse(condition.accept(null, null, attribs));
- assertEquals(0, counter.getAcceptCount());
-
- assertFalse(condition.accept(null, null, attribs));
- assertEquals(0, counter.getAcceptCount());
-
- assertTrue(condition.accept(null, null, attribs));
- assertEquals(1, counter.getAcceptCount());
-
- assertTrue(condition.accept(null, null, attribs));
- assertEquals(2, counter.getAcceptCount());
- }
-
- @Test
- public void testBeforeTreeWalk() {
- final CountingCondition counter = new CountingCondition(true);
- final IfAccumulatedFileSize filter = IfAccumulatedFileSize.createFileSizeCondition("2GB", counter, counter,
- counter);
- filter.beforeFileTreeWalk();
- assertEquals(3, counter.getBeforeFileTreeWalkCount());
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the IfAccumulatedFileSize class.
+ */
+public class IfAccumulatedFileSizeTest {
+
+ @Test
+ public void testGetThresholdBytes() {
+ assertEquals(2, create("2B").getThresholdBytes());
+ assertEquals(3, create("3 B").getThresholdBytes());
+ assertEquals(2 * 1024, create("2KB").getThresholdBytes());
+ assertEquals(3 * 1024, create("3 KB").getThresholdBytes());
+ assertEquals(2 * 1024 * 1024, create("2MB").getThresholdBytes());
+ assertEquals(3 * 1024 * 1024, create("3 MB").getThresholdBytes());
+ assertEquals(2L * 1024 * 1024 * 1024, create("2GB").getThresholdBytes());
+ assertEquals(3L * 1024 * 1024 * 1024, create("3 GB").getThresholdBytes());
+ }
+
+ private static IfAccumulatedFileSize create(final String size) {
+ return IfAccumulatedFileSize.createFileSizeCondition(size);
+ }
+
+ @Test
+ public void testNotAcceptOnExactMatch() {
+ final String[] sizes = {"2KB", "3MB", "4GB"};
+ for (final String size : sizes) {
+ final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
+ final DummyFileAttributes attribs = new DummyFileAttributes();
+ attribs.size = condition.getThresholdBytes();
+ assertFalse(condition.accept(null, null, attribs));
+ }
+ }
+
+ @Test
+ public void testAcceptIfExceedThreshold() {
+ final String[] sizes = {"2KB", "3MB", "4GB"};
+ for (final String size : sizes) {
+ final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
+ final DummyFileAttributes attribs = new DummyFileAttributes();
+ attribs.size = condition.getThresholdBytes() + 1;
+ assertTrue(condition.accept(null, null, attribs));
+ }
+ }
+
+ @Test
+ public void testNotAcceptIfBelowThreshold() {
+ final String[] sizes = {"2KB", "3MB", "4GB"};
+ for (final String size : sizes) {
+ final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
+ final DummyFileAttributes attribs = new DummyFileAttributes();
+ attribs.size = condition.getThresholdBytes() - 1;
+ assertFalse(condition.accept(null, null, attribs));
+ }
+ }
+
+ @Test
+ public void testAcceptOnceThresholdExceeded() {
+ final DummyFileAttributes attribs = new DummyFileAttributes();
+ final String[] sizes = {"2KB", "3MB", "4GB"};
+ for (final String size : sizes) {
+ final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
+ final long quarter = condition.getThresholdBytes() / 4;
+ attribs.size = quarter;
+ assertFalse(condition.accept(null, null, attribs));
+ assertFalse(condition.accept(null, null, attribs));
+ assertFalse(condition.accept(null, null, attribs));
+ assertFalse(condition.accept(null, null, attribs));
+ assertTrue(condition.accept(null, null, attribs));
+ }
+ }
+
+ @Test
+ public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition("2KB", counter);
+ final DummyFileAttributes attribs = new DummyFileAttributes();
+
+ final long quarter = condition.getThresholdBytes() / 4;
+ attribs.size = quarter;
+ assertFalse(condition.accept(null, null, attribs));
+ assertEquals(0, counter.getAcceptCount());
+
+ assertFalse(condition.accept(null, null, attribs));
+ assertEquals(0, counter.getAcceptCount());
+
+ assertFalse(condition.accept(null, null, attribs));
+ assertEquals(0, counter.getAcceptCount());
+
+ assertFalse(condition.accept(null, null, attribs));
+ assertEquals(0, counter.getAcceptCount());
+
+ assertTrue(condition.accept(null, null, attribs));
+ assertEquals(1, counter.getAcceptCount());
+
+ assertTrue(condition.accept(null, null, attribs));
+ assertEquals(2, counter.getAcceptCount());
+ }
+
+ @Test
+ public void testBeforeTreeWalk() {
+ final CountingCondition counter = new CountingCondition(true);
+ final IfAccumulatedFileSize filter = IfAccumulatedFileSize.createFileSizeCondition("2GB", counter, counter,
+ counter);
+ filter.beforeFileTreeWalk();
+ assertEquals(3, counter.getBeforeFileTreeWalkCount());
+ }
+
+}