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:10:49 UTC
[01/10] logging-log4j2 git commit: Use final.
Repository: logging-log4j2
Updated Branches:
refs/heads/master e3c418d1c -> 018ca8a30
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/132e9489
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/132e9489
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/132e9489
Branch: refs/heads/master
Commit: 132e9489189855f4d8f3f27ead8a043a7c72c41b
Parents: e3c418d
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 10:01:38 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 10:01:38 2016 -0700
----------------------------------------------------------------------
.../log4j/message/AbstractMessageFactory.java | 30 +++++++++---------
.../log4j/message/FormattedMessageFactory.java | 28 ++++++++---------
.../log4j/message/MessageFormatMessage.java | 2 +-
.../message/MessageFormatMessageFactory.java | 28 ++++++++---------
.../log4j/message/ParameterFormatter.java | 10 +++---
.../log4j/message/ParameterizedMessage.java | 6 ++--
.../message/ParameterizedMessageFactory.java | 28 ++++++++---------
.../log4j/message/ReusableMessageFactory.java | 6 ++--
.../log4j/message/ReusableObjectMessage.java | 2 +-
.../message/ReusableParameterizedMessage.java | 32 ++++++++++----------
.../log4j/message/ReusableSimpleMessage.java | 4 +--
.../logging/log4j/message/SimpleMessage.java | 4 +--
.../log4j/message/SimpleMessageFactory.java | 28 ++++++++---------
.../message/StringFormatterMessageFactory.java | 28 ++++++++---------
.../logging/log4j/message/JsonMessage.java | 2 +-
.../log4j/message/ParameterFormatterTest.java | 12 ++++----
.../message/ReusableObjectMessageTest.java | 18 +++++------
.../ReusableParameterizedMessageTest.java | 4 +--
.../message/ReusableSimpleMessageTest.java | 18 +++++------
19 files changed, 145 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java
index c1913a6..6429ed7 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/AbstractMessageFactory.java
@@ -35,7 +35,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
private static final long serialVersionUID = -1307891137684031187L;
@Override
- public Message newMessage(CharSequence message) {
+ public Message newMessage(final CharSequence message) {
return new SimpleMessage(message);
}
@@ -63,7 +63,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return newMessage(message, new Object[] { p0 });
}
@@ -71,7 +71,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return newMessage(message, new Object[] { p0, p1 });
}
@@ -79,7 +79,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return newMessage(message, new Object[] { p0, p1, p2 });
}
@@ -87,7 +87,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return newMessage(message, new Object[] { p0, p1, p2, p3 });
}
@@ -95,7 +95,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4 });
}
@@ -103,7 +103,7 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4, p5 });
}
@@ -111,8 +111,8 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4, p5, p6 });
}
@@ -120,8 +120,8 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4, p5, p6, p7 });
}
@@ -129,8 +129,8 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4, p5, p6, p7, p8 });
}
@@ -138,8 +138,8 @@ public abstract class AbstractMessageFactory implements MessageFactory2, Seriali
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return newMessage(message, new Object[] { p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 });
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java
index e72c3e6..805e24b 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/FormattedMessageFactory.java
@@ -54,7 +54,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return new FormattedMessage(message, p0);
}
@@ -62,7 +62,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return new FormattedMessage(message, p0, p1);
}
@@ -70,7 +70,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return new FormattedMessage(message, p0, p1, p2);
}
@@ -78,7 +78,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return new FormattedMessage(message, p0, p1, p2, p3);
}
@@ -86,7 +86,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return new FormattedMessage(message, p0, p1, p2, p3, p4);
}
@@ -94,7 +94,7 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return new FormattedMessage(message, p0, p1, p2, p3, p4, p5);
}
@@ -102,8 +102,8 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6);
}
@@ -111,8 +111,8 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
}
@@ -120,8 +120,8 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
@@ -129,8 +129,8 @@ public class FormattedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java
index 3991c30..b34a72d 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessage.java
@@ -112,7 +112,7 @@ public class MessageFormatMessage implements Message {
protected String formatMessage(final String msgPattern, final Object... args) {
try {
- MessageFormat temp = new MessageFormat(msgPattern, locale);
+ final MessageFormat temp = new MessageFormat(msgPattern, locale);
return temp.format(args);
} catch (final IllegalFormatException ife) {
LOGGER.error("Unable to format msg: " + msgPattern, ife);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java
index 40e43dc..f75e68b 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFormatMessageFactory.java
@@ -52,7 +52,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return new MessageFormatMessage(message, p0);
}
@@ -60,7 +60,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return new MessageFormatMessage(message, p0, p1);
}
@@ -68,7 +68,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return new MessageFormatMessage(message, p0, p1, p2);
}
@@ -76,7 +76,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return new MessageFormatMessage(message, p0, p1, p2, p3);
}
@@ -84,7 +84,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4);
}
@@ -92,7 +92,7 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4, p5);
}
@@ -100,8 +100,8 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4, p5, p6);
}
@@ -109,8 +109,8 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
}
@@ -118,8 +118,8 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
@@ -127,8 +127,8 @@ public class MessageFormatMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return new MessageFormatMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
index fa1a43a..0718cc1 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java
@@ -75,7 +75,7 @@ final class ParameterFormatter {
if (messagePattern == null) {
return 0;
}
- int length = messagePattern.length();
+ final int length = messagePattern.length();
int result = 0;
boolean isEscaped = false;
for (int i = 0; i < length - 1; i++) {
@@ -105,7 +105,7 @@ final class ParameterFormatter {
if (messagePattern == null) {
return 0;
}
- int length = messagePattern.length();
+ final int length = messagePattern.length();
int result = 0;
boolean isEscaped = false;
for (int i = 0; i < length - 1; i++) {
@@ -134,7 +134,7 @@ final class ParameterFormatter {
* @param messagePattern the message pattern to be analyzed.
* @return the number of unescaped placeholders.
*/
- static int countArgumentPlaceholders3(final char[] messagePattern, int length, final int[] indices) {
+ static int countArgumentPlaceholders3(final char[] messagePattern, final int length, final int[] indices) {
int result = 0;
boolean isEscaped = false;
for (int i = 0; i < length - 1; i++) {
@@ -229,7 +229,7 @@ final class ParameterFormatter {
int escapeCounter = 0;
int currentArgument = 0;
int i = 0;
- int len = messagePattern.length();
+ final int len = messagePattern.length();
for (; i < len - 1; i++) { // last char is excluded from the loop
final char curChar = messagePattern.charAt(i);
if (curChar == ESCAPE_CHAR) {
@@ -275,7 +275,7 @@ final class ParameterFormatter {
// Profiling showed this method is important to log4j performance. Modify with care!
// 28 bytes (allows immediate JVM inlining: < 35 bytes) LOG4J2-1096
private static void handleRemainingCharIfAny(final String messagePattern, final int len,
- final StringBuilder buffer, int escapeCounter, int i) {
+ final StringBuilder buffer, final int escapeCounter, final int i) {
if (i == len - 1) {
final char curChar = messagePattern.charAt(i);
handleLastChar(buffer, escapeCounter, curChar);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
index 6c5b8e7..c48ab14 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
@@ -133,17 +133,17 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable {
this(messagePattern, new Object[]{arg0, arg1});
}
- private void init(String messagePattern) {
+ private void init(final String messagePattern) {
this.messagePattern = messagePattern;
this.indices = new int[messagePattern == null ? 0 : messagePattern.length() >> 1]; // divide by 2
- int usedCount = ParameterFormatter.countArgumentPlaceholders2(messagePattern, indices);
+ final int usedCount = ParameterFormatter.countArgumentPlaceholders2(messagePattern, indices);
initThrowable(argArray, usedCount);
this.usedCount = Math.min(usedCount, (argArray == null) ? 0 : argArray.length);
}
private void initThrowable(final Object[] params, final int usedParams) {
if (params != null) {
- int argCount = params.length;
+ final int argCount = params.length;
if (usedParams < argCount && this.throwable == null && params[argCount - 1] instanceof Throwable) {
this.throwable = (Throwable) params[argCount - 1];
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java
index b526bc4..5878cac 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessageFactory.java
@@ -67,7 +67,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return new ParameterizedMessage(message, p0);
}
@@ -75,7 +75,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return new ParameterizedMessage(message, p0, p1);
}
@@ -83,7 +83,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return new ParameterizedMessage(message, p0, p1, p2);
}
@@ -91,7 +91,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return new ParameterizedMessage(message, p0, p1, p2, p3);
}
@@ -99,7 +99,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4);
}
@@ -107,7 +107,7 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5);
}
@@ -115,8 +115,8 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6);
}
@@ -124,8 +124,8 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
}
@@ -133,8 +133,8 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
@@ -142,8 +142,8 @@ public final class ParameterizedMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java
index b29d842..9a6329b 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java
@@ -78,7 +78,7 @@ public final class ReusableMessageFactory implements MessageFactory2, Serializab
@Override
public Message newMessage(final CharSequence charSequence) {
- ReusableSimpleMessage result = getSimple();
+ final ReusableSimpleMessage result = getSimple();
result.set(charSequence);
return result;
}
@@ -164,7 +164,7 @@ public final class ReusableMessageFactory implements MessageFactory2, Serializab
*/
@Override
public Message newMessage(final String message) {
- ReusableSimpleMessage result = getSimple();
+ final ReusableSimpleMessage result = getSimple();
result.set(message);
return result;
}
@@ -180,7 +180,7 @@ public final class ReusableMessageFactory implements MessageFactory2, Serializab
*/
@Override
public Message newMessage(final Object message) {
- ReusableObjectMessage result = getObject();
+ final ReusableObjectMessage result = getObject();
result.set(message);
return result;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
index fddc0eb..21e9f98 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
@@ -30,7 +30,7 @@ public class ReusableObjectMessage implements ReusableMessage {
private transient Object obj;
private transient String objectString;
- public void set(Object object) {
+ public void set(final Object object) {
this.obj = object;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
index 2498eb6..96f5394 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
@@ -108,7 +108,7 @@ public class ReusableParameterizedMessage implements ReusableMessage {
this.varargs = null;
this.messagePattern = messagePattern;
this.argCount = argCount;
- int placeholderCount = count(messagePattern, indices);
+ final int placeholderCount = count(messagePattern, indices);
initThrowable(paramArray, argCount, placeholderCount);
this.usedCount = Math.min(placeholderCount, argCount);
}
@@ -130,26 +130,26 @@ public class ReusableParameterizedMessage implements ReusableMessage {
}
}
- ReusableParameterizedMessage set(String messagePattern, Object... arguments) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object... arguments) {
init(messagePattern, arguments == null ? 0 : arguments.length, arguments);
varargs = arguments;
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0) {
params[0] = p0;
init(messagePattern, 1, params);
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1) {
params[0] = p0;
params[1] = p1;
init(messagePattern, 2, params);
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -157,7 +157,7 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -166,7 +166,7 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -176,7 +176,7 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -187,8 +187,8 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -200,8 +200,8 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -214,8 +214,8 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
@@ -229,8 +229,8 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return this;
}
- ReusableParameterizedMessage set(String messagePattern, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ ReusableParameterizedMessage set(final String messagePattern, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
params[0] = p0;
params[1] = p1;
params[2] = p2;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
index d894ef7..905b694 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
@@ -93,12 +93,12 @@ public class ReusableSimpleMessage implements ReusableMessage, CharSequence {
}
@Override
- public char charAt(int index) {
+ public char charAt(final int index) {
return charSequence.charAt(index);
}
@Override
- public CharSequence subSequence(int start, int end) {
+ public CharSequence subSequence(final int start, final int end) {
return charSequence.subSequence(start, end);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
index 3701b09..0c209e5 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
@@ -133,12 +133,12 @@ public class SimpleMessage implements Message, StringBuilderFormattable, CharSeq
}
@Override
- public char charAt(int index) {
+ public char charAt(final int index) {
return charSequence.charAt(index);
}
@Override
- public CharSequence subSequence(int start, int end) {
+ public CharSequence subSequence(final int start, final int end) {
return charSequence.subSequence(start, end);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java
index 2a60358..e85b8c0 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/SimpleMessageFactory.java
@@ -65,7 +65,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return new SimpleMessage(message);
}
@@ -73,7 +73,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return new SimpleMessage(message);
}
@@ -81,7 +81,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return new SimpleMessage(message);
}
@@ -89,7 +89,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return new SimpleMessage(message);
}
@@ -97,7 +97,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return new SimpleMessage(message);
}
@@ -105,7 +105,7 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return new SimpleMessage(message);
}
@@ -113,8 +113,8 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return new SimpleMessage(message);
}
@@ -122,8 +122,8 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return new SimpleMessage(message);
}
@@ -131,8 +131,8 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return new SimpleMessage(message);
}
@@ -140,8 +140,8 @@ public final class SimpleMessageFactory extends AbstractMessageFactory {
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return new SimpleMessage(message);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java
index 19a63fb..b6554d5 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java
@@ -66,7 +66,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0) {
+ public Message newMessage(final String message, final Object p0) {
return new StringFormattedMessage(message, p0);
}
@@ -74,7 +74,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1) {
+ public Message newMessage(final String message, final Object p0, final Object p1) {
return new StringFormattedMessage(message, p0, p1);
}
@@ -82,7 +82,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
return new StringFormattedMessage(message, p0, p1, p2);
}
@@ -90,7 +90,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
return new StringFormattedMessage(message, p0, p1, p2, p3);
}
@@ -98,7 +98,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4);
}
@@ -106,7 +106,7 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4, p5);
}
@@ -114,8 +114,8 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4, p5, p6);
}
@@ -123,8 +123,8 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
}
@@ -132,8 +132,8 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
@@ -141,8 +141,8 @@ public final class StringFormatterMessageFactory extends AbstractMessageFactory
* @since 2.6.1
*/
@Override
- public Message newMessage(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5,
- Object p6, Object p7, Object p8, Object p9) {
+ public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
+ final Object p6, final Object p7, final Object p8, final Object p9) {
return new StringFormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/message/JsonMessage.java b/log4j-api/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
index 7d228b8..5107841 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/message/JsonMessage.java
@@ -43,7 +43,7 @@ public class JsonMessage implements Message {
public String getFormattedMessage() {
try {
return mapper.writeValueAsString(object);
- } catch (JsonProcessingException e) {
+ } catch (final JsonProcessingException e) {
StatusLogger.getLogger().catching(e);
return object.toString();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java
index 625b1b8..6e728f6 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/message/ParameterFormatterTest.java
@@ -169,23 +169,23 @@ public class ParameterFormatterTest {
@Test
public void testDeepToString() throws Exception {
- List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<>();
list.add(1);
list.add(list);
list.add(2);
- String actual = ParameterFormatter.deepToString(list);
- String expected = "[1, [..." + ParameterFormatter.identityToString(list) + "...], 2]";
+ final String actual = ParameterFormatter.deepToString(list);
+ final String expected = "[1, [..." + ParameterFormatter.identityToString(list) + "...], 2]";
assertEquals(expected, actual);
}
@Test
public void testIdentityToString() throws Exception {
- List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<>();
list.add(1);
list.add(list);
list.add(2);
- String actual = ParameterFormatter.identityToString(list);
- String expected = list.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(list));
+ final String actual = ParameterFormatter.identityToString(list);
+ final String expected = list.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(list));
assertEquals(expected, actual);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java
index 961eaa9..d4f87a7 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableObjectMessageTest.java
@@ -27,7 +27,7 @@ public class ReusableObjectMessageTest {
@Test
public void testSet_InitializesFormattedMessage() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
msg.set("abc");
assertEquals("abc", msg.getFormattedMessage());
}
@@ -39,7 +39,7 @@ public class ReusableObjectMessageTest {
@Test
public void testGetFormattedMessage_ReturnsLatestSetString() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
msg.set("abc");
assertEquals("abc", msg.getFormattedMessage());
msg.set("def");
@@ -55,7 +55,7 @@ public class ReusableObjectMessageTest {
@Test
public void testGetFormat_ReturnsLatestSetString() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
msg.set("abc");
assertEquals("abc", msg.getFormat());
msg.set("def");
@@ -71,7 +71,7 @@ public class ReusableObjectMessageTest {
@Test
public void testGetParameters_ReturnsSetObjectInParameterArrayAfterMessageSet() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
msg.set("abc");
assertArrayEquals(new Object[]{"abc"}, msg.getParameters());
msg.set("def");
@@ -85,7 +85,7 @@ public class ReusableObjectMessageTest {
@Test
public void testGetThrowable_ReturnsNullAfterMessageSet() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
msg.set("abc");
assertNull(msg.getThrowable());
msg.set("def");
@@ -94,16 +94,16 @@ public class ReusableObjectMessageTest {
@Test
public void testFormatTo_InitiallyWritesNull() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
- StringBuilder sb = new StringBuilder();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
+ final StringBuilder sb = new StringBuilder();
msg.formatTo(sb);
assertEquals("null", sb.toString());
}
@Test
public void testFormatTo_WritesLatestSetString() throws Exception {
- ReusableObjectMessage msg = new ReusableObjectMessage();
- StringBuilder sb = new StringBuilder();
+ final ReusableObjectMessage msg = new ReusableObjectMessage();
+ final StringBuilder sb = new StringBuilder();
msg.formatTo(sb);
assertEquals("null", sb.toString());
sb.setLength(0);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java
index 00fe130..4b6182b 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableParameterizedMessageTest.java
@@ -29,7 +29,7 @@ public class ReusableParameterizedMessageTest {
@Test
public void testNoArgs() {
final String testMsg = "Test message {}";
- ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
+ final ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
msg.set(testMsg, (Object[]) null);
String result = msg.getFormattedMessage();
assertEquals(testMsg, result);
@@ -129,7 +129,7 @@ public class ReusableParameterizedMessageTest {
@Test
public void testThrowable() {
final String testMsg = "Test message {}";
- ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
+ final ReusableParameterizedMessage msg = new ReusableParameterizedMessage();
final Throwable EXCEPTION1 = new IllegalAccessError("#1");
msg.set(testMsg, "msg", EXCEPTION1);
assertSame(EXCEPTION1, msg.getThrowable());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/132e9489/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java
index bd560b0..3a56b64 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/message/ReusableSimpleMessageTest.java
@@ -27,7 +27,7 @@ public class ReusableSimpleMessageTest {
@Test
public void testSet_InitializesFormattedMessage() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
msg.set("abc");
assertEquals("abc", msg.getFormattedMessage());
}
@@ -39,7 +39,7 @@ public class ReusableSimpleMessageTest {
@Test
public void testGetFormattedMessage_ReturnsLatestSetString() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
msg.set("abc");
assertEquals("abc", msg.getFormattedMessage());
msg.set("def");
@@ -55,7 +55,7 @@ public class ReusableSimpleMessageTest {
@Test
public void testGetFormat_ReturnsLatestSetString() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
msg.set("abc");
assertEquals("abc", msg.getFormat());
msg.set("def");
@@ -71,7 +71,7 @@ public class ReusableSimpleMessageTest {
@Test
public void testGetParameters_ReturnsEmptyArrayAfterMessageSet() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
msg.set("abc");
assertArrayEquals(new Object[0], msg.getParameters());
msg.set("def");
@@ -85,7 +85,7 @@ public class ReusableSimpleMessageTest {
@Test
public void testGetThrowable_ReturnsNullAfterMessageSet() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
msg.set("abc");
assertNull(msg.getThrowable());
msg.set("def");
@@ -94,16 +94,16 @@ public class ReusableSimpleMessageTest {
@Test
public void testFormatTo_InitiallyWritesNull() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
- StringBuilder sb = new StringBuilder();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final StringBuilder sb = new StringBuilder();
msg.formatTo(sb);
assertEquals("null", sb.toString());
}
@Test
public void testFormatTo_WritesLatestSetString() throws Exception {
- ReusableSimpleMessage msg = new ReusableSimpleMessage();
- StringBuilder sb = new StringBuilder();
+ final ReusableSimpleMessage msg = new ReusableSimpleMessage();
+ final StringBuilder sb = new StringBuilder();
msg.formatTo(sb);
assertEquals("null", sb.toString());
sb.setLength(0);
[05/10] logging-log4j2 git commit: Add final modifier to method
parameters.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 4dcd828..7e7c9a9 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
@@ -74,7 +74,7 @@ public class GelfLayoutTest {
Logger root = ctx.getRootLogger();
- private void testCompressedLayout(final CompressionType compressionType, boolean includeStacktrace) throws IOException {
+ private void testCompressedLayout(final CompressionType compressionType, final boolean includeStacktrace) throws IOException {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 d114bb8..5b51e96 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
@@ -44,7 +44,7 @@ import static org.junit.Assert.*;
*/
public class PatternLayoutTest {
public class FauxLogger {
- public String formatEvent(LogEvent event, Layout<?> layout) {
+ public String formatEvent(final LogEvent event, final Layout<?> layout) {
return new String(layout.toByteArray(event));
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 5fb0d74..82f710f 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
@@ -1,65 +1,65 @@
-/*
- * 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 static org.junit.Assert.assertTrue;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-public class PatternSelectorTest {
-
- public class FauxLogger {
- public String formatEvent(LogEvent event, Layout<?> layout) {
- return new String(layout.toByteArray(event));
- }
- }
-
- LoggerContext ctx = LoggerContext.getContext();
-
- @Test
- public void testPatternSelector() throws Exception {
- 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 PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector)
- .withConfiguration(ctx.getConfiguration()).build();
- final LogEvent event1 = Log4jLogEvent.newBuilder() //
- .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.layout.PatternSelectorTest$FauxLogger")
- .setMarker(MarkerManager.getMarker("FLOW"))
- .setLevel(Level.TRACE) //
- .setIncludeLocation(true)
- .setMessage(new SimpleMessage("entry")).build();
- final String result1 = new FauxLogger().formatEvent(event1, layout);
- final String expectSuffix1 = String.format("====== PatternSelectorTest.testPatternSelector:53 entry ======%n");
- assertTrue("Unexpected result: " + result1, result1.endsWith(expectSuffix1));
- final LogEvent event2 = Log4jLogEvent.newBuilder() //
- .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
- .setLevel(Level.INFO) //
- .setMessage(new SimpleMessage("Hello, world 1!")).build();
- final String result2 = new String(layout.toByteArray(event2));
- final String expectSuffix2 = String.format("Hello, world 1!%n");
- assertTrue("Unexpected result: " + result2, result2.endsWith(expectSuffix2));
- }
-
-}
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.junit.Test;
+
+public class PatternSelectorTest {
+
+ public class FauxLogger {
+ public String formatEvent(final LogEvent event, final Layout<?> layout) {
+ return new String(layout.toByteArray(event));
+ }
+ }
+
+ LoggerContext ctx = LoggerContext.getContext();
+
+ @Test
+ public void testPatternSelector() throws Exception {
+ 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 PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector)
+ .withConfiguration(ctx.getConfiguration()).build();
+ final LogEvent event1 = Log4jLogEvent.newBuilder() //
+ .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.layout.PatternSelectorTest$FauxLogger")
+ .setMarker(MarkerManager.getMarker("FLOW"))
+ .setLevel(Level.TRACE) //
+ .setIncludeLocation(true)
+ .setMessage(new SimpleMessage("entry")).build();
+ final String result1 = new FauxLogger().formatEvent(event1, layout);
+ final String expectSuffix1 = String.format("====== PatternSelectorTest.testPatternSelector:53 entry ======%n");
+ assertTrue("Unexpected result: " + result1, result1.endsWith(expectSuffix1));
+ final LogEvent event2 = Log4jLogEvent.newBuilder() //
+ .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
+ .setLevel(Level.INFO) //
+ .setMessage(new SimpleMessage("Hello, world 1!")).build();
+ final String result2 = new String(layout.toByteArray(event2));
+ final String expectSuffix2 = String.format("Hello, world 1!%n");
+ assertTrue("Unexpected result: " + result2, result2.endsWith(expectSuffix2));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java
index 5d8f3b5..b7e7ff8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java
@@ -42,7 +42,7 @@ public class SpyByteBufferDestination implements ByteBufferDestination {
}
}
- public SpyByteBufferDestination(int bufferSize, int destinationSize) {
+ public SpyByteBufferDestination(final int bufferSize, final int destinationSize) {
buffer = ByteBuffer.wrap(new byte[bufferSize]);
drained = ByteBuffer.wrap(new byte[destinationSize]);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
index 3455d30..4a5669c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java
@@ -55,7 +55,7 @@ public class DatePatternConverterTest {
return Arrays.asList(new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}});
}
- public DatePatternConverterTest(Boolean threadLocalEnabled) throws Exception {
+ public DatePatternConverterTest(final Boolean threadLocalEnabled) throws Exception {
// Setting the system property does not work: the Constant field has already been initialized...
//System.setProperty("log4j2.enable.threadlocals", threadLocalEnabled.toString());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java
index 26200eb..ff03b72 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java
@@ -46,7 +46,7 @@ public class EqualsIgnoreCaseReplacementConverterTest {
testReplacement("%logger", "aaa[" + EqualsIgnoreCaseReplacementConverterTest.class.getName() + "]zzz");
}
- private void testReplacement(String tag, String expectedValue) {
+ private void testReplacement(final String tag, final String expectedValue) {
final LogEvent event = Log4jLogEvent.newBuilder() //
.setLoggerName(EqualsIgnoreCaseReplacementConverterTest.class.getName()) //
.setLevel(Level.DEBUG) //
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 c3e064e..69e0ec3 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
@@ -290,7 +290,7 @@ public class PatternParserTest {
testFirstConverter(pattern, ThreadPriorityPatternConverter.class);
}
- private void testFirstConverter(final String pattern, Class<?> checkClass) {
+ private void testFirstConverter(final String pattern, final Class<?> checkClass) {
final List<PatternFormatter> formatters = parser.parse(pattern);
assertNotNull(formatters);
final String msg = formatters.toString();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java
index 15be1ea..dd6f1b6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java
@@ -61,7 +61,7 @@ public class VariablesNotEmptyReplacementConverterTest {
testReplacement("%logger", "[" + VariablesNotEmptyReplacementConverterTest.class.getName() + "]");
}
- private void testReplacement(String tag, String expectedValue) {
+ private void testReplacement(final String tag, final String expectedValue) {
final LogEvent event = Log4jLogEvent.newBuilder() //
.setLoggerName(VariablesNotEmptyReplacementConverterTest.class.getName()) //
.setLevel(Level.DEBUG) //
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 4953ac8..8b98134 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
@@ -79,12 +79,12 @@ public class WatchManagerTest {
private final Queue<File> queue;
- public TestWatcher(Queue<File> queue) {
+ public TestWatcher(final Queue<File> queue) {
this.queue = queue;
}
@Override
- public void fileModified(File file) {
+ public void fileModified(final File file) {
System.out.println(file.toString() + " was modified");
queue.add(file);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 9fc0ece..8c15ef2 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
@@ -122,7 +122,7 @@ public class LoggerContextRule implements TestRule {
* @param cls The target Appender class
* @return the named Appender or {@code null} if it wasn't defined in the configuration.
*/
- public <T extends Appender> T getAppender(final String name, Class<T> cls) {
+ public <T extends Appender> T getAppender(final String name, final Class<T> cls) {
return cls.cast(getConfiguration().getAppenders().get(name));
}
@@ -200,7 +200,7 @@ public class LoggerContextRule implements TestRule {
* @return the named Appender.
* @throws AssertionError if the Appender doesn't exist.
*/
- public <T extends Appender> T getRequiredAppender(final String name, Class<T> cls) {
+ public <T extends Appender> T getRequiredAppender(final String name, final Class<T> cls) {
final T appender = getAppender(name, cls);
assertNotNull("Appender named " + name + " was null.", appender);
return appender;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 c7c07e5..1174174 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
@@ -33,11 +33,11 @@ import java.nio.ByteBuffer;
*/
public class EncodingListAppender extends ListAppender {
- public EncodingListAppender(String name) {
+ public EncodingListAppender(final String name) {
super(name);
}
- public EncodingListAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean newline, boolean raw) {
+ public EncodingListAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean newline, final boolean raw) {
super(name, filter, layout, newline, raw);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java
index fb767b0..f81d3fa 100644
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java
@@ -126,7 +126,7 @@ public abstract class AbstractLoggerTest {
testMessage("message{%s}");
}
- private void testMessage(String string) {
+ private void testMessage(final String string) {
final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
root.info("Test info " + string);
root.config("Test info " + string);
@@ -173,7 +173,7 @@ public abstract class AbstractLoggerTest {
testLambdaMessages("message{%s}");
}
- private void testLambdaMessages(String string) {
+ private void testLambdaMessages(final String string) {
// TODO FOR JAVA 8
// final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
// root.info(() -> "Test info " + string);
[09/10] logging-log4j2 git commit: Add final modifier to method
parameters.
Posted by gg...@apache.org.
Add final modifier to method parameters.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7a5dcd43
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7a5dcd43
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7a5dcd43
Branch: refs/heads/master
Commit: 7a5dcd43d559971caf3f00c55586f372ca4d9046
Parents: fe22ab8
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 10:05:18 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 10:05:18 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/Logger.java | 2 +-
.../logging/log4j/core/LoggerContext.java | 4 +-
.../log4j/core/appender/AbstractManager.java | 8 +-
.../log4j/core/appender/AsyncAppender.java | 2 +-
.../log4j/core/appender/ConsoleAppender.java | 2 +-
.../core/appender/CountingNoOpAppender.java | 4 +-
.../core/appender/OutputStreamManager.java | 4 +-
.../log4j/core/appender/SocketAppender.java | 2 +-
.../appender/rolling/CronTriggeringPolicy.java | 6 +-
.../rolling/DefaultRolloverStrategy.java | 6 +-
.../log4j/core/appender/rolling/FileSize.java | 180 ++---
.../core/appender/rolling/action/Duration.java | 514 +++++++-------
.../core/appender/rolling/action/IfAll.java | 232 +++----
.../core/appender/routing/IdlePurgePolicy.java | 8 +-
.../core/appender/routing/RoutingAppender.java | 4 +-
.../logging/log4j/core/async/AsyncLogger.java | 4 +-
.../core/async/AsyncLoggerConfigDisruptor.java | 2 +-
.../log4j/core/async/AsyncLoggerContext.java | 4 +-
.../log4j/core/async/AsyncLoggerDisruptor.java | 472 ++++++-------
.../log4j/core/async/RingBufferLogEvent.java | 10 +-
.../core/config/AbstractConfiguration.java | 8 +-
.../AwaitCompletionReliabilityStrategy.java | 350 +++++-----
...AwaitUnconditionallyReliabilityStrategy.java | 246 +++----
.../log4j/core/config/ConfigurationFactory.java | 2 +-
.../core/config/ConfigurationScheduler.java | 16 +-
.../core/config/ConfiguratonFileWatcher.java | 4 +-
.../logging/log4j/core/config/Configurator.java | 688 +++++++++----------
.../core/config/DefaultReliabilityStrategy.java | 214 +++---
.../core/config/LockingReliabilityStrategy.java | 270 ++++----
.../impl/DefaultConfigurationBuilder.java | 20 +-
.../impl/DefaultLoggerComponentBuilder.java | 4 +-
.../impl/DefaultScriptFileComponentBuilder.java | 8 +-
.../composite/CompositeConfiguration.java | 6 +-
.../config/composite/DefaultMergeStrategy.java | 16 +-
.../properties/PropertiesConfiguration.java | 2 +-
.../PropertiesConfigurationBuilder.java | 2 +-
.../log4j/core/config/xml/XmlConfiguration.java | 2 +-
.../core/filter/DynamicThresholdFilter.java | 2 +-
.../logging/log4j/core/impl/Log4jLogEvent.java | 32 +-
.../log4j/core/impl/MutableLogEvent.java | 30 +-
.../log4j/core/layout/AbstractStringLayout.java | 2 +-
.../logging/log4j/core/layout/GelfLayout.java | 4 +-
.../log4j/core/layout/JacksonFactory.java | 4 +-
.../core/layout/MarkerPatternSelector.java | 2 +-
.../core/layout/ScriptPatternSelector.java | 4 +-
.../log4j/core/layout/TextEncoderHelper.java | 2 +-
.../logging/log4j/core/net/SmtpManager.java | 4 +-
.../log4j/core/net/TcpSocketManager.java | 2 +-
.../pattern/EqualsReplacementConverter.java | 2 +-
.../log4j/core/pattern/NameAbbreviator.java | 4 +-
.../logging/log4j/core/script/Script.java | 2 +-
.../logging/log4j/core/script/ScriptFile.java | 2 +-
.../log4j/core/script/ScriptManager.java | 2 +-
.../logging/log4j/core/script/ScriptRef.java | 4 +-
.../logging/log4j/core/util/CronExpression.java | 48 +-
.../logging/log4j/core/util/DummyNanoClock.java | 96 +--
.../core/util/ExtensionLanguageMapping.java | 6 +-
.../logging/log4j/core/util/FileUtils.java | 2 +-
.../logging/log4j/core/util/JsonUtils.java | 6 +-
.../logging/log4j/core/util/StringEncoder.java | 6 +-
.../logging/log4j/core/util/WatchManager.java | 10 +-
.../core/util/datetime/FixedDateFormat.java | 686 +++++++++---------
.../core/GcFreeAsynchronousLoggingTest.java | 2 +-
.../log4j/core/GcFreeLoggingTestUtil.java | 4 +-
.../core/GcFreeMixedSyncAyncLoggingTest.java | 2 +-
.../core/GcFreeSynchronousLoggingTest.java | 2 +-
.../AsyncAppenderQueueFullPolicyTest.java | 2 +-
.../appender/mom/kafka/KafkaAppenderTest.java | 292 ++++----
.../RollingAppenderCustomDeleteActionTest.java | 2 +-
...lingAppenderDeleteAccumulatedCount1Test.java | 4 +-
...lingAppenderDeleteAccumulatedCount2Test.java | 4 +-
.../RollingAppenderDeleteMaxDepthTest.java | 4 +-
.../RollingAppenderDeleteNestedTest.java | 4 +-
...ollingAppenderNoUnconditionalDeleteTest.java | 2 +-
.../rolling/action/CountingCondition.java | 124 ++--
.../rolling/action/DeleteActionTest.java | 238 +++----
.../rolling/action/DeletingVisitorTest.java | 270 ++++----
.../appender/rolling/action/FixedCondition.java | 88 +--
.../action/PathSortByModificationTimeTest.java | 186 ++---
.../routing/RoutingAppenderWithPurgingTest.java | 2 +-
.../core/async/perftest/PerfTestDriver.java | 4 +-
.../core/async/perftest/ResponseTimeTest.java | 18 +-
.../core/async/perftest/SimplePerfTest.java | 2 +-
.../core/config/CompositeConfigurationTest.java | 2 +-
.../log4j/core/config/ConfiguratorTest.java | 94 +--
.../builder/ConfigurationAssemblerTest.java | 2 +-
.../builder/CustomConfigurationFactory.java | 4 +-
.../core/filter/AbstractFilterableTest.java | 4 +-
.../log4j/core/impl/Log4jLogEventTest.java | 6 +-
.../log4j/core/impl/ThrowableProxyTest.java | 2 +-
.../core/layout/CsvLogEventLayoutTest.java | 2 +-
.../core/layout/CsvParameterLayoutTest.java | 2 +-
.../log4j/core/layout/GelfLayoutTest.java | 2 +-
.../log4j/core/layout/PatternLayoutTest.java | 2 +-
.../log4j/core/layout/PatternSelectorTest.java | 130 ++--
.../core/layout/SpyByteBufferDestination.java | 2 +-
.../core/pattern/DatePatternConverterTest.java | 2 +-
...qualsIgnoreCaseReplacementConverterTest.java | 2 +-
.../log4j/core/pattern/PatternParserTest.java | 2 +-
...riablesNotEmptyReplacementConverterTest.java | 2 +-
.../log4j/core/util/WatchManagerTest.java | 4 +-
.../logging/log4j/junit/LoggerContextRule.java | 4 +-
.../test/appender/EncodingListAppender.java | 4 +-
.../logging/log4j/jul/AbstractLoggerTest.java | 4 +-
104 files changed, 2913 insertions(+), 2913 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 d08dd8a..99f4207 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
@@ -632,7 +632,7 @@ public class Logger extends AbstractLogger implements Supplier<LoggerConfig> {
private final String name;
private final MessageFactory messageFactory;
- public LoggerProxy(String name, MessageFactory messageFactory) {
+ public LoggerProxy(final String name, final MessageFactory messageFactory) {
this.name = name;
this.messageFactory = messageFactory;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 82a6de8..fea1975 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -424,7 +424,7 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
* @return True if the Logger exists, false otherwise.
*/
@Override
- public boolean hasLogger(final String name, MessageFactory messageFactory) {
+ public boolean hasLogger(final String name, final MessageFactory messageFactory) {
return loggerRegistry.hasLogger(name, messageFactory);
}
@@ -435,7 +435,7 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
* @return True if the Logger exists, false otherwise.
*/
@Override
- public boolean hasLogger(final 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/7a5dcd43/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 45f5141..fd15f17 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
@@ -150,21 +150,21 @@ public abstract class AbstractManager {
return new HashMap<>();
}
- protected void log(Level level, String message, Throwable throwable) {
+ protected void log(final Level level, final String message, final Throwable throwable) {
Message m = LOGGER.getMessageFactory().newMessage("{} {} {}: {}",
getClass().getSimpleName(), getName(), message, throwable);
LOGGER.log(level, m, throwable);
}
- protected void logDebug(String message, Throwable throwable) {
+ protected void logDebug(final String message, final Throwable throwable) {
log(Level.DEBUG, message, throwable);
}
- protected void logError(String message, Throwable throwable) {
+ protected void logError(final String message, final Throwable throwable) {
log(Level.ERROR, message, throwable);
}
- protected void logWarn(String message, Throwable throwable) {
+ protected void logWarn(final String message, final Throwable throwable) {
log(Level.WARN, message, throwable);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
index 83afd92..0abb07e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
@@ -141,7 +141,7 @@ public final class AsyncAppender extends AbstractAppender {
* @param logEvent The LogEvent.
*/
@Override
- public void append(LogEvent logEvent) {
+ public void append(final LogEvent logEvent) {
if (!isStarted()) {
throw new IllegalStateException("AsyncAppender " + getName() + " is not active");
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
index 4e1e87c..0eb05d8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
@@ -69,7 +69,7 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender<OutputSt
}
private ConsoleAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
- final OutputStreamManager manager, final boolean ignoreExceptions, Target target) {
+ final OutputStreamManager manager, final boolean ignoreExceptions, final Target target) {
super(name, layout, filter, ignoreExceptions, true, manager);
this.target = target;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
index 8164aea..38775eb 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
@@ -33,7 +33,7 @@ public class CountingNoOpAppender extends AbstractAppender {
private final AtomicLong total = new AtomicLong();
- public CountingNoOpAppender(String name, Layout<?> layout) {
+ public CountingNoOpAppender(final String name, final Layout<?> layout) {
super(name, null, layout);
}
@@ -42,7 +42,7 @@ public class CountingNoOpAppender extends AbstractAppender {
}
@Override
- public void append(LogEvent event) {
+ public void append(final LogEvent event) {
total.incrementAndGet();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
index 20ef401..5e3ae5d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
@@ -143,7 +143,7 @@ public class OutputStreamManager extends AbstractManager implements ByteBufferDe
* @param immediateFlush If true, flushes after writing.
* @throws AppenderLoggingException if an error occurs.
*/
- protected void write(final byte[] bytes, boolean immediateFlush) {
+ protected void write(final byte[] bytes, final boolean immediateFlush) {
write(bytes, 0, bytes.length, immediateFlush);
}
@@ -168,7 +168,7 @@ public class OutputStreamManager extends AbstractManager implements ByteBufferDe
* @param immediateFlush flushes immediately after writing.
* @throws AppenderLoggingException if an error occurs.
*/
- protected synchronized void write(final byte[] bytes, final int offset, final int length, boolean immediateFlush) {
+ protected synchronized void write(final byte[] bytes, final int offset, final int length, final boolean immediateFlush) {
if (immediateFlush && byteBuffer.position() == 0) {
writeToDestination(bytes, offset, length);
flushDestination();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 1a542db..c49ed46 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
@@ -199,7 +199,7 @@ public class SocketAppender extends AbstractOutputStreamAppender<AbstractSocketM
final String name,
final String immediateFlush,
final String ignore,
- Layout<? extends Serializable> layout,
+ final Layout<? extends Serializable> layout,
final Filter filter,
final String advertise,
final Configuration config) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 b45d6e0..b4d1b1b 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
@@ -44,7 +44,7 @@ public final class CronTriggeringPolicy implements TriggeringPolicy {
private final Configuration configuration;
private final boolean checkOnStartup;
- private CronTriggeringPolicy(CronExpression schedule, boolean checkOnStartup, Configuration configuration) {
+ private CronTriggeringPolicy(final CronExpression schedule, final boolean checkOnStartup, final Configuration configuration) {
this.cronExpression = schedule;
this.configuration = configuration;
this.checkOnStartup = checkOnStartup;
@@ -89,7 +89,7 @@ public final class CronTriggeringPolicy implements TriggeringPolicy {
*/
@PluginFactory
public static CronTriggeringPolicy createPolicy(
- @PluginConfiguration Configuration configuration,
+ @PluginConfiguration final Configuration configuration,
@PluginAttribute("evaluateOnStartup") final String evaluateOnStartup,
@PluginAttribute("schedule") final String schedule) {
CronExpression cronExpression;
@@ -107,7 +107,7 @@ public final class CronTriggeringPolicy implements TriggeringPolicy {
return new CronTriggeringPolicy(cronExpression, checkOnStartup, configuration);
}
- private static CronExpression getSchedule(String expression) {
+ private static CronExpression getSchedule(final String expression) {
try {
return new CronExpression(expression);
} catch (ParseException pe) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 547cc3e..6097586 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
@@ -131,7 +131,7 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
}
};
- static FileExtensions lookup(String fileExtension) {
+ static FileExtensions lookup(final String fileExtension) {
for (FileExtensions ext : values()) {
if (ext.isExtensionFor(fileExtension)) {
return ext;
@@ -162,11 +162,11 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
return extension.length();
}
- File source(String fileName) {
+ File source(final String fileName) {
return new File(fileName);
}
- File target(String fileName) {
+ File target(final String fileName) {
return new File(fileName);
}
};
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileSize.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileSize.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileSize.java
index e134b1f..08e6b9e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileSize.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileSize.java
@@ -1,90 +1,90 @@
-/*
- * 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;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * FileSize utility class.
- */
-public final class FileSize {
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final long KB = 1024;
- private static final long MB = KB * KB;
- private static final long GB = KB * MB;
-
- /**
- * Pattern for string parsing.
- */
- private static final Pattern VALUE_PATTERN =
- Pattern.compile("([0-9]+([\\.,][0-9]+)?)\\s*(|K|M|G)B?", Pattern.CASE_INSENSITIVE);
-
- private FileSize() {
- }
-
- /**
- * Converts a string to a number of bytes. Strings consist of a floating point value followed by
- * K, M, or G for kilobytes, megabytes, gigabytes, respectively. The
- * abbreviations KB, MB, and GB are also accepted. Matching is case insensitive.
- *
- * @param string The string to convert
- * @return The Bytes value for the string
- */
- public static long parse(final String string, long defaultValue) {
- final Matcher matcher = VALUE_PATTERN.matcher(string);
-
- // Valid input?
- if (matcher.matches()) {
- try {
- // Get double precision value
- final long value = NumberFormat.getNumberInstance(Locale.getDefault()).parse(
- matcher.group(1)).longValue();
-
- // Get units specified
- final String units = matcher.group(3);
-
- if (units.isEmpty()) {
- return value;
- } else if (units.equalsIgnoreCase("K")) {
- return value * KB;
- } else if (units.equalsIgnoreCase("M")) {
- return value * MB;
- } else if (units.equalsIgnoreCase("G")) {
- return value * GB;
- } else {
- LOGGER.error("FileSize units not recognized: " + string);
- return defaultValue;
- }
- } catch (final ParseException e) {
- LOGGER.error("FileSize unable to parse numeric part: " + string, e);
- return defaultValue;
- }
- }
- LOGGER.error("FileSize unable to parse bytes: " + string);
- return defaultValue;
- }
-
-}
+/*
+ * 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;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+/**
+ * FileSize utility class.
+ */
+public final class FileSize {
+ private static final Logger LOGGER = StatusLogger.getLogger();
+
+ private static final long KB = 1024;
+ private static final long MB = KB * KB;
+ private static final long GB = KB * MB;
+
+ /**
+ * Pattern for string parsing.
+ */
+ private static final Pattern VALUE_PATTERN =
+ Pattern.compile("([0-9]+([\\.,][0-9]+)?)\\s*(|K|M|G)B?", Pattern.CASE_INSENSITIVE);
+
+ private FileSize() {
+ }
+
+ /**
+ * Converts a string to a number of bytes. Strings consist of a floating point value followed by
+ * K, M, or G for kilobytes, megabytes, gigabytes, respectively. The
+ * abbreviations KB, MB, and GB are also accepted. Matching is case insensitive.
+ *
+ * @param string The string to convert
+ * @return The Bytes value for the string
+ */
+ public static long parse(final String string, final long defaultValue) {
+ final Matcher matcher = VALUE_PATTERN.matcher(string);
+
+ // Valid input?
+ if (matcher.matches()) {
+ try {
+ // Get double precision value
+ final long value = NumberFormat.getNumberInstance(Locale.getDefault()).parse(
+ matcher.group(1)).longValue();
+
+ // Get units specified
+ final String units = matcher.group(3);
+
+ if (units.isEmpty()) {
+ return value;
+ } else if (units.equalsIgnoreCase("K")) {
+ return value * KB;
+ } else if (units.equalsIgnoreCase("M")) {
+ return value * MB;
+ } else if (units.equalsIgnoreCase("G")) {
+ return value * GB;
+ } else {
+ LOGGER.error("FileSize units not recognized: " + string);
+ return defaultValue;
+ }
+ } catch (final ParseException e) {
+ LOGGER.error("FileSize unable to parse numeric part: " + string, e);
+ return defaultValue;
+ }
+ }
+ LOGGER.error("FileSize unable to parse bytes: " + string);
+ return defaultValue;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 8508f03..a5103f7 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
@@ -1,257 +1,257 @@
-/*
- * 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.io.Serializable;
-import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Simplified implementation of the <a href="https://en.wikipedia.org/wiki/ISO_8601#Durations">ISO-8601 Durations</a>
- * standard. The supported format is {@code PnDTnHnMnS}, with 'P' and 'T' optional. Days are considered to be exactly 24
- * hours.
- * <p>
- * Similarly to the {@code java.time.Duration} class, this class does not support year or month sections in the format.
- * This implementation does not support fractions or negative values.
- *
- * @see #parse(CharSequence)
- */
-public class Duration implements Serializable, Comparable<Duration> {
- private static final long serialVersionUID = -3756810052716342061L;
-
- /**
- * Constant for a duration of zero.
- */
- public static final Duration ZERO = new Duration(0);
-
- /**
- * Hours per day.
- */
- private static final int HOURS_PER_DAY = 24;
- /**
- * Minutes per hour.
- */
- private static final int MINUTES_PER_HOUR = 60;
- /**
- * Seconds per minute.
- */
- private static final int SECONDS_PER_MINUTE = 60;
- /**
- * Seconds per hour.
- */
- private static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
- /**
- * Seconds per day.
- */
- private static final int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
-
- /**
- * The pattern for parsing.
- */
- private static final Pattern PATTERN = Pattern.compile("P?(?:([0-9]+)D)?"
- + "(T?(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+)?S)?)?", Pattern.CASE_INSENSITIVE);
-
- /**
- * The number of seconds in the duration.
- */
- private final long seconds;
-
- /**
- * Constructs an instance of {@code Duration} using seconds.
- *
- * @param seconds the length of the duration in seconds, positive or negative
- */
- private Duration(long seconds) {
- super();
- this.seconds = seconds;
- }
-
- /**
- * Obtains a {@code Duration} from a text string such as {@code PnDTnHnMnS}.
- * <p>
- * This will parse a textual representation of a duration, including the string produced by {@code toString()}. The
- * formats accepted are based on the ISO-8601 duration format {@code PnDTnHnMnS} with days considered to be exactly
- * 24 hours.
- * <p>
- * This implementation does not support negative numbers or fractions (so the smallest non-zero value a Duration can
- * have is one second).
- * <p>
- * The string optionally starts with the ASCII letter "P" in upper or lower case. There are then four sections, each
- * consisting of a number and a suffix. The sections have suffixes in ASCII of "D", "H", "M" and "S" for days,
- * hours, minutes and seconds, accepted in upper or lower case. The suffixes must occur in order. The ASCII letter
- * "T" may occur before the first occurrence, if any, of an hour, minute or second section. At least one of the four
- * sections must be present, and if "T" is present there must be at least one section after the "T". The number part
- * of each section must consist of one or more ASCII digits. The number may not be prefixed by the ASCII negative or
- * positive symbol. The number of days, hours, minutes and seconds must parse to a {@code long}.
- * <p>
- * Examples:
- *
- * <pre>
- * "PT20S" -- parses as "20 seconds"
- * "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds)
- * "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds)
- * "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
- * "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes"
- * </pre>
- *
- * @param text the text to parse, not null
- * @return the parsed duration, not null
- * @throws IllegalArgumentException if the text cannot be parsed to a duration
- */
- public static Duration parse(CharSequence text) {
- Objects.requireNonNull(text, "text");
- 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);
- 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");
- try {
- return create(daysAsSecs, hoursAsSecs, minsAsSecs, seconds);
- } catch (ArithmeticException ex) {
- throw new IllegalArgumentException("Text cannot be parsed to a Duration (overflow) " + text, ex);
- }
- }
- }
- }
- throw new IllegalArgumentException("Text cannot be parsed to a Duration: " + text);
- }
-
- private static long parseNumber(final CharSequence text, final String parsed, final int multiplier,
- final String errorText) {
- // regex limits to [0-9]+
- if (parsed == null) {
- return 0;
- }
- try {
- final long val = Long.parseLong(parsed);
- return val * multiplier;
- } catch (final Exception ex) {
- throw new IllegalArgumentException("Text cannot be parsed to a Duration: " + errorText + " (in " + text
- + ")", ex);
- }
- }
-
- private static Duration create(final long daysAsSecs, final long hoursAsSecs, final long minsAsSecs, final long secs) {
- return create(daysAsSecs + hoursAsSecs + minsAsSecs + secs);
- }
-
- /**
- * Obtains an instance of {@code Duration} using seconds.
- *
- * @param seconds the length of the duration in seconds, positive only
- */
- private static Duration create(final long seconds) {
- if ((seconds) == 0) {
- return ZERO;
- }
- return new Duration(seconds);
- }
-
- /**
- * Converts this duration to the total length in milliseconds.
- *
- * @return the total length of the duration in milliseconds
- */
- public long toMillis() {
- return seconds * 1000L;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof Duration)) {
- return false;
- }
- Duration other = (Duration) obj;
- return other.seconds == this.seconds;
- }
-
- @Override
- public int hashCode() {
- return (int) (seconds ^ (seconds >>> 32));
- }
-
- /**
- * A string representation of this duration using ISO-8601 seconds based representation, such as {@code PT8H6M12S}.
- * <p>
- * The format of the returned string will be {@code PnDTnHnMnS}, where n is the relevant days, hours, minutes or
- * seconds part of the duration. If a section has a zero value, it is omitted. The hours, minutes and seconds are
- * all positive.
- * <p>
- * Examples:
- *
- * <pre>
- * "20 seconds" -- "PT20S
- * "15 minutes" (15 * 60 seconds) -- "PT15M"
- * "10 hours" (10 * 3600 seconds) -- "PT10H"
- * "2 days" (2 * 86400 seconds) -- "P2D"
- * </pre>
- *
- * @return an ISO-8601 representation of this duration, not null
- */
- @Override
- public String toString() {
- if (this == ZERO) {
- return "PT0S";
- }
- final long days = seconds / SECONDS_PER_DAY;
- final long hours = (seconds % SECONDS_PER_DAY) / SECONDS_PER_HOUR;
- final int minutes = (int) ((seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE);
- final int secs = (int) (seconds % SECONDS_PER_MINUTE);
- final StringBuilder buf = new StringBuilder(24);
- buf.append("P");
- if (days != 0) {
- buf.append(days).append('D');
- }
- if ((hours | minutes | secs) != 0) {
- buf.append('T');
- }
- if (hours != 0) {
- buf.append(hours).append('H');
- }
- if (minutes != 0) {
- buf.append(minutes).append('M');
- }
- if (secs == 0 && buf.length() > 0) {
- return buf.toString();
- }
- buf.append(secs).append('S');
- return buf.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(Duration other) {
- return Long.signum(toMillis() - other.toMillis());
- }
-}
+/*
+ * 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.io.Serializable;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Simplified implementation of the <a href="https://en.wikipedia.org/wiki/ISO_8601#Durations">ISO-8601 Durations</a>
+ * standard. The supported format is {@code PnDTnHnMnS}, with 'P' and 'T' optional. Days are considered to be exactly 24
+ * hours.
+ * <p>
+ * Similarly to the {@code java.time.Duration} class, this class does not support year or month sections in the format.
+ * This implementation does not support fractions or negative values.
+ *
+ * @see #parse(CharSequence)
+ */
+public class Duration implements Serializable, Comparable<Duration> {
+ private static final long serialVersionUID = -3756810052716342061L;
+
+ /**
+ * Constant for a duration of zero.
+ */
+ public static final Duration ZERO = new Duration(0);
+
+ /**
+ * Hours per day.
+ */
+ private static final int HOURS_PER_DAY = 24;
+ /**
+ * Minutes per hour.
+ */
+ private static final int MINUTES_PER_HOUR = 60;
+ /**
+ * Seconds per minute.
+ */
+ private static final int SECONDS_PER_MINUTE = 60;
+ /**
+ * Seconds per hour.
+ */
+ private static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
+ /**
+ * Seconds per day.
+ */
+ private static final int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
+
+ /**
+ * The pattern for parsing.
+ */
+ private static final Pattern PATTERN = Pattern.compile("P?(?:([0-9]+)D)?"
+ + "(T?(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+)?S)?)?", Pattern.CASE_INSENSITIVE);
+
+ /**
+ * The number of seconds in the duration.
+ */
+ private final long seconds;
+
+ /**
+ * Constructs an instance of {@code Duration} using seconds.
+ *
+ * @param seconds the length of the duration in seconds, positive or negative
+ */
+ private Duration(final long seconds) {
+ super();
+ this.seconds = seconds;
+ }
+
+ /**
+ * Obtains a {@code Duration} from a text string such as {@code PnDTnHnMnS}.
+ * <p>
+ * This will parse a textual representation of a duration, including the string produced by {@code toString()}. The
+ * formats accepted are based on the ISO-8601 duration format {@code PnDTnHnMnS} with days considered to be exactly
+ * 24 hours.
+ * <p>
+ * This implementation does not support negative numbers or fractions (so the smallest non-zero value a Duration can
+ * have is one second).
+ * <p>
+ * The string optionally starts with the ASCII letter "P" in upper or lower case. There are then four sections, each
+ * consisting of a number and a suffix. The sections have suffixes in ASCII of "D", "H", "M" and "S" for days,
+ * hours, minutes and seconds, accepted in upper or lower case. The suffixes must occur in order. The ASCII letter
+ * "T" may occur before the first occurrence, if any, of an hour, minute or second section. At least one of the four
+ * sections must be present, and if "T" is present there must be at least one section after the "T". The number part
+ * of each section must consist of one or more ASCII digits. The number may not be prefixed by the ASCII negative or
+ * positive symbol. The number of days, hours, minutes and seconds must parse to a {@code long}.
+ * <p>
+ * Examples:
+ *
+ * <pre>
+ * "PT20S" -- parses as "20 seconds"
+ * "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds)
+ * "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds)
+ * "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+ * "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes"
+ * </pre>
+ *
+ * @param text the text to parse, not null
+ * @return the parsed duration, not null
+ * @throws IllegalArgumentException if the text cannot be parsed to a duration
+ */
+ public static Duration parse(final CharSequence text) {
+ Objects.requireNonNull(text, "text");
+ 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);
+ 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");
+ try {
+ return create(daysAsSecs, hoursAsSecs, minsAsSecs, seconds);
+ } catch (ArithmeticException ex) {
+ throw new IllegalArgumentException("Text cannot be parsed to a Duration (overflow) " + text, ex);
+ }
+ }
+ }
+ }
+ throw new IllegalArgumentException("Text cannot be parsed to a Duration: " + text);
+ }
+
+ private static long parseNumber(final CharSequence text, final String parsed, final int multiplier,
+ final String errorText) {
+ // regex limits to [0-9]+
+ if (parsed == null) {
+ return 0;
+ }
+ try {
+ final long val = Long.parseLong(parsed);
+ return val * multiplier;
+ } catch (final Exception ex) {
+ throw new IllegalArgumentException("Text cannot be parsed to a Duration: " + errorText + " (in " + text
+ + ")", ex);
+ }
+ }
+
+ private static Duration create(final long daysAsSecs, final long hoursAsSecs, final long minsAsSecs, final long secs) {
+ return create(daysAsSecs + hoursAsSecs + minsAsSecs + secs);
+ }
+
+ /**
+ * Obtains an instance of {@code Duration} using seconds.
+ *
+ * @param seconds the length of the duration in seconds, positive only
+ */
+ private static Duration create(final long seconds) {
+ if ((seconds) == 0) {
+ return ZERO;
+ }
+ return new Duration(seconds);
+ }
+
+ /**
+ * Converts this duration to the total length in milliseconds.
+ *
+ * @return the total length of the duration in milliseconds
+ */
+ public long toMillis() {
+ return seconds * 1000L;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof Duration)) {
+ return false;
+ }
+ Duration other = (Duration) obj;
+ return other.seconds == this.seconds;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) (seconds ^ (seconds >>> 32));
+ }
+
+ /**
+ * A string representation of this duration using ISO-8601 seconds based representation, such as {@code PT8H6M12S}.
+ * <p>
+ * The format of the returned string will be {@code PnDTnHnMnS}, where n is the relevant days, hours, minutes or
+ * seconds part of the duration. If a section has a zero value, it is omitted. The hours, minutes and seconds are
+ * all positive.
+ * <p>
+ * Examples:
+ *
+ * <pre>
+ * "20 seconds" -- "PT20S
+ * "15 minutes" (15 * 60 seconds) -- "PT15M"
+ * "10 hours" (10 * 3600 seconds) -- "PT10H"
+ * "2 days" (2 * 86400 seconds) -- "P2D"
+ * </pre>
+ *
+ * @return an ISO-8601 representation of this duration, not null
+ */
+ @Override
+ public String toString() {
+ if (this == ZERO) {
+ return "PT0S";
+ }
+ final long days = seconds / SECONDS_PER_DAY;
+ final long hours = (seconds % SECONDS_PER_DAY) / SECONDS_PER_HOUR;
+ final int minutes = (int) ((seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE);
+ final int secs = (int) (seconds % SECONDS_PER_MINUTE);
+ final StringBuilder buf = new StringBuilder(24);
+ buf.append("P");
+ if (days != 0) {
+ buf.append(days).append('D');
+ }
+ if ((hours | minutes | secs) != 0) {
+ buf.append('T');
+ }
+ if (hours != 0) {
+ buf.append(hours).append('H');
+ }
+ if (minutes != 0) {
+ buf.append(minutes).append('M');
+ }
+ if (secs == 0 && buf.length() > 0) {
+ return buf.toString();
+ }
+ buf.append(secs).append('S');
+ return buf.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final Duration other) {
+ return Long.signum(toMillis() - other.toMillis());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 627a082..9591804 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
@@ -1,116 +1,116 @@
-/*
- * 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 only accepts objects that are accepted by <em>all</em> component conditions.
- * Corresponds to logical "AND".
- */
-@Plugin(name = "IfAll", category = "Core", printObject = true)
-public final class IfAll implements PathCondition {
-
- private final PathCondition[] components;
-
- private IfAll(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) {
- if (components == null || components.length == 0) {
- return false; // unconditional delete not supported
- }
- return accept(components, baseDir, relativePath, attrs);
- }
-
- /**
- * Returns {@code true} if all the specified conditions accept the specified path, {@code false} otherwise.
- *
- * @param list the array of conditions to evaluate
- * @param baseDir the directory from where to start scanning for deletion candidate files
- * @param relativePath the candidate for deletion. This path is relative to the baseDir.
- * @param attrs attributes of the candidate path
- * @return {@code true} if all the specified conditions accept the specified path, {@code false} otherwise
- * @throws NullPointerException if any of the parameters is {@code null}
- */
- public static boolean accept(final PathCondition[] list, final Path baseDir, final Path relativePath,
- final BasicFileAttributes attrs) {
- for (final PathCondition component : list) {
- if (!component.accept(baseDir, relativePath, attrs)) {
- return false;
- }
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
- */
- @Override
- public void beforeFileTreeWalk() {
- beforeFileTreeWalk(components);
- }
-
- /**
- * Calls {@link #beforeFileTreeWalk()} on all of the specified nested conditions.
- *
- * @param nestedConditions the conditions to call {@link #beforeFileTreeWalk()} on
- */
- public static void beforeFileTreeWalk(PathCondition[] nestedConditions) {
- for (PathCondition condition : nestedConditions) {
- condition.beforeFileTreeWalk();
- }
- }
-
- /**
- * Create a Composite PathCondition whose components all need to accept before this condition accepts.
- *
- * @param components The component filters.
- * @return A Composite PathCondition.
- */
- @PluginFactory
- public static IfAll createAndCondition( //
- @PluginElement("PathConditions") final PathCondition... components) {
- return new IfAll(components);
- }
-
- @Override
- public String toString() {
- return "IfAll" + 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 only accepts objects that are accepted by <em>all</em> component conditions.
+ * Corresponds to logical "AND".
+ */
+@Plugin(name = "IfAll", category = "Core", printObject = true)
+public final class IfAll implements PathCondition {
+
+ private final PathCondition[] components;
+
+ private IfAll(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) {
+ if (components == null || components.length == 0) {
+ return false; // unconditional delete not supported
+ }
+ return accept(components, baseDir, relativePath, attrs);
+ }
+
+ /**
+ * Returns {@code true} if all the specified conditions accept the specified path, {@code false} otherwise.
+ *
+ * @param list the array of conditions to evaluate
+ * @param baseDir the directory from where to start scanning for deletion candidate files
+ * @param relativePath the candidate for deletion. This path is relative to the baseDir.
+ * @param attrs attributes of the candidate path
+ * @return {@code true} if all the specified conditions accept the specified path, {@code false} otherwise
+ * @throws NullPointerException if any of the parameters is {@code null}
+ */
+ public static boolean accept(final PathCondition[] list, final Path baseDir, final Path relativePath,
+ final BasicFileAttributes attrs) {
+ for (final PathCondition component : list) {
+ if (!component.accept(baseDir, relativePath, attrs)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
+ */
+ @Override
+ public void beforeFileTreeWalk() {
+ beforeFileTreeWalk(components);
+ }
+
+ /**
+ * Calls {@link #beforeFileTreeWalk()} on all of the specified nested conditions.
+ *
+ * @param nestedConditions the conditions to call {@link #beforeFileTreeWalk()} on
+ */
+ public static void beforeFileTreeWalk(final PathCondition[] nestedConditions) {
+ for (PathCondition condition : nestedConditions) {
+ condition.beforeFileTreeWalk();
+ }
+ }
+
+ /**
+ * Create a Composite PathCondition whose components all need to accept before this condition accepts.
+ *
+ * @param components The component filters.
+ * @return A Composite PathCondition.
+ */
+ @PluginFactory
+ public static IfAll createAndCondition( //
+ @PluginElement("PathConditions") final PathCondition... components) {
+ return new IfAll(components);
+ }
+
+ @Override
+ public String toString() {
+ return "IfAll" + Arrays.toString(components);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 953f1bc..e9e7469 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
@@ -48,13 +48,13 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
private final ConfigurationScheduler scheduler;
private volatile ScheduledFuture<?> future = null;
- public IdlePurgePolicy(long timeToLive, ConfigurationScheduler scheduler) {
+ public IdlePurgePolicy(final long timeToLive, final ConfigurationScheduler scheduler) {
this.timeToLive = timeToLive;
this.scheduler = scheduler;
}
@Override
- public void initialize(RoutingAppender routingAppender) {
+ public void initialize(final RoutingAppender routingAppender) {
this.routingAppender = routingAppender;
}
@@ -80,7 +80,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
}
@Override
- public void update(String key, LogEvent event) {
+ public void update(final String key, final LogEvent event) {
long now = System.currentTimeMillis();
appendersUsage.put(key, now);
if (future == null) {
@@ -123,7 +123,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
public static PurgePolicy createPurgePolicy(
@PluginAttribute("timeToLive") final String timeToLive,
@PluginAttribute("timeUnit") final String timeUnit,
- @PluginConfiguration Configuration configuration) {
+ @PluginConfiguration final Configuration configuration) {
if (timeToLive == null) {
LOGGER.error("A timeToLive value is required");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 a6b5df0..02f2d33 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
@@ -55,7 +55,7 @@ public final class RoutingAppender extends AbstractAppender {
private final PurgePolicy purgePolicy;
private RoutingAppender(final String name, final Filter filter, final boolean ignoreExceptions, final Routes routes,
- final RewritePolicy rewritePolicy, final Configuration config, PurgePolicy purgePolicy) {
+ final RewritePolicy rewritePolicy, final Configuration config, final PurgePolicy purgePolicy) {
super(name, filter, null, ignoreExceptions);
this.routes = routes;
this.config = config;
@@ -181,7 +181,7 @@ public final class RoutingAppender extends AbstractAppender {
*
* @param key The appender's key
*/
- public void deleteAppender(String key) {
+ public void deleteAppender(final String key) {
LOGGER.debug("Stopping route with key" + key);
AppenderControl control = appenders.remove(key);
control.getAppender().stop();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
index 4c590c1..df7eb8a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
@@ -98,7 +98,7 @@ public class AsyncLogger extends Logger implements EventTranslatorVararg<RingBuf
* @see org.apache.logging.log4j.core.Logger#updateConfiguration(org.apache.logging.log4j.core.config.Configuration)
*/
@Override
- protected void updateConfiguration(Configuration newConfig) {
+ protected void updateConfiguration(final Configuration newConfig) {
nanoClock = newConfig.getNanoClock();
includeLocation = newConfig.getLoggerConfig(name).isIncludeLocation();
super.updateConfiguration(newConfig);
@@ -215,7 +215,7 @@ public class AsyncLogger extends Logger implements EventTranslatorVararg<RingBuf
* @param fqcn fully qualified caller name.
* @return the caller location if requested, {@code null} otherwise.
*/
- private StackTraceElement calcLocationIfRequested(String fqcn) {
+ private StackTraceElement calcLocationIfRequested(final String fqcn) {
// location: very expensive operation. LOG4J2-153:
// Only include if "includeLocation=true" is specified,
// exclude if not specified or if "false" was specified.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
index 276d2ed..d0c9eea 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
@@ -66,7 +66,7 @@ public class AsyncLoggerConfigDisruptor implements AsyncLoggerConfigDelegate {
public Log4jEventWrapper() {
}
- public Log4jEventWrapper(MutableLogEvent mutableLogEvent) {
+ public Log4jEventWrapper(final MutableLogEvent mutableLogEvent) {
event = mutableLogEvent;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java
index a256238..a06893c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java
@@ -81,12 +81,12 @@ public class AsyncLoggerContext extends LoggerContext {
* @see org.apache.logging.log4j.core.LoggerContext#start(org.apache.logging.log4j.core.config.Configuration)
*/
@Override
- public void start(Configuration config) {
+ public void start(final Configuration config) {
maybeStartHelper(config);
super.start(config);
}
- private void maybeStartHelper(Configuration config) {
+ private void maybeStartHelper(final Configuration config) {
// If no log4j configuration was found, there are no loggers
// and there is no point in starting the disruptor (which takes up
// significant memory and starts a thread).
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
index 628f4ff..a2dcb19 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
@@ -1,236 +1,236 @@
-/*
- * 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.async;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import com.lmax.disruptor.ExceptionHandler;
-import com.lmax.disruptor.RingBuffer;
-import com.lmax.disruptor.WaitStrategy;
-import com.lmax.disruptor.dsl.Disruptor;
-import com.lmax.disruptor.dsl.ProducerType;
-
-/**
- * Helper class for async loggers: AsyncLoggerDisruptor handles the mechanics of working with the LMAX Disruptor, and
- * works with its associated AsyncLoggerContext to synchronize the life cycle of the Disruptor and its thread with the
- * life cycle of the context. The AsyncLoggerDisruptor of the context is shared by all AsyncLogger objects created by
- * that AsyncLoggerContext.
- */
-class AsyncLoggerDisruptor {
- private static final int SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS = 50;
- private static final int MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN = 200;
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
-
- private volatile Disruptor<RingBufferLogEvent> disruptor;
- private ExecutorService executor;
- private String contextName;
-
- private boolean useThreadLocalTranslator = true;
- private long backgroundThreadId;
- private AsyncQueueFullPolicy asyncQueueFullPolicy;
- private int ringBufferSize;
-
- AsyncLoggerDisruptor(String contextName) {
- this.contextName = contextName;
- }
-
- public String getContextName() {
- return contextName;
- }
-
- public void setContextName(String name) {
- contextName = name;
- }
-
- Disruptor<RingBufferLogEvent> getDisruptor() {
- return disruptor;
- }
-
- /**
- * Creates and starts a new Disruptor and associated thread if none currently exists.
- *
- * @see #stop()
- */
- synchronized void start() {
- if (disruptor != null) {
- LOGGER.trace(
- "[{}] AsyncLoggerDisruptor not starting new disruptor for this context, using existing object.",
- contextName);
- return;
- }
- LOGGER.trace("[{}] AsyncLoggerDisruptor creating new disruptor for this context.", contextName);
- ringBufferSize = DisruptorUtil.calculateRingBufferSize("AsyncLogger.RingBufferSize");
- final WaitStrategy waitStrategy = DisruptorUtil.createWaitStrategy("AsyncLogger.WaitStrategy");
- executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory("AsyncLogger[" + contextName + "]"));
- backgroundThreadId = DisruptorUtil.getExecutorThreadId(executor);
- asyncQueueFullPolicy = AsyncQueueFullPolicyFactory.create();
-
- disruptor = new Disruptor<>(RingBufferLogEvent.FACTORY, ringBufferSize, executor, ProducerType.MULTI,
- waitStrategy);
-
- final ExceptionHandler<RingBufferLogEvent> errorHandler = DisruptorUtil.getAsyncLoggerExceptionHandler();
- disruptor.handleExceptionsWith(errorHandler);
-
- final RingBufferLogEventHandler[] handlers = {new RingBufferLogEventHandler()};
- disruptor.handleEventsWith(handlers);
-
- LOGGER.debug("[{}] Starting AsyncLogger disruptor for this context with ringbufferSize={}, waitStrategy={}, "
- + "exceptionHandler={}...", contextName, disruptor.getRingBuffer().getBufferSize(), waitStrategy
- .getClass().getSimpleName(), errorHandler);
- disruptor.start();
-
- LOGGER.trace("[{}] AsyncLoggers use a {} translator", contextName, useThreadLocalTranslator ? "threadlocal"
- : "vararg");
- }
-
- /**
- * Decreases the reference count. If the reference count reached zero, the Disruptor and its associated thread are
- * shut down and their references set to {@code null}.
- */
- synchronized void stop() {
- final Disruptor<RingBufferLogEvent> temp = getDisruptor();
- if (temp == null) {
- LOGGER.trace("[{}] AsyncLoggerDisruptor: disruptor for this context already shut down.", contextName);
- return; // disruptor was already shut down by another thread
- }
- LOGGER.debug("[{}] AsyncLoggerDisruptor: shutting down disruptor for this context.", contextName);
-
- // We must guarantee that publishing to the RingBuffer has stopped before we call disruptor.shutdown().
- disruptor = null; // client code fails with NPE if log after stop. This is by design.
-
- // Calling Disruptor.shutdown() will wait until all enqueued events are fully processed,
- // but this waiting happens in a busy-spin. To avoid (postpone) wasting CPU,
- // we sleep in short chunks, up to 10 seconds, waiting for the ringbuffer to drain.
- for (int i = 0; hasBacklog(temp) && i < MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN; i++) {
- try {
- Thread.sleep(SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS); // give up the CPU for a while
- } catch (final InterruptedException e) { // ignored
- }
- }
- temp.shutdown(); // busy-spins until all events currently in the disruptor have been processed
-
- LOGGER.trace("[{}] AsyncLoggerDisruptor: shutting down disruptor executor.", contextName);
- executor.shutdown(); // finally, kill the processor thread
- executor = null;
-
- if (DiscardingAsyncQueueFullPolicy.getDiscardCount(asyncQueueFullPolicy) > 0) {
- LOGGER.trace("AsyncLoggerDisruptor: {} discarded {} events.", asyncQueueFullPolicy,
- DiscardingAsyncQueueFullPolicy.getDiscardCount(asyncQueueFullPolicy));
- }
- }
-
- /**
- * Returns {@code true} if the specified disruptor still has unprocessed events.
- */
- private static boolean hasBacklog(final Disruptor<?> theDisruptor) {
- final RingBuffer<?> ringBuffer = theDisruptor.getRingBuffer();
- return !ringBuffer.hasAvailableCapacity(ringBuffer.getBufferSize());
- }
-
- /**
- * Creates and returns a new {@code RingBufferAdmin} that instruments the ringbuffer of the {@code AsyncLogger}.
- *
- * @param jmxContextName name of the {@code AsyncLoggerContext}
- * @return a new {@code RingBufferAdmin} that instruments the ringbuffer
- */
- public RingBufferAdmin createRingBufferAdmin(final String jmxContextName) {
- final RingBuffer<RingBufferLogEvent> ring = disruptor == null ? null : disruptor.getRingBuffer();
- return RingBufferAdmin.forAsyncLogger(ring, jmxContextName);
- }
-
- EventRoute getEventRoute(final Level logLevel) {
- final int remainingCapacity = remainingDisruptorCapacity();
- if (remainingCapacity < 0) {
- return EventRoute.DISCARD;
- }
- return asyncQueueFullPolicy.getRoute(backgroundThreadId, logLevel);
- }
-
- private int remainingDisruptorCapacity() {
- final Disruptor<RingBufferLogEvent> temp = disruptor;
- if (hasLog4jBeenShutDown(temp)) {
- return -1;
- }
- return (int) temp.getRingBuffer().remainingCapacity();
- }
- /**
- * Returns {@code true} if the specified disruptor is null.
- */
- private boolean hasLog4jBeenShutDown(final Disruptor<RingBufferLogEvent> aDisruptor) {
- if (aDisruptor == null) { // LOG4J2-639
- LOGGER.warn("Ignoring log event after log4j was shut down");
- return true;
- }
- return false;
- }
-
- public boolean tryPublish(final RingBufferLogEventTranslator translator) {
- // LOG4J2-639: catch NPE if disruptor field was set to null in stop()
- try {
- return disruptor.getRingBuffer().tryPublishEvent(translator);
- } catch (final NullPointerException npe) {
- LOGGER.warn("[{}] Ignoring log event after log4j was shut down.", contextName);
- return false;
- }
- }
-
- void enqueueLogMessageInfo(final RingBufferLogEventTranslator translator) {
- // LOG4J2-639: catch NPE if disruptor field was set to null in stop()
- try {
- // Note: we deliberately access the volatile disruptor field afresh here.
- // Avoiding this and using an older reference could result in adding a log event to the disruptor after it
- // was shut down, which could cause the publishEvent method to hang and never return.
- disruptor.publishEvent(translator);
- } catch (final NullPointerException npe) {
- LOGGER.warn("[{}] Ignoring log event after log4j was shut down.", contextName);
- }
- }
-
- /**
- * Returns whether it is allowed to store non-JDK classes in ThreadLocal objects for efficiency.
- *
- * @return whether AsyncLoggers are allowed to use ThreadLocal objects
- * @since 2.5
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1172">LOG4J2-1172</a>
- */
- public boolean isUseThreadLocals() {
- return useThreadLocalTranslator;
- }
-
- /**
- * Signals this AsyncLoggerDisruptor whether it is allowed to store non-JDK classes in ThreadLocal objects for
- * efficiency.
- * <p>
- * This property may be modified after the {@link #start()} method has been called.
- * </p>
- *
- * @param allow whether AsyncLoggers are allowed to use ThreadLocal objects
- * @since 2.5
- * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1172">LOG4J2-1172</a>
- */
- public void setUseThreadLocals(final boolean allow) {
- useThreadLocalTranslator = allow;
- LOGGER.trace("[{}] AsyncLoggers have been modified to use a {} translator", contextName,
- useThreadLocalTranslator ? "threadlocal" : "vararg");
- }
-}
+/*
+ * 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.async;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import com.lmax.disruptor.ExceptionHandler;
+import com.lmax.disruptor.RingBuffer;
+import com.lmax.disruptor.WaitStrategy;
+import com.lmax.disruptor.dsl.Disruptor;
+import com.lmax.disruptor.dsl.ProducerType;
+
+/**
+ * Helper class for async loggers: AsyncLoggerDisruptor handles the mechanics of working with the LMAX Disruptor, and
+ * works with its associated AsyncLoggerContext to synchronize the life cycle of the Disruptor and its thread with the
+ * life cycle of the context. The AsyncLoggerDisruptor of the context is shared by all AsyncLogger objects created by
+ * that AsyncLoggerContext.
+ */
+class AsyncLoggerDisruptor {
+ private static final int SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS = 50;
+ private static final int MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN = 200;
+ private static final StatusLogger LOGGER = StatusLogger.getLogger();
+
+ private volatile Disruptor<RingBufferLogEvent> disruptor;
+ private ExecutorService executor;
+ private String contextName;
+
+ private boolean useThreadLocalTranslator = true;
+ private long backgroundThreadId;
+ private AsyncQueueFullPolicy asyncQueueFullPolicy;
+ private int ringBufferSize;
+
+ AsyncLoggerDisruptor(final String contextName) {
+ this.contextName = contextName;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public void setContextName(final String name) {
+ contextName = name;
+ }
+
+ Disruptor<RingBufferLogEvent> getDisruptor() {
+ return disruptor;
+ }
+
+ /**
+ * Creates and starts a new Disruptor and associated thread if none currently exists.
+ *
+ * @see #stop()
+ */
+ synchronized void start() {
+ if (disruptor != null) {
+ LOGGER.trace(
+ "[{}] AsyncLoggerDisruptor not starting new disruptor for this context, using existing object.",
+ contextName);
+ return;
+ }
+ LOGGER.trace("[{}] AsyncLoggerDisruptor creating new disruptor for this context.", contextName);
+ ringBufferSize = DisruptorUtil.calculateRingBufferSize("AsyncLogger.RingBufferSize");
+ final WaitStrategy waitStrategy = DisruptorUtil.createWaitStrategy("AsyncLogger.WaitStrategy");
+ executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory("AsyncLogger[" + contextName + "]"));
+ backgroundThreadId = DisruptorUtil.getExecutorThreadId(executor);
+ asyncQueueFullPolicy = AsyncQueueFullPolicyFactory.create();
+
+ disruptor = new Disruptor<>(RingBufferLogEvent.FACTORY, ringBufferSize, executor, ProducerType.MULTI,
+ waitStrategy);
+
+ final ExceptionHandler<RingBufferLogEvent> errorHandler = DisruptorUtil.getAsyncLoggerExceptionHandler();
+ disruptor.handleExceptionsWith(errorHandler);
+
+ final RingBufferLogEventHandler[] handlers = {new RingBufferLogEventHandler()};
+ disruptor.handleEventsWith(handlers);
+
+ LOGGER.debug("[{}] Starting AsyncLogger disruptor for this context with ringbufferSize={}, waitStrategy={}, "
+ + "exceptionHandler={}...", contextName, disruptor.getRingBuffer().getBufferSize(), waitStrategy
+ .getClass().getSimpleName(), errorHandler);
+ disruptor.start();
+
+ LOGGER.trace("[{}] AsyncLoggers use a {} translator", contextName, useThreadLocalTranslator ? "threadlocal"
+ : "vararg");
+ }
+
+ /**
+ * Decreases the reference count. If the reference count reached zero, the Disruptor and its associated thread are
+ * shut down and their references set to {@code null}.
+ */
+ synchronized void stop() {
+ final Disruptor<RingBufferLogEvent> temp = getDisruptor();
+ if (temp == null) {
+ LOGGER.trace("[{}] AsyncLoggerDisruptor: disruptor for this context already shut down.", contextName);
+ return; // disruptor was already shut down by another thread
+ }
+ LOGGER.debug("[{}] AsyncLoggerDisruptor: shutting down disruptor for this context.", contextName);
+
+ // We must guarantee that publishing to the RingBuffer has stopped before we call disruptor.shutdown().
+ disruptor = null; // client code fails with NPE if log after stop. This is by design.
+
+ // Calling Disruptor.shutdown() will wait until all enqueued events are fully processed,
+ // but this waiting happens in a busy-spin. To avoid (postpone) wasting CPU,
+ // we sleep in short chunks, up to 10 seconds, waiting for the ringbuffer to drain.
+ for (int i = 0; hasBacklog(temp) && i < MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN; i++) {
+ try {
+ Thread.sleep(SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS); // give up the CPU for a while
+ } catch (final InterruptedException e) { // ignored
+ }
+ }
+ temp.shutdown(); // busy-spins until all events currently in the disruptor have been processed
+
+ LOGGER.trace("[{}] AsyncLoggerDisruptor: shutting down disruptor executor.", contextName);
+ executor.shutdown(); // finally, kill the processor thread
+ executor = null;
+
+ if (DiscardingAsyncQueueFullPolicy.getDiscardCount(asyncQueueFullPolicy) > 0) {
+ LOGGER.trace("AsyncLoggerDisruptor: {} discarded {} events.", asyncQueueFullPolicy,
+ DiscardingAsyncQueueFullPolicy.getDiscardCount(asyncQueueFullPolicy));
+ }
+ }
+
+ /**
+ * Returns {@code true} if the specified disruptor still has unprocessed events.
+ */
+ private static boolean hasBacklog(final Disruptor<?> theDisruptor) {
+ final RingBuffer<?> ringBuffer = theDisruptor.getRingBuffer();
+ return !ringBuffer.hasAvailableCapacity(ringBuffer.getBufferSize());
+ }
+
+ /**
+ * Creates and returns a new {@code RingBufferAdmin} that instruments the ringbuffer of the {@code AsyncLogger}.
+ *
+ * @param jmxContextName name of the {@code AsyncLoggerContext}
+ * @return a new {@code RingBufferAdmin} that instruments the ringbuffer
+ */
+ public RingBufferAdmin createRingBufferAdmin(final String jmxContextName) {
+ final RingBuffer<RingBufferLogEvent> ring = disruptor == null ? null : disruptor.getRingBuffer();
+ return RingBufferAdmin.forAsyncLogger(ring, jmxContextName);
+ }
+
+ EventRoute getEventRoute(final Level logLevel) {
+ final int remainingCapacity = remainingDisruptorCapacity();
+ if (remainingCapacity < 0) {
+ return EventRoute.DISCARD;
+ }
+ return asyncQueueFullPolicy.getRoute(backgroundThreadId, logLevel);
+ }
+
+ private int remainingDisruptorCapacity() {
+ final Disruptor<RingBufferLogEvent> temp = disruptor;
+ if (hasLog4jBeenShutDown(temp)) {
+ return -1;
+ }
+ return (int) temp.getRingBuffer().remainingCapacity();
+ }
+ /**
+ * Returns {@code true} if the specified disruptor is null.
+ */
+ private boolean hasLog4jBeenShutDown(final Disruptor<RingBufferLogEvent> aDisruptor) {
+ if (aDisruptor == null) { // LOG4J2-639
+ LOGGER.warn("Ignoring log event after log4j was shut down");
+ return true;
+ }
+ return false;
+ }
+
+ public boolean tryPublish(final RingBufferLogEventTranslator translator) {
+ // LOG4J2-639: catch NPE if disruptor field was set to null in stop()
+ try {
+ return disruptor.getRingBuffer().tryPublishEvent(translator);
+ } catch (final NullPointerException npe) {
+ LOGGER.warn("[{}] Ignoring log event after log4j was shut down.", contextName);
+ return false;
+ }
+ }
+
+ void enqueueLogMessageInfo(final RingBufferLogEventTranslator translator) {
+ // LOG4J2-639: catch NPE if disruptor field was set to null in stop()
+ try {
+ // Note: we deliberately access the volatile disruptor field afresh here.
+ // Avoiding this and using an older reference could result in adding a log event to the disruptor after it
+ // was shut down, which could cause the publishEvent method to hang and never return.
+ disruptor.publishEvent(translator);
+ } catch (final NullPointerException npe) {
+ LOGGER.warn("[{}] Ignoring log event after log4j was shut down.", contextName);
+ }
+ }
+
+ /**
+ * Returns whether it is allowed to store non-JDK classes in ThreadLocal objects for efficiency.
+ *
+ * @return whether AsyncLoggers are allowed to use ThreadLocal objects
+ * @since 2.5
+ * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1172">LOG4J2-1172</a>
+ */
+ public boolean isUseThreadLocals() {
+ return useThreadLocalTranslator;
+ }
+
+ /**
+ * Signals this AsyncLoggerDisruptor whether it is allowed to store non-JDK classes in ThreadLocal objects for
+ * efficiency.
+ * <p>
+ * This property may be modified after the {@link #start()} method has been called.
+ * </p>
+ *
+ * @param allow whether AsyncLoggers are allowed to use ThreadLocal objects
+ * @since 2.5
+ * @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1172">LOG4J2-1172</a>
+ */
+ public void setUseThreadLocals(final boolean allow) {
+ useThreadLocalTranslator = allow;
+ LOGGER.trace("[{}] AsyncLoggers have been modified to use a {} translator", contextName,
+ useThreadLocalTranslator ? "threadlocal" : "vararg");
+ }
+}
[07/10] logging-log4j2 git commit: Add final modifier to method
parameters.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultScriptFileComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultScriptFileComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultScriptFileComponentBuilder.java
index 85fbbe4..c9d50ef 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultScriptFileComponentBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultScriptFileComponentBuilder.java
@@ -34,25 +34,25 @@ class DefaultScriptFileComponentBuilder extends DefaultComponentAndConfiguration
}
@Override
- public DefaultScriptFileComponentBuilder addLanguage(String language) {
+ public DefaultScriptFileComponentBuilder addLanguage(final String language) {
addAttribute("language", language);
return this;
}
@Override
- public DefaultScriptFileComponentBuilder addIsWatched(boolean isWatched) {
+ public DefaultScriptFileComponentBuilder addIsWatched(final boolean isWatched) {
addAttribute("isWatched", Boolean.toString(isWatched));
return this;
}
@Override
- public DefaultScriptFileComponentBuilder addIsWatched(String isWatched) {
+ public DefaultScriptFileComponentBuilder addIsWatched(final String isWatched) {
addAttribute("isWatched", isWatched);
return this;
}
@Override
- public DefaultScriptFileComponentBuilder addCharset(String charset) {
+ public DefaultScriptFileComponentBuilder addCharset(final String charset) {
addAttribute("charset", charset);
return this;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 60d98f0..b29e60b 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
@@ -61,7 +61,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
*
* @param configurations The List of Configurations to merge.
*/
- public CompositeConfiguration(List<? extends AbstractConfiguration> configurations) {
+ public CompositeConfiguration(final List<? extends AbstractConfiguration> configurations) {
super(ConfigurationSource.NULL_SOURCE);
rootNode = configurations.get(0).getRootNode();
this.configurations = configurations;
@@ -167,13 +167,13 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
return new CompositeConfiguration(configs);
}
- private void staffChildConfiguration(AbstractConfiguration childConfiguration) {
+ private void staffChildConfiguration(final AbstractConfiguration childConfiguration) {
childConfiguration.setPluginManager(pluginManager);
childConfiguration.setScriptManager(scriptManager);
childConfiguration.setup();
}
- private void printNodes(String indent, Node node, StringBuilder sb) {
+ 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()) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ce38e82..e188efa 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
@@ -68,7 +68,7 @@ public class DefaultMergeStrategy implements MergeStrategy {
* @param configuration The configuration to merge.
*/
@Override
- public void mergeRootProperties(Node rootNode, AbstractConfiguration configuration) {
+ public void mergeRootProperties(final Node rootNode, final AbstractConfiguration configuration) {
for (Map.Entry<String, String> attribute : configuration.getRootNode().getAttributes().entrySet()) {
boolean isFound = false;
for (Map.Entry<String, String> targetAttribute : rootNode.getAttributes().entrySet()) {
@@ -112,7 +112,7 @@ public class DefaultMergeStrategy implements MergeStrategy {
* @param pluginManager The PluginManager.
*/
@Override
- public void mergConfigurations(Node target, Node source, PluginManager pluginManager) {
+ public void mergConfigurations(final Node target, final Node source, final PluginManager pluginManager) {
for (Node sourceChildNode : source.getChildren()) {
boolean isFilter = isFilterNode(sourceChildNode);
boolean isMerged = false;
@@ -222,7 +222,7 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
}
- private Node getLoggerNode(Node parentNode, String name) {
+ private Node getLoggerNode(final Node parentNode, final String name) {
for (Node node : parentNode.getChildren()) {
String nodeName = node.getAttributes().get(NAME);
if (name == null && nodeName == null) {
@@ -235,8 +235,8 @@ public class DefaultMergeStrategy implements MergeStrategy {
return null;
}
- private void updateFilterNode(Node target, Node targetChildNode, Node sourceChildNode,
- PluginManager pluginManager) {
+ 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());
node.getChildren().addAll(sourceChildNode.getChildren());
@@ -256,15 +256,15 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
}
- private boolean isFilterNode(Node node) {
+ private boolean isFilterNode(final Node node) {
return Filter.class.isAssignableFrom(node.getType().getPluginClass());
}
- private boolean isSameName(Node node1, Node node2) {
+ private boolean isSameName(final Node node1, final Node node2) {
return node1.getAttributes().get(NAME).toLowerCase().equals(node2.getAttributes().get(NAME).toLowerCase());
}
- private boolean isSameReference(Node node1, Node node2) {
+ private boolean isSameReference(final Node node1, final Node node2) {
return node1.getAttributes().get(REF).toLowerCase().equals(node2.getAttributes().get(REF).toLowerCase());
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
index 90abf56..a5eaae9 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
@@ -30,7 +30,7 @@ import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
*/
public class PropertiesConfiguration extends BuiltConfiguration implements Reconfigurable {
- public PropertiesConfiguration(ConfigurationSource source, Component root) {
+ public PropertiesConfiguration(final ConfigurationSource source, final Component root) {
super(source, root);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 2c70234..66f9bba 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
@@ -71,7 +71,7 @@ public class PropertiesConfigurationBuilder extends ConfigurationBuilderFactory
return this;
}
- public PropertiesConfigurationBuilder setConfigurationSource(ConfigurationSource source) {
+ public PropertiesConfigurationBuilder setConfigurationSource(final ConfigurationSource source) {
builder.setConfigurationSource(source);
return this;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ca2c0a0..ea1c12b 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
@@ -187,7 +187,7 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
* @return a new DocumentBuilder
* @throws ParserConfigurationException
*/
- static DocumentBuilder newDocumentBuilder(boolean xIncludeAware) throws ParserConfigurationException {
+ static DocumentBuilder newDocumentBuilder(final boolean xIncludeAware) throws ParserConfigurationException {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
if (xIncludeAware) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
index 65d8ffa..e68c3d1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
@@ -113,7 +113,7 @@ public final class DynamicThresholdFilter extends AbstractFilter {
return true;
}
- private Result filter(final Level level, Map<String, String> contextMap) {
+ private Result filter(final Level level, final Map<String, String> contextMap) {
final Object value = contextMap.get(key);
if (value != null) {
Level ctxLevel = levelMap.get(value);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 69a8a22..d7588a6 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
@@ -95,7 +95,7 @@ public class Log4jLogEvent implements LogEvent {
public Builder() {
}
- public Builder(LogEvent other) {
+ public Builder(final LogEvent other) {
Objects.requireNonNull(other);
if (other instanceof RingBufferLogEvent) {
((RingBufferLogEvent) other).initializeBuilder(this);
@@ -165,52 +165,52 @@ public class Log4jLogEvent implements LogEvent {
return this;
}
- public Builder setTimeMillis(long timeMillis) {
+ public Builder setTimeMillis(final long timeMillis) {
this.timeMillis = timeMillis;
return this;
}
- public Builder setThrownProxy(ThrowableProxy thrownProxy) {
+ public Builder setThrownProxy(final ThrowableProxy thrownProxy) {
this.thrownProxy = thrownProxy;
return this;
}
- public Builder setContextMap(Map<String, String> contextMap) {
+ public Builder setContextMap(final Map<String, String> contextMap) {
this.contextMap = contextMap;
return this;
}
- public Builder setContextStack(ThreadContext.ContextStack contextStack) {
+ public Builder setContextStack(final ThreadContext.ContextStack contextStack) {
this.contextStack = contextStack;
return this;
}
- public Builder setThreadId(long threadId) {
+ public Builder setThreadId(final long threadId) {
this.threadId = threadId;
return this;
}
- public Builder setThreadName(String threadName) {
+ public Builder setThreadName(final String threadName) {
this.threadName = threadName;
return this;
}
- public Builder setThreadPriority(int threadPriority) {
+ public Builder setThreadPriority(final int threadPriority) {
this.threadPriority = threadPriority;
return this;
}
- public Builder setSource(StackTraceElement source) {
+ public Builder setSource(final StackTraceElement source) {
this.source = source;
return this;
}
- public Builder setIncludeLocation(boolean includeLocation) {
+ public Builder setIncludeLocation(final boolean includeLocation) {
this.includeLocation = includeLocation;
return this;
}
- public Builder setEndOfBatch(boolean endOfBatch) {
+ public Builder setEndOfBatch(final boolean endOfBatch) {
this.endOfBatch = endOfBatch;
return this;
}
@@ -221,7 +221,7 @@ public class Log4jLogEvent implements LogEvent {
* was created.
* @return this builder
*/
- public Builder setNanoTime(long nanoTime) {
+ public Builder setNanoTime(final long nanoTime) {
this.nanoTime = nanoTime;
return this;
}
@@ -374,8 +374,8 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
*/
private Log4jLogEvent(final String loggerName, final Marker marker, final String loggerFQCN, final Level level,
final Message message, final Throwable thrown, final ThrowableProxy thrownProxy,
- final Map<String, String> contextMap, final ThreadContext.ContextStack contextStack, long threadId,
- final String threadName, int threadPriority, final StackTraceElement source, final long timestampMillis,
+ final Map<String, String> contextMap, final ThreadContext.ContextStack contextStack, final long threadId,
+ final String threadName, final int threadPriority, final StackTraceElement source, final long timestampMillis,
final long nanoTime) {
this.loggerName = loggerName;
this.marker = marker;
@@ -430,7 +430,7 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
*
* @param nanoClock the {@code NanoClock} to use for creating the nanoTime timestamp of log events
*/
- public static void setNanoClock(NanoClock nanoClock) {
+ public static void setNanoClock(final NanoClock nanoClock) {
Log4jLogEvent.nanoClock = Objects.requireNonNull(nanoClock, "NanoClock must be non-null");
StatusLogger.getLogger().trace("Using {} for nanosecond timestamps.", nanoClock.getClass().getSimpleName());
}
@@ -696,7 +696,7 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
*
* @return a new immutable copy of the data in this {@code Log4jLogEvent}
*/
- public static Log4jLogEvent createMemento(LogEvent event, final boolean includeLocation) {
+ public static Log4jLogEvent createMemento(final LogEvent event, final boolean includeLocation) {
// TODO implement Log4jLogEvent.createMemento()
return deserialize(serialize(event, includeLocation));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 6e806af..b89dc04 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
@@ -147,7 +147,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return loggerFqcn;
}
- public void setLoggerFqcn(String loggerFqcn) {
+ public void setLoggerFqcn(final String loggerFqcn) {
this.loggerFqcn = loggerFqcn;
}
@@ -156,7 +156,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return marker;
}
- public void setMarker(Marker marker) {
+ public void setMarker(final Marker marker) {
this.marker = marker;
}
@@ -168,7 +168,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return level;
}
- public void setLevel(Level level) {
+ public void setLevel(final Level level) {
this.level = level;
}
@@ -177,7 +177,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return loggerName;
}
- public void setLoggerName(String loggerName) {
+ public void setLoggerName(final String loggerName) {
this.loggerName = loggerName;
}
@@ -291,7 +291,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return thrown;
}
- public void setThrown(Throwable thrown) {
+ public void setThrown(final Throwable thrown) {
this.thrown = thrown;
}
@@ -300,7 +300,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return timeMillis;
}
- public void setTimeMillis(long timeMillis) {
+ public void setTimeMillis(final long timeMillis) {
this.timeMillis = timeMillis;
}
@@ -338,7 +338,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return contextMap;
}
- public void setContextMap(Map<String, String> contextMap) {
+ public void setContextMap(final Map<String, String> contextMap) {
this.contextMap = contextMap;
}
@@ -347,7 +347,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return contextStack;
}
- public void setContextStack(ThreadContext.ContextStack contextStack) {
+ public void setContextStack(final ThreadContext.ContextStack contextStack) {
this.contextStack = contextStack;
}
@@ -356,7 +356,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return threadId;
}
- public void setThreadId(long threadId) {
+ public void setThreadId(final long threadId) {
this.threadId = threadId;
}
@@ -365,7 +365,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return threadName;
}
- public void setThreadName(String threadName) {
+ public void setThreadName(final String threadName) {
this.threadName = threadName;
}
@@ -374,7 +374,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return threadPriority;
}
- public void setThreadPriority(int threadPriority) {
+ public void setThreadPriority(final int threadPriority) {
this.threadPriority = threadPriority;
}
@@ -384,7 +384,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
}
@Override
- public void setIncludeLocation(boolean includeLocation) {
+ public void setIncludeLocation(final boolean includeLocation) {
this.includeLocation = includeLocation;
}
@@ -394,7 +394,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
}
@Override
- public void setEndOfBatch(boolean endOfBatch) {
+ public void setEndOfBatch(final boolean endOfBatch) {
this.endOfBatch = endOfBatch;
}
@@ -403,7 +403,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
return nanoTime;
}
- public void setNanoTime(long nanoTime) {
+ public void setNanoTime(final long nanoTime) {
this.nanoTime = nanoTime;
}
@@ -433,7 +433,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
* Initializes the specified {@code Log4jLogEvent.Builder} from this {@code MutableLogEvent}.
* @param builder the builder whose fields to populate
*/
- public void initializeBuilder(Log4jLogEvent.Builder builder) {
+ public void initializeBuilder(final Log4jLogEvent.Builder builder) {
builder.setContextMap(contextMap) //
.setContextStack(contextStack) //
.setEndOfBatch(endOfBatch) //
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index 6694943..4d4e761 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -207,7 +207,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> implem
return headerSerializer;
}
- protected byte[] serializeToBytes(final Serializer serializer, byte[] defaultValue) {
+ protected byte[] serializeToBytes(final Serializer serializer, final byte[] defaultValue) {
final String serializable = serializeToString(serializer);
if (serializer == null) {
return defaultValue;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 7db739e..b679fcd 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
@@ -107,7 +107,7 @@ public final class GelfLayout extends AbstractStringLayout {
private final boolean includeStacktrace;
public GelfLayout(final String host, final KeyValuePair[] additionalFields, final CompressionType compressionType,
- final int compressionThreshold, boolean includeStacktrace) {
+ final int compressionThreshold, final boolean includeStacktrace) {
super(StandardCharsets.UTF_8);
this.host = host;
this.additionalFields = additionalFields;
@@ -182,7 +182,7 @@ public final class GelfLayout extends AbstractStringLayout {
return text.toString();
}
- private StringBuilder toText(LogEvent event, StringBuilder builder, boolean gcFree) {
+ private StringBuilder toText(final LogEvent event, final StringBuilder builder, final boolean gcFree) {
builder.append('{');
builder.append("\"version\":\"1.1\",");
builder.append("\"host\":\"");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
index 5869435..e230119 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
@@ -163,12 +163,12 @@ abstract class JacksonFactory {
private static final long serialVersionUID = 1L;
- Log4jXmlPrettyPrinter(int nesting) {
+ Log4jXmlPrettyPrinter(final int nesting) {
_nesting = nesting;
}
@Override
- public void writePrologLinefeed(XMLStreamWriter2 sw) throws XMLStreamException {
+ public void writePrologLinefeed(final XMLStreamWriter2 sw) throws XMLStreamException {
// nothing
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 383f0ed..1a98313 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
@@ -74,7 +74,7 @@ public class MarkerPatternSelector implements PatternSelector {
}
@Override
- public PatternFormatter[] getFormatters(LogEvent event) {
+ public PatternFormatter[] getFormatters(final LogEvent event) {
Marker marker = event.getMarker();
if (marker == null) {
return defaultFormatters;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 6a02c46..01ade28 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
@@ -83,7 +83,7 @@ public class ScriptPatternSelector implements PatternSelector {
}
@Override
- public PatternFormatter[] getFormatters(LogEvent event) {
+ public PatternFormatter[] getFormatters(final LogEvent event) {
SimpleBindings bindings = new SimpleBindings();
bindings.putAll(configuration.getProperties());
bindings.put("substitutor", configuration.getStrSubstitutor());
@@ -99,7 +99,7 @@ public class ScriptPatternSelector implements PatternSelector {
@PluginFactory
- public static ScriptPatternSelector createSelector(@PluginElement("Script") AbstractScript script,
+ public static ScriptPatternSelector createSelector(@PluginElement("Script") final AbstractScript script,
@PluginElement("PatternMatch") final PatternMatch[] properties,
@PluginAttribute("defaultPattern") String defaultPattern,
@PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions,
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 7d27830..8778acb 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
@@ -130,7 +130,7 @@ public class TextEncoderHelper {
return temp;
}
- private static ByteBuffer drainIfByteBufferFull(ByteBufferDestination destination, ByteBuffer temp, CoderResult result) {
+ private static ByteBuffer drainIfByteBufferFull(final ByteBufferDestination destination, ByteBuffer temp, final CoderResult result) {
if (result.isOverflow()) { // byte buffer full
// SHOULD NOT HAPPEN:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
index 6683f1d..a6bbad8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
@@ -67,7 +67,7 @@ public class SmtpManager extends AbstractManager {
private final FactoryData data;
- private static MimeMessage createMimeMessage(final FactoryData data, final Session session, LogEvent appendEvent)
+ private static MimeMessage createMimeMessage(final FactoryData data, final Session session, final LogEvent appendEvent)
throws MessagingException {
return new MimeMessageBuilder(session).setFrom(data.from).setReplyTo(data.replyto)
.setRecipients(Message.RecipientType.TO, data.to).setRecipients(Message.RecipientType.CC, data.cc)
@@ -295,7 +295,7 @@ public class SmtpManager extends AbstractManager {
}
}
- private synchronized void connect(LogEvent appendEvent) {
+ private synchronized void connect(final LogEvent appendEvent) {
if (message != null) {
return;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java
index d518aee..4d83d97 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java
@@ -116,7 +116,7 @@ public class TcpSocketManager extends AbstractSocketManager {
}
@Override
- protected void write(final byte[] bytes, final int offset, final int length, boolean immediateFlush) {
+ protected void write(final byte[] bytes, final int offset, final int length, final boolean immediateFlush) {
if (socket == null) {
if (connector != null && !immediateFail) {
connector.latch();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverter.java
index bb8464c..d4a2310 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/EqualsReplacementConverter.java
@@ -77,7 +77,7 @@ public final class EqualsReplacementConverter extends LogEventPatternConverter {
* @param parser The PatternParser.
*/
private EqualsReplacementConverter(final List<PatternFormatter> formatters, final String testString,
- final String substitution, PatternParser parser) {
+ final String substitution, final PatternParser parser) {
super("equals", "equals");
this.testString = testString;
this.substitution = substitution;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
index a59cc5f..bc114f1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
@@ -226,7 +226,7 @@ public abstract class NameAbbreviator {
}
}
- private void abbreviateForDrop(String original, StringBuilder destination) {
+ private void abbreviateForDrop(final String original, final StringBuilder destination) {
// If a path does not contain enough path elements to drop, none will be dropped.
int start = 0;
int nextStart = 0;
@@ -242,7 +242,7 @@ public abstract class NameAbbreviator {
destination.append(original, start, original.length());
}
- private void abbreviateForRetain(String original, StringBuilder destination) {
+ private void abbreviateForRetain(final String original, final StringBuilder destination) {
// We subtract 1 from 'len' when assigning to 'end' to avoid out of
// bounds exception in return r.substring(end+1, len). This can happen if
// precision is 1 and the category name ends with a dot.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/script/Script.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/Script.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/Script.java
index 3f0c1da..0eff8df 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/script/Script.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/script/Script.java
@@ -32,7 +32,7 @@ public class Script extends AbstractScript {
private static final Logger logger = StatusLogger.getLogger();
- public Script(String name, String language, String scriptText) {
+ public Script(final String name, final String language, final String scriptText) {
super(name, language, scriptText);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 f2fe085..31f11d9 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
@@ -48,7 +48,7 @@ public class ScriptFile extends AbstractScript {
private final boolean isWatched;
- public ScriptFile(String name, Path filePath, String language, boolean isWatched, String scriptText) {
+ public ScriptFile(final String name, final Path filePath, final String language, final boolean isWatched, final String scriptText) {
super(name, language, scriptText);
this.filePath = filePath;
this.isWatched = isWatched;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ff73662..1cad47c 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
@@ -52,7 +52,7 @@ public class ScriptManager implements FileWatcher, Serializable {
private final WatchManager watchManager;
private static final SecurityManager SECURITY_MANAGER = System.getSecurityManager();
- public ScriptManager(WatchManager watchManager) {
+ public ScriptManager(final WatchManager watchManager) {
this.watchManager = watchManager;
final List<ScriptEngineFactory> factories = manager.getEngineFactories();
if (logger.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 0ace830..d70da09 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
@@ -34,7 +34,7 @@ public class ScriptRef extends AbstractScript {
private static final Logger logger = StatusLogger.getLogger();
private final ScriptManager scriptManager;
- public ScriptRef(String name, ScriptManager scriptManager) {
+ public ScriptRef(final String name, final ScriptManager scriptManager) {
super(name, null, null);
this.scriptManager = scriptManager;
}
@@ -56,7 +56,7 @@ public class ScriptRef extends AbstractScript {
public static ScriptRef createReference(
// @formatter:off
@PluginAttribute("ref") final String name,
- @PluginConfiguration Configuration configuration) {
+ @PluginConfiguration final Configuration configuration) {
// @formatter:on
if (name == null) {
logger.error("No script name provided");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 dbb5a9d..2c0bfe4 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
@@ -262,7 +262,7 @@ public final class CronExpression {
* @throws java.text.ParseException if the string expression cannot be parsed into a valid
* <CODE>CronExpression</CODE>
*/
- public CronExpression(String cronExpression) throws ParseException {
+ public CronExpression(final String cronExpression) throws ParseException {
if (cronExpression == null) {
throw new IllegalArgumentException("cronExpression cannot be null");
}
@@ -281,7 +281,7 @@ public final class CronExpression {
* @return a boolean indicating whether the given date satisfies the cron
* expression
*/
- public boolean isSatisfiedBy(Date date) {
+ public boolean isSatisfiedBy(final Date date) {
Calendar testDateCal = Calendar.getInstance(getTimeZone());
testDateCal.setTime(date);
testDateCal.set(Calendar.MILLISECOND, 0);
@@ -302,7 +302,7 @@ public final class CronExpression {
* date/time
* @return the next valid date/time
*/
- public Date getNextValidTimeAfter(Date date) {
+ public Date getNextValidTimeAfter(final Date date) {
return getTimeAfter(date);
}
@@ -314,7 +314,7 @@ public final class CronExpression {
* invalid date/time
* @return the next valid date/time
*/
- public Date getNextInvalidTimeAfter(Date date) {
+ public Date getNextInvalidTimeAfter(final Date date) {
long difference = 1000;
//move back to the nearest second so differences will be accurate
@@ -362,7 +362,7 @@ public final class CronExpression {
* Sets the time zone for which this <code>CronExpression</code>
* will be resolved.
*/
- public void setTimeZone(TimeZone timeZone) {
+ public void setTimeZone(final TimeZone timeZone) {
this.timeZone = timeZone;
}
@@ -384,7 +384,7 @@ public final class CronExpression {
* @return a boolean indicating whether the given expression is a valid cron
* expression
*/
- public static boolean isValidExpression(String cronExpression) {
+ public static boolean isValidExpression(final String cronExpression) {
try {
new CronExpression(cronExpression);
@@ -395,7 +395,7 @@ public final class CronExpression {
return true;
}
- public static void validateExpression(String cronExpression) throws ParseException {
+ public static void validateExpression(final String cronExpression) throws ParseException {
new CronExpression(cronExpression);
}
@@ -407,7 +407,7 @@ public final class CronExpression {
//
////////////////////////////////////////////////////////////////////////////
- protected void buildExpression(String expression) throws ParseException {
+ protected void buildExpression(final String expression) throws ParseException {
expressionParsed = true;
try {
@@ -493,7 +493,7 @@ public final class CronExpression {
}
}
- protected int storeExpressionVals(int pos, String s, int type)
+ protected int storeExpressionVals(final int pos, final String s, final int type)
throws ParseException {
int incr = 0;
@@ -684,7 +684,7 @@ public final class CronExpression {
return i;
}
- protected int checkNext(int pos, String s, int val, int type)
+ protected int checkNext(final int pos, final String s, final int val, final int type)
throws ParseException {
int end = -1;
@@ -861,7 +861,7 @@ public final class CronExpression {
return buf.toString();
}
- protected String getExpressionSetSummary(java.util.Set<Integer> set) {
+ protected String getExpressionSetSummary(final java.util.Set<Integer> set) {
if (set.contains(NO_SPEC)) {
return "?";
@@ -887,7 +887,7 @@ public final class CronExpression {
return buf.toString();
}
- protected String getExpressionSetSummary(java.util.ArrayList<Integer> list) {
+ protected String getExpressionSetSummary(final java.util.ArrayList<Integer> list) {
if (list.contains(NO_SPEC)) {
return "?";
@@ -913,7 +913,7 @@ public final class CronExpression {
return buf.toString();
}
- protected int skipWhiteSpace(int i, String s) {
+ protected int skipWhiteSpace(int i, final String s) {
for (; i < s.length() && (s.charAt(i) == ' ' || s.charAt(i) == '\t'); i++) {
;
}
@@ -921,7 +921,7 @@ public final class CronExpression {
return i;
}
- protected int findNextWhiteSpace(int i, String s) {
+ protected int findNextWhiteSpace(int i, final String s) {
for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++) {
;
}
@@ -929,7 +929,7 @@ public final class CronExpression {
return i;
}
- protected void addToSet(int val, int end, int incr, int type)
+ protected void addToSet(final int val, final int end, int incr, final int type)
throws ParseException {
TreeSet<Integer> set = getSet(type);
@@ -1076,7 +1076,7 @@ public final class CronExpression {
}
}
- TreeSet<Integer> getSet(int type) {
+ TreeSet<Integer> getSet(final int type) {
switch (type) {
case SECOND:
return seconds;
@@ -1097,7 +1097,7 @@ public final class CronExpression {
}
}
- protected ValueSet getValue(int v, String s, int i) {
+ protected ValueSet getValue(final int v, final String s, int i) {
char c = s.charAt(i);
StringBuilder s1 = new StringBuilder(String.valueOf(v));
while (c >= '0' && c <= '9') {
@@ -1115,13 +1115,13 @@ public final class CronExpression {
return val;
}
- protected int getNumericValue(String s, int i) {
+ protected int getNumericValue(final String s, final int i) {
int endOfVal = findNextWhiteSpace(i, s);
String val = s.substring(i, endOfVal);
return Integer.parseInt(val);
}
- protected int getMonthNumber(String s) {
+ protected int getMonthNumber(final String s) {
Integer integer = monthMap.get(s);
if (integer == null) {
@@ -1131,7 +1131,7 @@ public final class CronExpression {
return integer;
}
- protected int getDayOfWeekNumber(String s) {
+ protected int getDayOfWeekNumber(final String s) {
Integer integer = dayMap.get(s);
if (integer == null) {
@@ -1558,7 +1558,7 @@ public final class CronExpression {
* @param cal the calendar to operate on
* @param hour the hour to set
*/
- protected void setCalendarHour(Calendar cal, int hour) {
+ protected void setCalendarHour(final Calendar cal, final int hour) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
@@ -1569,7 +1569,7 @@ public final class CronExpression {
* NOT YET IMPLEMENTED: Returns the time before the given time
* that the <code>CronExpression</code> matches.
*/
- public Date getTimeBefore(Date endTime) {
+ public Date getTimeBefore(final Date endTime) {
// FUTURE_TODO: implement QUARTZ-423
return null;
}
@@ -1583,11 +1583,11 @@ public final class CronExpression {
return null;
}
- protected boolean isLeapYear(int year) {
+ protected boolean isLeapYear(final int year) {
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
}
- protected int getLastDayOfMonth(int monthNum, int year) {
+ protected int getLastDayOfMonth(final int monthNum, final int year) {
switch (monthNum) {
case 1:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyNanoClock.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyNanoClock.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyNanoClock.java
index 8200c38..e3d6c2b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyNanoClock.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DummyNanoClock.java
@@ -1,48 +1,48 @@
-/*
- * 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.util;
-
-/**
- * Implementation of the {@code NanoClock} interface that always returns a fixed value.
- */
-public final class DummyNanoClock implements NanoClock {
-
- private final long fixedNanoTime;
-
- public DummyNanoClock() {
- this(0L);
- }
-
- /**
- * Constructs a new DummyNanoClock with the specified value to return.
- * @param fixedNanoTime the value to return from {@link #nanoTime()}.
- */
- public DummyNanoClock(long fixedNanoTime) {
- this.fixedNanoTime = fixedNanoTime;
- }
-
- /**
- * Returns the constructor value.
- *
- * @return the constructor value
- */
- @Override
- public long nanoTime() {
- return fixedNanoTime;
- }
-
-}
+/*
+ * 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.util;
+
+/**
+ * Implementation of the {@code NanoClock} interface that always returns a fixed value.
+ */
+public final class DummyNanoClock implements NanoClock {
+
+ private final long fixedNanoTime;
+
+ public DummyNanoClock() {
+ this(0L);
+ }
+
+ /**
+ * Constructs a new DummyNanoClock with the specified value to return.
+ * @param fixedNanoTime the value to return from {@link #nanoTime()}.
+ */
+ public DummyNanoClock(final long fixedNanoTime) {
+ this.fixedNanoTime = fixedNanoTime;
+ }
+
+ /**
+ * Returns the constructor value.
+ *
+ * @return the constructor value
+ */
+ @Override
+ public long nanoTime() {
+ return fixedNanoTime;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExtensionLanguageMapping.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExtensionLanguageMapping.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExtensionLanguageMapping.java
index c3442ee..22c005b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExtensionLanguageMapping.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExtensionLanguageMapping.java
@@ -36,7 +36,7 @@ public enum ExtensionLanguageMapping {
private final String extension;
private final String language;
- ExtensionLanguageMapping(String extension, String language) {
+ ExtensionLanguageMapping(final String extension, final String language) {
this.extension = extension;
this.language = language;
}
@@ -49,7 +49,7 @@ public enum ExtensionLanguageMapping {
return this.language;
}
- public static ExtensionLanguageMapping getByExtension(String extension) {
+ public static ExtensionLanguageMapping getByExtension(final String extension) {
for (final ExtensionLanguageMapping mapping : values()) {
if (mapping.extension.equals(extension)) {
return mapping;
@@ -58,7 +58,7 @@ public enum ExtensionLanguageMapping {
return null;
}
- public static List<ExtensionLanguageMapping> getByLanguage(String language) {
+ public static List<ExtensionLanguageMapping> getByLanguage(final String language) {
final List<ExtensionLanguageMapping> list = new ArrayList<>();
for (final ExtensionLanguageMapping mapping : values()) {
if (mapping.language.equals(language)) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ad675ed..258773f 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
@@ -93,7 +93,7 @@ public final class FileUtils {
return url != null && (url.getProtocol().equals(PROTOCOL_FILE) || url.getProtocol().equals(JBOSS_FILE));
}
- public static String getFileExtension(File file) {
+ public static String getFileExtension(final File file) {
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/7a5dcd43/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 bca5417..685d12f 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
@@ -46,7 +46,7 @@ public final class JsonUtils {
/**
* Quote text contents using JSON standard quoting, and append results to a supplied {@link StringBuilder}.
*/
- public static void quoteAsString(CharSequence input, StringBuilder output) {
+ public static void quoteAsString(final CharSequence input, final StringBuilder output) {
final char[] qbuf = getQBuf();
final int[] escCodes = CharTypes.get7BitOutputEscapes();
final int escCodeCount = escCodes.length;
@@ -77,7 +77,7 @@ public final class JsonUtils {
}
}
- private static int _appendNumeric(int value, char[] qbuf) {
+ private static int _appendNumeric(final int value, final char[] qbuf) {
qbuf[1] = 'u';
// We know it's a control char, so only the last 2 chars are non-0
qbuf[4] = HC[value >> 4];
@@ -85,7 +85,7 @@ public final class JsonUtils {
return 6;
}
- private static int _appendNamed(int esc, char[] qbuf) {
+ private static int _appendNamed(final int esc, final char[] qbuf) {
qbuf[1] = (char) esc;
return 2;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 a2011cb..a9c3548 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
@@ -59,7 +59,7 @@ public final class StringEncoder {
* @return the encoded String
* @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1151">LOG4J2-1151</a>
*/
- public static byte[] encodeSingleByteChars(CharSequence s) {
+ public static byte[] encodeSingleByteChars(final CharSequence s) {
final int length = s.length();
final byte[] result = new byte[length];
encodeString(s, 0, length, result);
@@ -71,7 +71,7 @@ public final class StringEncoder {
* Implementation note: this is the fast path. If the char array contains only ISO-8859-1 characters, all the work
* will be done here.
*/
- public static int encodeIsoChars(CharSequence charArray, int charIndex, byte[] byteArray, int byteIndex, int length) {
+ 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++);
@@ -84,7 +84,7 @@ public final class StringEncoder {
}
// LOG4J2-1151
- public static int encodeString(CharSequence charArray, int charOffset, int charLength, byte[] byteArray) {
+ public static int encodeString(final CharSequence charArray, int charOffset, int charLength, final byte[] byteArray) {
int byteOffset = 0;
int length = Math.min(charLength, byteArray.length);
int charDoneIndex = charOffset + length;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 146bff7..746c2d5 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
@@ -40,11 +40,11 @@ public class WatchManager extends AbstractLifeCycle {
private ScheduledFuture<?> future;
private final ConfigurationScheduler scheduler;
- public WatchManager(ConfigurationScheduler scheduler) {
+ public WatchManager(final ConfigurationScheduler scheduler) {
this.scheduler = scheduler;
}
- public void setIntervalSeconds(int intervalSeconds) {
+ public void setIntervalSeconds(final int intervalSeconds) {
if (!isStarted()) {
if (this.intervalSeconds > 0 && intervalSeconds == 0) {
scheduler.decrementScheduledItems();
@@ -74,7 +74,7 @@ public class WatchManager extends AbstractLifeCycle {
super.stop();
}
- public void watchFile(File file, FileWatcher watcher) {
+ public void watchFile(final File file, final FileWatcher watcher) {
watchers.put(file, new FileMonitor(file.lastModified(), watcher));
}
@@ -103,7 +103,7 @@ public class WatchManager extends AbstractLifeCycle {
}
}
- private boolean fileModified(FileMonitor fileMonitor, long lastModfied) {
+ private boolean fileModified(final FileMonitor fileMonitor, final long lastModfied) {
return lastModfied != fileMonitor.lastModified;
}
}
@@ -112,7 +112,7 @@ public class WatchManager extends AbstractLifeCycle {
private final FileWatcher fileWatcher;
private long lastModified;
- public FileMonitor(long lastModified, FileWatcher fileWatcher) {
+ public FileMonitor(final long lastModified, final FileWatcher fileWatcher) {
this.fileWatcher = fileWatcher;
this.lastModified = lastModified;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 631d334..e36bba1 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
@@ -1,343 +1,343 @@
-/*
- * 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.util.datetime;
-
-import java.util.Calendar;
-import java.util.Objects;
-
-/**
- * Custom time formatter that trades flexibility for performance. This formatter only supports the date patterns defined
- * in {@link FixedFormat}. For any other date patterns use {@link FastDateFormat}.
- * <p>
- * Related benchmarks: /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java and
- * /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
- */
-public class FixedDateFormat {
- /**
- * Enumeration over the supported date/time format patterns.
- * <p>
- * Package protected for unit tests.
- */
- public enum FixedFormat {
- /**
- * ABSOLUTE time format: {@code "HH:mm:ss,SSS"}.
- */
- ABSOLUTE("HH:mm:ss,SSS", null, 0, ':', 1, ',', 1),
-
- /**
- * ABSOLUTE time format variation with period separator: {@code "HH:mm:ss.SSS"}.
- */
- ABSOLUTE_PERIOD("HH:mm:ss.SSS", null, 0, ':', 1, '.', 1),
-
- /**
- * COMPACT time format: {@code "yyyyMMddHHmmssSSS"}.
- */
- COMPACT("yyyyMMddHHmmssSSS", "yyyyMMdd", 0, ' ', 0, ' ', 0),
-
- /**
- * DATE_AND_TIME time format: {@code "dd MMM yyyy HH:mm:ss,SSS"}.
- */
- DATE("dd MMM yyyy HH:mm:ss,SSS", "dd MMM yyyy ", 0, ':', 1, ',', 1),
-
- /**
- * DATE_AND_TIME time format variation with period separator: {@code "dd MMM yyyy HH:mm:ss.SSS"}.
- */
- DATE_PERIOD("dd MMM yyyy HH:mm:ss.SSS", "dd MMM yyyy ", 0, ':', 1, '.', 1),
-
- /**
- * DEFAULT time format: {@code "yyyy-MM-dd HH:mm:ss,SSS"}.
- */
- DEFAULT("yyyy-MM-dd HH:mm:ss,SSS", "yyyy-MM-dd ", 0, ':', 1, ',', 1),
-
- /**
- * DEFAULT time format variation with period separator: {@code "yyyy-MM-dd HH:mm:ss.SSS"}.
- */
- DEFAULT_PERIOD("yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd ", 0, ':', 1, '.', 1),
-
- /**
- * ISO8601_BASIC time format: {@code "yyyyMMdd'T'HHmmss,SSS"}.
- */
- ISO8601_BASIC("yyyyMMdd'T'HHmmss,SSS", "yyyyMMdd'T'", 2, ' ', 0, ',', 1),
-
- /**
- * ISO8601 time format: {@code "yyyy-MM-dd'T'HH:mm:ss,SSS"}.
- */
- ISO8601("yyyy-MM-dd'T'HH:mm:ss,SSS", "yyyy-MM-dd'T'", 2, ':', 1, ',', 1);
-
- private final String pattern;
- private final String datePattern;
- private final int escapeCount;
- private final char timeSeparatorChar;
- private final int timeSeparatorLength;
- private final char millisSeparatorChar;
- private final int millisSeparatorLength;
-
- FixedFormat(final String pattern, final String datePattern, final int escapeCount, final char timeSeparator,
- final int timeSepLength, final char millisSeparator, final int millisSepLength) {
- this.timeSeparatorChar = timeSeparator;
- this.timeSeparatorLength = timeSepLength;
- this.millisSeparatorChar = millisSeparator;
- this.millisSeparatorLength = millisSepLength;
- this.pattern = Objects.requireNonNull(pattern);
- this.datePattern = datePattern; // may be null
- this.escapeCount = escapeCount;
- }
-
- /**
- * Returns the full pattern.
- *
- * @return the full pattern
- */
- public String getPattern() {
- return pattern;
- }
-
- /**
- * Returns the date part of the pattern.
- *
- * @return the date part of the pattern
- */
- public String getDatePattern() {
- return datePattern;
- }
-
- /**
- * Returns the FixedFormat with the name or pattern matching the specified string or {@code null} if not found.
- *
- * @param nameOrPattern the name or pattern to find a FixedFormat for
- * @return the FixedFormat with the name or pattern matching the specified string
- */
- public static FixedFormat lookup(final String nameOrPattern) {
- for (final FixedFormat type : FixedFormat.values()) {
- if (type.name().equals(nameOrPattern) || type.getPattern().equals(nameOrPattern)) {
- return type;
- }
- }
- return null;
- }
-
- /**
- * Returns the length of the resulting formatted date and time strings.
- *
- * @return the length of the resulting formatted date and time strings
- */
- public int getLength() {
- return pattern.length() - escapeCount;
- }
-
- /**
- * Returns the length of the date part of the resulting formatted string.
- *
- * @return the length of the date part of the resulting formatted string
- */
- public int getDatePatternLength() {
- return getDatePattern() == null ? 0 : getDatePattern().length() - escapeCount;
- }
-
- /**
- * Returns the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null} if the
- * pattern does not have a date part.
- *
- * @return the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null}
- */
- public FastDateFormat getFastDateFormat() {
- return getDatePattern() == null ? null : FastDateFormat.getInstance(getDatePattern());
- }
- }
-
- private final FixedFormat fixedFormat;
- private final int length;
- private final FastDateFormat fastDateFormat; // may be null
- private final char timeSeparatorChar;
- private final char millisSeparatorChar;
- private final int timeSeparatorLength;
- private final int millisSeparatorLength;
-
- private volatile long midnightToday = 0;
- private volatile long midnightTomorrow = 0;
- // cachedDate does not need to be volatile because
- // there is a write to a volatile field *after* cachedDate is modified,
- // and there is a read from a volatile field *before* cachedDate is read.
- // The Java memory model guarantees that because of the above,
- // changes to cachedDate in one thread are visible to other threads.
- // See http://g.oswego.edu/dl/jmm/cookbook.html
- private char[] cachedDate; // may be null
- private int dateLength;
-
- /**
- * Constructs a FixedDateFormat for the specified fixed format.
- * <p>
- * Package protected for unit tests.
- *
- * @param fixedFormat the fixed format
- */
- FixedDateFormat(final FixedFormat fixedFormat) {
- this.fixedFormat = Objects.requireNonNull(fixedFormat);
- this.timeSeparatorChar = fixedFormat.timeSeparatorChar;
- this.timeSeparatorLength = fixedFormat.timeSeparatorLength;
- this.millisSeparatorChar = fixedFormat.millisSeparatorChar;
- this.millisSeparatorLength = fixedFormat.millisSeparatorLength;
- this.length = fixedFormat.getLength();
- this.fastDateFormat = fixedFormat.getFastDateFormat();
- }
-
- public static FixedDateFormat createIfSupported(final String... options) {
- if (options == null || options.length == 0 || options[0] == null) {
- return new FixedDateFormat(FixedFormat.DEFAULT);
- }
- if (options.length > 1) {
- return null; // time zone not supported
- }
- final FixedFormat type = FixedFormat.lookup(options[0]);
- return type == null ? null : new FixedDateFormat(type);
- }
-
- /**
- * Returns a new {@code FixedDateFormat} object for the specified {@code FixedFormat} and a {@code null} TimeZone.
- *
- * @param format the format to use
- * @return a new {@code FixedDateFormat} object
- */
- public static FixedDateFormat create(FixedFormat format) {
- return new FixedDateFormat(format);
- }
-
- /**
- * Returns the full pattern of the selected fixed format.
- *
- * @return the full date-time pattern
- */
- public String getFormat() {
- return fixedFormat.getPattern();
- }
-
- // Profiling showed this method is important to log4j performance. Modify with care!
- // 30 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
- private long millisSinceMidnight(final long now) {
- if (now >= midnightTomorrow || now < midnightToday) {
- updateMidnightMillis(now);
- }
- return now - midnightToday;
- }
-
- private void updateMidnightMillis(final long now) {
-
- updateCachedDate(now);
-
- midnightToday = calcMidnightMillis(now, 0);
- midnightTomorrow = calcMidnightMillis(now, 1);
- }
-
- static long calcMidnightMillis(final long time, final int addDays) {
- final Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(time);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- cal.add(Calendar.DATE, addDays);
- return cal.getTimeInMillis();
- }
-
- private void updateCachedDate(final long now) {
- if (fastDateFormat != null) {
- final StringBuilder result = fastDateFormat.format(now, new StringBuilder());
- cachedDate = result.toString().toCharArray();
- dateLength = result.length();
- }
- }
-
- // Profiling showed this method is important to log4j performance. Modify with care!
- // 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);
- return new String(result, 0, written);
- }
-
- // Profiling showed this method is important to log4j performance. Modify with care!
- // 31 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
- public int format(final long time, final char[] buffer, final int startPos) {
- // Calculate values by getting the ms values first and do then
- // calculate the hour minute and second values divisions.
-
- // Get daytime in ms: this does fit into an int
- // int ms = (int) (time % 86400000);
- final int ms = (int) (millisSinceMidnight(time));
- writeDate(buffer, startPos);
- return writeTime(ms, buffer, startPos + dateLength) - startPos;
- }
-
- // Profiling showed this method is important to log4j performance. Modify with care!
- // 22 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
- private void writeDate(final char[] buffer, final int startPos) {
- if (cachedDate != null) {
- System.arraycopy(cachedDate, 0, buffer, startPos, dateLength);
- }
- }
-
- // Profiling showed this method is important to log4j performance. Modify with care!
- // 262 bytes (will be inlined when hot enough: <= -XX:FreqInlineSize=325 bytes on Linux)
- private int writeTime(int ms, final char[] buffer, int pos) {
- final int hours = ms / 3600000;
- ms -= 3600000 * hours;
-
- final int minutes = ms / 60000;
- ms -= 60000 * minutes;
-
- final int seconds = ms / 1000;
- ms -= 1000 * seconds;
-
- // Hour
- int temp = hours / 10;
- buffer[pos++] = ((char) (temp + '0'));
-
- // Do subtract to get remainder instead of doing % 10
- buffer[pos++] = ((char) (hours - 10 * temp + '0'));
- buffer[pos] = timeSeparatorChar;
- pos += timeSeparatorLength;
-
- // Minute
- temp = minutes / 10;
- buffer[pos++] = ((char) (temp + '0'));
-
- // Do subtract to get remainder instead of doing % 10
- buffer[pos++] = ((char) (minutes - 10 * temp + '0'));
- buffer[pos] = timeSeparatorChar;
- pos += timeSeparatorLength;
-
- // Second
- temp = seconds / 10;
- buffer[pos++] = ((char) (temp + '0'));
- buffer[pos++] = ((char) (seconds - 10 * temp + '0'));
- buffer[pos] = millisSeparatorChar;
- pos += millisSeparatorLength;
-
- // Millisecond
- temp = ms / 100;
- buffer[pos++] = ((char) (temp + '0'));
-
- ms -= 100 * temp;
- temp = ms / 10;
- buffer[pos++] = ((char) (temp + '0'));
-
- ms -= 10 * temp;
- buffer[pos++] = ((char) (ms + '0'));
- return pos;
- }
-}
+/*
+ * 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.util.datetime;
+
+import java.util.Calendar;
+import java.util.Objects;
+
+/**
+ * Custom time formatter that trades flexibility for performance. This formatter only supports the date patterns defined
+ * in {@link FixedFormat}. For any other date patterns use {@link FastDateFormat}.
+ * <p>
+ * Related benchmarks: /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java and
+ * /log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadsafeDateFormatBenchmark.java
+ */
+public class FixedDateFormat {
+ /**
+ * Enumeration over the supported date/time format patterns.
+ * <p>
+ * Package protected for unit tests.
+ */
+ public enum FixedFormat {
+ /**
+ * ABSOLUTE time format: {@code "HH:mm:ss,SSS"}.
+ */
+ ABSOLUTE("HH:mm:ss,SSS", null, 0, ':', 1, ',', 1),
+
+ /**
+ * ABSOLUTE time format variation with period separator: {@code "HH:mm:ss.SSS"}.
+ */
+ ABSOLUTE_PERIOD("HH:mm:ss.SSS", null, 0, ':', 1, '.', 1),
+
+ /**
+ * COMPACT time format: {@code "yyyyMMddHHmmssSSS"}.
+ */
+ COMPACT("yyyyMMddHHmmssSSS", "yyyyMMdd", 0, ' ', 0, ' ', 0),
+
+ /**
+ * DATE_AND_TIME time format: {@code "dd MMM yyyy HH:mm:ss,SSS"}.
+ */
+ DATE("dd MMM yyyy HH:mm:ss,SSS", "dd MMM yyyy ", 0, ':', 1, ',', 1),
+
+ /**
+ * DATE_AND_TIME time format variation with period separator: {@code "dd MMM yyyy HH:mm:ss.SSS"}.
+ */
+ DATE_PERIOD("dd MMM yyyy HH:mm:ss.SSS", "dd MMM yyyy ", 0, ':', 1, '.', 1),
+
+ /**
+ * DEFAULT time format: {@code "yyyy-MM-dd HH:mm:ss,SSS"}.
+ */
+ DEFAULT("yyyy-MM-dd HH:mm:ss,SSS", "yyyy-MM-dd ", 0, ':', 1, ',', 1),
+
+ /**
+ * DEFAULT time format variation with period separator: {@code "yyyy-MM-dd HH:mm:ss.SSS"}.
+ */
+ DEFAULT_PERIOD("yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd ", 0, ':', 1, '.', 1),
+
+ /**
+ * ISO8601_BASIC time format: {@code "yyyyMMdd'T'HHmmss,SSS"}.
+ */
+ ISO8601_BASIC("yyyyMMdd'T'HHmmss,SSS", "yyyyMMdd'T'", 2, ' ', 0, ',', 1),
+
+ /**
+ * ISO8601 time format: {@code "yyyy-MM-dd'T'HH:mm:ss,SSS"}.
+ */
+ ISO8601("yyyy-MM-dd'T'HH:mm:ss,SSS", "yyyy-MM-dd'T'", 2, ':', 1, ',', 1);
+
+ private final String pattern;
+ private final String datePattern;
+ private final int escapeCount;
+ private final char timeSeparatorChar;
+ private final int timeSeparatorLength;
+ private final char millisSeparatorChar;
+ private final int millisSeparatorLength;
+
+ FixedFormat(final String pattern, final String datePattern, final int escapeCount, final char timeSeparator,
+ final int timeSepLength, final char millisSeparator, final int millisSepLength) {
+ this.timeSeparatorChar = timeSeparator;
+ this.timeSeparatorLength = timeSepLength;
+ this.millisSeparatorChar = millisSeparator;
+ this.millisSeparatorLength = millisSepLength;
+ this.pattern = Objects.requireNonNull(pattern);
+ this.datePattern = datePattern; // may be null
+ this.escapeCount = escapeCount;
+ }
+
+ /**
+ * Returns the full pattern.
+ *
+ * @return the full pattern
+ */
+ public String getPattern() {
+ return pattern;
+ }
+
+ /**
+ * Returns the date part of the pattern.
+ *
+ * @return the date part of the pattern
+ */
+ public String getDatePattern() {
+ return datePattern;
+ }
+
+ /**
+ * Returns the FixedFormat with the name or pattern matching the specified string or {@code null} if not found.
+ *
+ * @param nameOrPattern the name or pattern to find a FixedFormat for
+ * @return the FixedFormat with the name or pattern matching the specified string
+ */
+ public static FixedFormat lookup(final String nameOrPattern) {
+ for (final FixedFormat type : FixedFormat.values()) {
+ if (type.name().equals(nameOrPattern) || type.getPattern().equals(nameOrPattern)) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the length of the resulting formatted date and time strings.
+ *
+ * @return the length of the resulting formatted date and time strings
+ */
+ public int getLength() {
+ return pattern.length() - escapeCount;
+ }
+
+ /**
+ * Returns the length of the date part of the resulting formatted string.
+ *
+ * @return the length of the date part of the resulting formatted string
+ */
+ public int getDatePatternLength() {
+ return getDatePattern() == null ? 0 : getDatePattern().length() - escapeCount;
+ }
+
+ /**
+ * Returns the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null} if the
+ * pattern does not have a date part.
+ *
+ * @return the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null}
+ */
+ public FastDateFormat getFastDateFormat() {
+ return getDatePattern() == null ? null : FastDateFormat.getInstance(getDatePattern());
+ }
+ }
+
+ private final FixedFormat fixedFormat;
+ private final int length;
+ private final FastDateFormat fastDateFormat; // may be null
+ private final char timeSeparatorChar;
+ private final char millisSeparatorChar;
+ private final int timeSeparatorLength;
+ private final int millisSeparatorLength;
+
+ private volatile long midnightToday = 0;
+ private volatile long midnightTomorrow = 0;
+ // cachedDate does not need to be volatile because
+ // there is a write to a volatile field *after* cachedDate is modified,
+ // and there is a read from a volatile field *before* cachedDate is read.
+ // The Java memory model guarantees that because of the above,
+ // changes to cachedDate in one thread are visible to other threads.
+ // See http://g.oswego.edu/dl/jmm/cookbook.html
+ private char[] cachedDate; // may be null
+ private int dateLength;
+
+ /**
+ * Constructs a FixedDateFormat for the specified fixed format.
+ * <p>
+ * Package protected for unit tests.
+ *
+ * @param fixedFormat the fixed format
+ */
+ FixedDateFormat(final FixedFormat fixedFormat) {
+ this.fixedFormat = Objects.requireNonNull(fixedFormat);
+ this.timeSeparatorChar = fixedFormat.timeSeparatorChar;
+ this.timeSeparatorLength = fixedFormat.timeSeparatorLength;
+ this.millisSeparatorChar = fixedFormat.millisSeparatorChar;
+ this.millisSeparatorLength = fixedFormat.millisSeparatorLength;
+ this.length = fixedFormat.getLength();
+ this.fastDateFormat = fixedFormat.getFastDateFormat();
+ }
+
+ public static FixedDateFormat createIfSupported(final String... options) {
+ if (options == null || options.length == 0 || options[0] == null) {
+ return new FixedDateFormat(FixedFormat.DEFAULT);
+ }
+ if (options.length > 1) {
+ return null; // time zone not supported
+ }
+ final FixedFormat type = FixedFormat.lookup(options[0]);
+ return type == null ? null : new FixedDateFormat(type);
+ }
+
+ /**
+ * Returns a new {@code FixedDateFormat} object for the specified {@code FixedFormat} and a {@code null} TimeZone.
+ *
+ * @param format the format to use
+ * @return a new {@code FixedDateFormat} object
+ */
+ public static FixedDateFormat create(final FixedFormat format) {
+ return new FixedDateFormat(format);
+ }
+
+ /**
+ * Returns the full pattern of the selected fixed format.
+ *
+ * @return the full date-time pattern
+ */
+ public String getFormat() {
+ return fixedFormat.getPattern();
+ }
+
+ // Profiling showed this method is important to log4j performance. Modify with care!
+ // 30 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
+ private long millisSinceMidnight(final long now) {
+ if (now >= midnightTomorrow || now < midnightToday) {
+ updateMidnightMillis(now);
+ }
+ return now - midnightToday;
+ }
+
+ private void updateMidnightMillis(final long now) {
+
+ updateCachedDate(now);
+
+ midnightToday = calcMidnightMillis(now, 0);
+ midnightTomorrow = calcMidnightMillis(now, 1);
+ }
+
+ static long calcMidnightMillis(final long time, final int addDays) {
+ final Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(time);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ cal.add(Calendar.DATE, addDays);
+ return cal.getTimeInMillis();
+ }
+
+ private void updateCachedDate(final long now) {
+ if (fastDateFormat != null) {
+ final StringBuilder result = fastDateFormat.format(now, new StringBuilder());
+ cachedDate = result.toString().toCharArray();
+ dateLength = result.length();
+ }
+ }
+
+ // Profiling showed this method is important to log4j performance. Modify with care!
+ // 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);
+ return new String(result, 0, written);
+ }
+
+ // Profiling showed this method is important to log4j performance. Modify with care!
+ // 31 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
+ public int format(final long time, final char[] buffer, final int startPos) {
+ // Calculate values by getting the ms values first and do then
+ // calculate the hour minute and second values divisions.
+
+ // Get daytime in ms: this does fit into an int
+ // int ms = (int) (time % 86400000);
+ final int ms = (int) (millisSinceMidnight(time));
+ writeDate(buffer, startPos);
+ return writeTime(ms, buffer, startPos + dateLength) - startPos;
+ }
+
+ // Profiling showed this method is important to log4j performance. Modify with care!
+ // 22 bytes (allows immediate JVM inlining: <= -XX:MaxInlineSize=35 bytes)
+ private void writeDate(final char[] buffer, final int startPos) {
+ if (cachedDate != null) {
+ System.arraycopy(cachedDate, 0, buffer, startPos, dateLength);
+ }
+ }
+
+ // Profiling showed this method is important to log4j performance. Modify with care!
+ // 262 bytes (will be inlined when hot enough: <= -XX:FreqInlineSize=325 bytes on Linux)
+ private int writeTime(int ms, final char[] buffer, int pos) {
+ final int hours = ms / 3600000;
+ ms -= 3600000 * hours;
+
+ final int minutes = ms / 60000;
+ ms -= 60000 * minutes;
+
+ final int seconds = ms / 1000;
+ ms -= 1000 * seconds;
+
+ // Hour
+ int temp = hours / 10;
+ buffer[pos++] = ((char) (temp + '0'));
+
+ // Do subtract to get remainder instead of doing % 10
+ buffer[pos++] = ((char) (hours - 10 * temp + '0'));
+ buffer[pos] = timeSeparatorChar;
+ pos += timeSeparatorLength;
+
+ // Minute
+ temp = minutes / 10;
+ buffer[pos++] = ((char) (temp + '0'));
+
+ // Do subtract to get remainder instead of doing % 10
+ buffer[pos++] = ((char) (minutes - 10 * temp + '0'));
+ buffer[pos] = timeSeparatorChar;
+ pos += timeSeparatorLength;
+
+ // Second
+ temp = seconds / 10;
+ buffer[pos++] = ((char) (temp + '0'));
+ buffer[pos++] = ((char) (seconds - 10 * temp + '0'));
+ buffer[pos] = millisSeparatorChar;
+ pos += millisSeparatorLength;
+
+ // Millisecond
+ temp = ms / 100;
+ buffer[pos++] = ((char) (temp + '0'));
+
+ ms -= 100 * temp;
+ temp = ms / 10;
+ buffer[pos++] = ((char) (temp + '0'));
+
+ ms -= 10 * temp;
+ buffer[pos++] = ((char) (ms + '0'));
+ return pos;
+ }
+}
[04/10] logging-log4j2 git commit: Add final modifier to private
fields.
Posted by gg...@apache.org.
Add final modifier to private fields.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fe22ab84
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fe22ab84
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fe22ab84
Branch: refs/heads/master
Commit: fe22ab84e439673a4cd653d06ea953c9b1f25f3f
Parents: 2693d25
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 10:04:33 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 10:04:33 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/appender/CountingNoOpAppender.java | 2 +-
.../log4j/core/config/composite/CompositeConfiguration.java | 2 +-
.../apache/logging/log4j/core/async/perftest/ResponseTimeTest.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fe22ab84/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
index a8e48dc..8164aea 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/CountingNoOpAppender.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginFactory;
@Plugin(name = "CountingNoOp", category = "Core", elementType = "appender", printObject = true)
public class CountingNoOpAppender extends AbstractAppender {
- private AtomicLong total = new AtomicLong();
+ private final AtomicLong total = new AtomicLong();
public CountingNoOpAppender(String name, Layout<?> layout) {
super(name, null, layout);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fe22ab84/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 68fbc3b..60d98f0 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
@@ -52,7 +52,7 @@ public class CompositeConfiguration extends AbstractConfiguration implements Rec
private static final String[] VERBOSE_CLASSES = new String[] {ResolverUtil.class.getName()};
- private List<? extends AbstractConfiguration> configurations;
+ private final List<? extends AbstractConfiguration> configurations;
private MergeStrategy mergeStrategy;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fe22ab84/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 c584f7e..1ad25db 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
@@ -281,7 +281,7 @@ public class ResponseTimeTest {
private long unitsCompletedAtCatchUpStart;
private double catchUpThroughputInUnitsPerNsec;
private double catchUpRateMultiple;
- private IdleStrategy idleStrategy;
+ private final IdleStrategy idleStrategy;
public Pacer(double unitsPerSec, IdleStrategy idleStrategy) {
this(unitsPerSec, 3.0, idleStrategy); // Default to catching up at 3x the set throughput
[03/10] 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/2693d253
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2693d253
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2693d253
Branch: refs/heads/master
Commit: 2693d2531e5868f3dee866ab3c5527a3cd3fc777
Parents: d7a9ff7
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 10:02:48 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 10:02:48 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/CloseableThreadContext.java | 2 +-
.../java/org/apache/logging/log4j/LogManager.java | 18 +++++++++---------
.../logging/log4j/simple/SimpleLoggerContext.java | 4 ++--
.../apache/logging/log4j/spi/LoggerRegistry.java | 2 +-
.../org/apache/logging/log4j/spi/Provider.java | 4 ++--
.../apache/logging/log4j/status/StatusData.java | 2 +-
.../apache/logging/log4j/status/StatusLogger.java | 2 +-
.../org/apache/logging/log4j/util/LambdaUtil.java | 2 +-
.../java/org/apache/logging/log4j/util/Unbox.java | 16 ++++++++--------
.../apache/logging/log4j/AbstractLoggerTest.java | 4 ++--
.../org/apache/logging/log4j/LogManagerTest.java | 2 +-
.../java/org/apache/logging/log4j/LoggerTest.java | 16 ++++++++--------
.../apache/logging/log4j/TestLoggerContext.java | 4 ++--
.../org/apache/logging/log4j/util/UnboxTest.java | 6 +++---
14 files changed, 42 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java b/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
index b9a9cf0..e9317cf 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
@@ -143,7 +143,7 @@ public class CloseableThreadContext {
}
private void closeMap() {
- for (Iterator<Map.Entry<String, String>> it = originalValues.entrySet().iterator(); it.hasNext(); ) {
+ for (final Iterator<Map.Entry<String, String>> it = originalValues.entrySet().iterator(); it.hasNext(); ) {
final Map.Entry<String, String> entry = it.next();
final String key = entry.getKey();
final String originalValue = entry.getValue();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
index 9b651d6..a891103 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
@@ -153,7 +153,7 @@ public class LogManager {
public static LoggerContext getContext() {
try {
return factory.getContext(FQCN, null, null, true);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, null, null, true);
}
@@ -172,7 +172,7 @@ public class LogManager {
// TODO: would it be a terrible idea to try and find the caller ClassLoader here?
try {
return factory.getContext(FQCN, null, null, currentContext, null, null);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, null, null, currentContext, null, null);
}
@@ -192,7 +192,7 @@ public class LogManager {
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext) {
try {
return factory.getContext(FQCN, loader, null, currentContext);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, loader, null, currentContext);
}
@@ -214,7 +214,7 @@ public class LogManager {
final Object externalContext) {
try {
return factory.getContext(FQCN, loader, externalContext, currentContext);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, loader, externalContext, currentContext);
}
@@ -236,7 +236,7 @@ public class LogManager {
final URI configLocation) {
try {
return factory.getContext(FQCN, loader, null, currentContext, configLocation, null);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, loader, null, currentContext, configLocation,
null);
@@ -260,7 +260,7 @@ public class LogManager {
final Object externalContext, final URI configLocation) {
try {
return factory.getContext(FQCN, loader, externalContext, currentContext, configLocation, null);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, loader, externalContext, currentContext,
configLocation, null);
@@ -285,7 +285,7 @@ public class LogManager {
final Object externalContext, final URI configLocation, final String name) {
try {
return factory.getContext(FQCN, loader, externalContext, currentContext, configLocation, name);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, loader, externalContext, currentContext,
configLocation, name);
@@ -305,7 +305,7 @@ public class LogManager {
protected static LoggerContext getContext(final String fqcn, final boolean currentContext) {
try {
return factory.getContext(fqcn, null, null, currentContext);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(fqcn, null, null, currentContext);
}
@@ -327,7 +327,7 @@ public class LogManager {
final boolean currentContext) {
try {
return factory.getContext(fqcn, loader, null, currentContext);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(fqcn, loader, null, currentContext);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
index 4f71a10..3fe637f 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
@@ -117,12 +117,12 @@ public class SimpleLoggerContext implements LoggerContext {
}
@Override
- public boolean hasLogger(String name, MessageFactory messageFactory) {
+ public boolean hasLogger(final String name, final MessageFactory messageFactory) {
return false;
}
@Override
- public boolean hasLogger(String name, Class<? extends MessageFactory> messageFactoryClass) {
+ public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
return false;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java
index dbc8c0b..821f7a2 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerRegistry.java
@@ -130,7 +130,7 @@ public class LoggerRegistry<T extends ExtendedLogger> {
}
public Collection<T> getLoggers(final Collection<T> destination) {
- for (Map<String, T> inner : map.values()) {
+ for (final Map<String, T> inner : map.values()) {
destination.addAll(inner.values());
}
return destination;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java
index 837f501..357e3c6 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/Provider.java
@@ -88,7 +88,7 @@ public class Provider {
if (className == null) {
return null;
}
- ClassLoader loader = classLoader.get();
+ final ClassLoader loader = classLoader.get();
if (loader == null) {
return null;
}
@@ -121,7 +121,7 @@ public class Provider {
if (threadContextMap == null) {
return null;
}
- ClassLoader loader = classLoader.get();
+ final ClassLoader loader = classLoader.get();
if (loader == null) {
return null;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
index 65d24c8..463d9d0 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
@@ -51,7 +51,7 @@ public class StatusData implements Serializable {
* @param threadName The thread name
*/
public StatusData(final StackTraceElement caller, final Level level, final Message msg, final Throwable t,
- String threadName) {
+ final String threadName) {
this.timestamp = System.currentTimeMillis();
this.caller = caller;
this.level = level;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
index 902b444..bf8fd52 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
@@ -80,7 +80,7 @@ public final class StatusLogger extends AbstractLogger {
private int listenersLevel;
- private StatusLogger(String name, MessageFactory messageFactory) {
+ private StatusLogger(final String name, final MessageFactory messageFactory) {
super(name, messageFactory);
this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, true, false, false, Strings.EMPTY,
messageFactory, PROPS, System.err);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java
index 33b0d2a..a9f1684 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java
@@ -84,7 +84,7 @@ public final class LambdaUtil {
* @return the Message resulting from evaluating the lambda expression or the Message created by the factory for
* supplied values that are not of type Message
*/
- public static Message getMessage(Supplier<?> supplier, MessageFactory messageFactory) {
+ public static Message getMessage(final Supplier<?> supplier, final MessageFactory messageFactory) {
if (supplier == null) {
return null;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java
index 41e403b..ff09b4b 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java
@@ -69,7 +69,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(float value) {
+ public static StringBuilder box(final float value) {
return getSB().append(value);
}
@@ -81,7 +81,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(double value) {
+ public static StringBuilder box(final double value) {
return getSB().append(value);
}
@@ -93,7 +93,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(short value) {
+ public static StringBuilder box(final short value) {
return getSB().append(value);
}
@@ -105,7 +105,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(int value) {
+ public static StringBuilder box(final int value) {
return getSB().append(value);
}
@@ -117,7 +117,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(char value) {
+ public static StringBuilder box(final char value) {
return getSB().append(value);
}
@@ -129,7 +129,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(long value) {
+ public static StringBuilder box(final long value) {
return getSB().append(value);
}
@@ -141,7 +141,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(byte value) {
+ public static StringBuilder box(final byte value) {
return getSB().append(value);
}
@@ -153,7 +153,7 @@ public class Unbox {
* @return a {@code StringBuilder} containing the text representation of the specified primitive value
*/
@PerformanceSensitive("allocation")
- public static StringBuilder box(boolean value) {
+ public static StringBuilder box(final boolean value) {
return getSB().append(value);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
index d973610..348cda1 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
@@ -42,10 +42,10 @@ public class AbstractLoggerTest extends AbstractLogger {
// TODO add proper tests for ReusableMessage
@Before
public void before() throws Exception {
- Field field = AbstractLogger.class.getDeclaredField("messageFactory");
+ final Field field = AbstractLogger.class.getDeclaredField("messageFactory");
field.setAccessible(true); // make non-private
- Field modifierField = Field.class.getDeclaredField("modifiers");
+ final Field modifierField = Field.class.getDeclaredField("modifiers");
modifierField.setAccessible(true);
modifierField.setInt(field, field.getModifiers() &~ Modifier.FINAL); // make non-private
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
index 596a9f2..0bf0a0e 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
@@ -57,7 +57,7 @@ public class LogManagerTest {
@Test
public void testShutdown() {
- LoggerContext loggerContext = LogManager.getContext(false);
+ final LoggerContext loggerContext = LogManager.getContext(false);
LogManager.shutdown(loggerContext);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
index c4238fa..b01cc17 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
@@ -105,7 +105,7 @@ public class LoggerTest {
@Test
public void flowTracingString_ObjectArray2() {
- EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
+ final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit(msg, 3);
assertEquals(2, results.size());
assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
@@ -116,7 +116,7 @@ public class LoggerTest {
@Test
public void flowTracingVoidReturn() {
- EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
+ final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", 1, 2);
logger.traceExit(msg);
assertEquals(2, results.size());
assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
@@ -145,7 +145,7 @@ public class LoggerTest {
@Test
public void flowTracingString_SupplierOfObjectMessages() {
- EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", new Supplier<Message>() {
+ final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", new Supplier<Message>() {
@Override
public Message get() {
return new ObjectMessage(1);
@@ -166,7 +166,7 @@ public class LoggerTest {
@Test
public void flowTracingString_SupplierOfStrings() {
- EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", new Supplier<String>() {
+ final EntryMessage msg = logger.traceEntry("doFoo(a={}, b={})", new Supplier<String>() {
@Override
public String get() {
return "1";
@@ -254,7 +254,7 @@ public class LoggerTest {
assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE), testLogger.getEntries().get(0));
}
- private static void assertMessageFactoryInstanceOf(MessageFactory factory, Class cls) {
+ private static void assertMessageFactoryInstanceOf(MessageFactory factory, final Class cls) {
if (factory instanceof MessageFactory2Adapter) {
factory = ((MessageFactory2Adapter) factory).getOriginal();
}
@@ -546,7 +546,7 @@ public class LoggerTest {
int status;
String message;
- public Response(int status, String message) {
+ public Response(final int status, final String message) {
this.status = status;
this.message = message;
}
@@ -555,7 +555,7 @@ public class LoggerTest {
return status;
}
- public void setStatus(int status) {
+ public void setStatus(final int status) {
this.status = status;
}
@@ -563,7 +563,7 @@ public class LoggerTest {
return message;
}
- public void setMessage(String message) {
+ public void setMessage(final String message) {
this.message = message;
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java b/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java
index b0a5a82..7ca2fd6 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/TestLoggerContext.java
@@ -56,12 +56,12 @@ public class TestLoggerContext implements LoggerContext {
}
@Override
- public boolean hasLogger(String name, MessageFactory messageFactory) {
+ public boolean hasLogger(final String name, final MessageFactory messageFactory) {
return false;
}
@Override
- public boolean hasLogger(String name, Class<? extends MessageFactory> messageFactoryClass) {
+ public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass) {
return false;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2693d253/log4j-api/src/test/java/org/apache/logging/log4j/util/UnboxTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/util/UnboxTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/util/UnboxTest.java
index e0b2766..784fbe8 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/util/UnboxTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/util/UnboxTest.java
@@ -26,7 +26,7 @@ public class UnboxTest {
@Test
public void testBoxHas16Slots() throws Exception {
- StringBuilder[] probe = new StringBuilder[16 * 3];
+ final StringBuilder[] probe = new StringBuilder[16 * 3];
for (int i = 0; i <= probe.length - 8; ) {
probe[i++] = Unbox.box(true);
probe[i++] = Unbox.box('c');
@@ -118,7 +118,7 @@ public class UnboxTest {
public void testBoxIsThreadLocal() throws Exception {
final StringBuilder[] probe = new StringBuilder[16 * 3];
populate(0, probe);
- Thread t1 = new Thread() {
+ final Thread t1 = new Thread() {
@Override
public void run() {
populate(16, probe);
@@ -126,7 +126,7 @@ public class UnboxTest {
};
t1.start();
t1.join();
- Thread t2 = new Thread() {
+ final Thread t2 = new Thread() {
@Override
public void run() {
populate(16, probe);
[08/10] logging-log4j2 git commit: Add final modifier to method
parameters.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 f687ff4..5d8d4fd 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
@@ -92,8 +92,8 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
public void setValues(final AsyncLogger anAsyncLogger, final String aLoggerName, final Marker aMarker,
final String theFqcn, final Level aLevel, final Message msg, final Throwable aThrowable,
- final Map<String, String> aMap, final ContextStack aContextStack, long threadId,
- final String threadName, int threadPriority, final StackTraceElement aLocation, final long aCurrentTimeMillis, final long aNanoTime) {
+ final Map<String, String> aMap, final ContextStack aContextStack, final long threadId,
+ final String threadName, final int threadPriority, final StackTraceElement aLocation, final long aCurrentTimeMillis, final long aNanoTime) {
this.threadPriority = threadPriority;
this.threadId = threadId;
this.currentTimeMillis = aCurrentTimeMillis;
@@ -283,12 +283,12 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
}
@Override
- public char charAt(int index) {
+ public char charAt(final int index) {
return messageText.charAt(index);
}
@Override
- public CharSequence subSequence(int start, int end) {
+ public CharSequence subSequence(final int start, final int end) {
return messageText.subSequence(start, end);
}
@@ -439,7 +439,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
* Initializes the specified {@code Log4jLogEvent.Builder} from this {@code RingBufferLogEvent}.
* @param builder the builder whose fields to populate
*/
- public void initializeBuilder(Log4jLogEvent.Builder builder) {
+ public void initializeBuilder(final Log4jLogEvent.Builder builder) {
builder.setContextMap(contextMap) //
.setContextStack(contextStack) //
.setEndOfBatch(endOfBatch) //
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 316381a..3562ce4 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
@@ -155,7 +155,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
return scriptManager;
}
- public void setScriptManager(ScriptManager scriptManager) {
+ public void setScriptManager(final ScriptManager scriptManager) {
this.scriptManager = scriptManager;
}
@@ -163,7 +163,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
return pluginManager;
}
- public void setPluginManager(PluginManager pluginManager) {
+ public void setPluginManager(final PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
@@ -434,7 +434,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
componentMap.putIfAbsent(componentName, obj);
}
- protected void preConfigure(Node node) {
+ protected void preConfigure(final Node node) {
try {
for (final Node child : node.getChildren()) {
if (child.getType() == null) {
@@ -655,7 +655,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
* .core.config.LoggerConfig)
*/
@Override
- public ReliabilityStrategy getReliabilityStrategy(LoggerConfig loggerConfig) {
+ public ReliabilityStrategy getReliabilityStrategy(final LoggerConfig loggerConfig) {
return ReliabilityStrategyFactory.getReliabilityStrategy(loggerConfig);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
index 96467f1..ccc35d0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitCompletionReliabilityStrategy.java
@@ -1,175 +1,175 @@
-/*
- * 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 java.util.Objects;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.util.Supplier;
-
-/**
- * ReliabilityStrategy that counts the number of threads that have started to log an event but have not completed yet,
- * and waits for these threads to finish before allowing the appenders to be stopped.
- */
-public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
- private static final int MAX_RETRIES = 3;
- private final AtomicInteger counter = new AtomicInteger();
- private final AtomicBoolean shutdown = new AtomicBoolean(false);
- private final Lock shutdownLock = new ReentrantLock();
- private final Condition noLogEvents = shutdownLock.newCondition(); // should only be used when shutdown == true
- private final LoggerConfig loggerConfig;
-
- public AwaitCompletionReliabilityStrategy(final LoggerConfig loggerConfig) {
- this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
- * org.apache.logging.log4j.message.Message, java.lang.Throwable)
- */
- @Override
- public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn,
- final Marker marker, final Level level, final Message data, final Throwable t) {
-
- final LoggerConfig config = getActiveLoggerConfig(reconfigured);
- try {
- config.log(loggerName, fqcn, marker, level, data, t);
- } finally {
- config.getReliabilityStrategy().afterLogEvent();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * org.apache.logging.log4j.core.LogEvent)
- */
- @Override
- public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
- final LoggerConfig config = getActiveLoggerConfig(reconfigured);
- try {
- config.log(event);
- } finally {
- config.getReliabilityStrategy().afterLogEvent();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
- * LoggerConfig, org.apache.logging.log4j.util.Supplier)
- */
- @Override
- public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
- LoggerConfig result = this.loggerConfig;
- if (!beforeLogEvent()) {
- result = next.get();
- return result.getReliabilityStrategy().getActiveLoggerConfig(next);
- }
- return result;
- }
-
- private boolean beforeLogEvent() {
- return counter.incrementAndGet() > 0;
- }
-
- @Override
- public void afterLogEvent() {
- if (counter.decrementAndGet() == 0 && shutdown.get()) {
- signalCompletionIfShutdown();
- }
- }
-
- private void signalCompletionIfShutdown() {
- final Lock lock = shutdownLock;
- lock.lock();
- try {
- noLogEvents.signalAll();
- } finally {
- lock.unlock();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
- */
- @Override
- public void beforeStopAppenders() {
- waitForCompletion();
- }
-
- /**
- * Waits for all log events to complete before returning.
- */
- private void waitForCompletion() {
- shutdownLock.lock();
- try {
- if (shutdown.compareAndSet(false, true)) {
- int retries = 0;
- // repeat while counter is non-zero
- while (!counter.compareAndSet(0, Integer.MIN_VALUE)) {
-
- // counter was non-zero
- if (counter.get() < 0) { // this should not happen
- return; // but if it does, we are already done
- }
- // counter greater than zero, wait for afterLogEvent to decrease count
- try {
- noLogEvents.await(retries + 1, TimeUnit.SECONDS);
- } catch (final InterruptedException ie) {
- if (++retries > MAX_RETRIES) {
- break;
- }
- }
- }
- }
- } finally {
- shutdownLock.unlock();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
- * .config.Configuration)
- */
- @Override
- public void beforeStopConfiguration(Configuration configuration) {
- // no action
- }
-
-}
+/*
+ * 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 java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.util.Supplier;
+
+/**
+ * ReliabilityStrategy that counts the number of threads that have started to log an event but have not completed yet,
+ * and waits for these threads to finish before allowing the appenders to be stopped.
+ */
+public class AwaitCompletionReliabilityStrategy implements ReliabilityStrategy {
+ private static final int MAX_RETRIES = 3;
+ private final AtomicInteger counter = new AtomicInteger();
+ private final AtomicBoolean shutdown = new AtomicBoolean(false);
+ private final Lock shutdownLock = new ReentrantLock();
+ private final Condition noLogEvents = shutdownLock.newCondition(); // should only be used when shutdown == true
+ private final LoggerConfig loggerConfig;
+
+ public AwaitCompletionReliabilityStrategy(final LoggerConfig loggerConfig) {
+ this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
+ * org.apache.logging.log4j.message.Message, java.lang.Throwable)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn,
+ final Marker marker, final Level level, final Message data, final Throwable t) {
+
+ final LoggerConfig config = getActiveLoggerConfig(reconfigured);
+ try {
+ config.log(loggerName, fqcn, marker, level, data, t);
+ } finally {
+ config.getReliabilityStrategy().afterLogEvent();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * org.apache.logging.log4j.core.LogEvent)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
+ final LoggerConfig config = getActiveLoggerConfig(reconfigured);
+ try {
+ config.log(event);
+ } finally {
+ config.getReliabilityStrategy().afterLogEvent();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
+ * LoggerConfig, org.apache.logging.log4j.util.Supplier)
+ */
+ @Override
+ public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
+ LoggerConfig result = this.loggerConfig;
+ if (!beforeLogEvent()) {
+ result = next.get();
+ return result.getReliabilityStrategy().getActiveLoggerConfig(next);
+ }
+ return result;
+ }
+
+ private boolean beforeLogEvent() {
+ return counter.incrementAndGet() > 0;
+ }
+
+ @Override
+ public void afterLogEvent() {
+ if (counter.decrementAndGet() == 0 && shutdown.get()) {
+ signalCompletionIfShutdown();
+ }
+ }
+
+ private void signalCompletionIfShutdown() {
+ final Lock lock = shutdownLock;
+ lock.lock();
+ try {
+ noLogEvents.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
+ */
+ @Override
+ public void beforeStopAppenders() {
+ waitForCompletion();
+ }
+
+ /**
+ * Waits for all log events to complete before returning.
+ */
+ private void waitForCompletion() {
+ shutdownLock.lock();
+ try {
+ if (shutdown.compareAndSet(false, true)) {
+ int retries = 0;
+ // repeat while counter is non-zero
+ while (!counter.compareAndSet(0, Integer.MIN_VALUE)) {
+
+ // counter was non-zero
+ if (counter.get() < 0) { // this should not happen
+ return; // but if it does, we are already done
+ }
+ // counter greater than zero, wait for afterLogEvent to decrease count
+ try {
+ noLogEvents.await(retries + 1, TimeUnit.SECONDS);
+ } catch (final InterruptedException ie) {
+ if (++retries > MAX_RETRIES) {
+ break;
+ }
+ }
+ }
+ }
+ } finally {
+ shutdownLock.unlock();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
+ * .config.Configuration)
+ */
+ @Override
+ public void beforeStopConfiguration(final Configuration configuration) {
+ // no action
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 5e0456c..806a1f3 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
@@ -1,123 +1,123 @@
-/*
- * 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 java.util.Objects;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.PropertiesUtil;
-import org.apache.logging.log4j.util.Supplier;
-
-/**
- * Reliability strategy that sleeps unconditionally for some time before allowing a Configuration to be stopped.
- */
-public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrategy {
-
- private static final long DEFAULT_SLEEP_MILLIS = 5000; // 5 seconds
- private static final long SLEEP_MILLIS = sleepMillis();
- private final LoggerConfig loggerConfig;
-
- public AwaitUnconditionallyReliabilityStrategy(final LoggerConfig loggerConfig) {
- this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
- }
-
- private static long sleepMillis() {
- return PropertiesUtil.getProperties().getLongProperty("log4j.waitMillisBeforeStopOldConfig",
- DEFAULT_SLEEP_MILLIS);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
- * org.apache.logging.log4j.message.Message, java.lang.Throwable)
- */
- @Override
- public void log(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, Marker marker, Level level,
- Message data, Throwable t) {
- loggerConfig.log(loggerName, fqcn, marker, level, data, t);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * org.apache.logging.log4j.core.LogEvent)
- */
- @Override
- public void log(Supplier<LoggerConfig> reconfigured, LogEvent event) {
- loggerConfig.log(event);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
- * LoggerConfig, org.apache.logging.log4j.util.Supplier)
- */
- @Override
- public LoggerConfig getActiveLoggerConfig(Supplier<LoggerConfig> next) {
- return this.loggerConfig;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent()
- */
- @Override
- public void afterLogEvent() {
- // no action
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
- */
- @Override
- public void beforeStopAppenders() {
- // no action
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
- * .config.Configuration)
- */
- @Override
- public void beforeStopConfiguration(Configuration configuration) {
- // only sleep once per configuration stop
- if (loggerConfig == configuration.getRootLogger()) {
- try {
- Thread.sleep(SLEEP_MILLIS);
- } catch (InterruptedException e) {
- StatusLogger.getLogger().warn("Sleep before stop configuration was interrupted.");
- }
- }
- }
-
-}
+/*
+ * 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 java.util.Objects;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.PropertiesUtil;
+import org.apache.logging.log4j.util.Supplier;
+
+/**
+ * Reliability strategy that sleeps unconditionally for some time before allowing a Configuration to be stopped.
+ */
+public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrategy {
+
+ private static final long DEFAULT_SLEEP_MILLIS = 5000; // 5 seconds
+ private static final long SLEEP_MILLIS = sleepMillis();
+ private final LoggerConfig loggerConfig;
+
+ public AwaitUnconditionallyReliabilityStrategy(final LoggerConfig loggerConfig) {
+ this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
+ }
+
+ private static long sleepMillis() {
+ return PropertiesUtil.getProperties().getLongProperty("log4j.waitMillisBeforeStopOldConfig",
+ DEFAULT_SLEEP_MILLIS);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
+ * org.apache.logging.log4j.message.Message, java.lang.Throwable)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn, final Marker marker, final Level level,
+ final Message data, final Throwable t) {
+ loggerConfig.log(loggerName, fqcn, marker, level, data, t);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * org.apache.logging.log4j.core.LogEvent)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
+ loggerConfig.log(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
+ * LoggerConfig, org.apache.logging.log4j.util.Supplier)
+ */
+ @Override
+ public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
+ return this.loggerConfig;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent()
+ */
+ @Override
+ public void afterLogEvent() {
+ // no action
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
+ */
+ @Override
+ public void beforeStopAppenders() {
+ // no action
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
+ * .config.Configuration)
+ */
+ @Override
+ public void beforeStopConfiguration(final Configuration configuration) {
+ // only sleep once per configuration stop
+ if (loggerConfig == configuration.getRootLogger()) {
+ try {
+ Thread.sleep(SLEEP_MILLIS);
+ } catch (InterruptedException e) {
+ StatusLogger.getLogger().warn("Sleep before stop configuration was interrupted.");
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 32cfe90..05c5823 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
@@ -458,7 +458,7 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
return new DefaultConfiguration();
}
- private Configuration getConfiguration(String configLocationStr) {
+ private Configuration getConfiguration(final String configLocationStr) {
ConfigurationSource source = null;
try {
source = getInputFromUri(NetUtils.toURI(configLocationStr));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ed2c277..50b8194 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
@@ -91,7 +91,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @return a ScheduledFuture that can be used to extract result or cancel.
*
*/
- public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+ public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
return executorService.schedule(callable, delay, unit);
}
@@ -103,7 +103,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @return a ScheduledFuture representing pending completion of the task and whose get() method will return null
* upon completion.
*/
- public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
+ public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
return executorService.schedule(command, delay, unit);
}
@@ -114,7 +114,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @param command The Runnable to run,
* @return a ScheduledFuture representing the next time the command will run.
*/
- public CronScheduledFuture<?> scheduleWithCron(CronExpression cronExpression, Runnable command) {
+ 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);
@@ -134,7 +134,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an
* exception upon cancellation
*/
- public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
+ public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period, final TimeUnit unit) {
return executorService.scheduleAtFixedRate(command, initialDelay, period, unit);
}
@@ -148,7 +148,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an
* exception upon cancellation
*/
- public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
+ public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, final long initialDelay, final long delay, final TimeUnit unit) {
return executorService.scheduleWithFixedDelay(command, initialDelay, delay, unit);
}
@@ -158,12 +158,12 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
private final Runnable runnable;
private CronScheduledFuture<?> scheduledFuture;
- public CronRunnable(Runnable runnable, CronExpression cronExpression) {
+ public CronRunnable(final Runnable runnable, final CronExpression cronExpression) {
this.cronExpression = cronExpression;
this.runnable = runnable;
}
- public void setScheduledFuture(CronScheduledFuture<?> future) {
+ public void setScheduledFuture(final CronScheduledFuture<?> future) {
this.scheduledFuture = future;
}
@@ -180,7 +180,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle {
}
}
- private long nextFireInterval(CronExpression cronExpression) {
+ private long nextFireInterval(final CronExpression cronExpression) {
Date now = new Date();
Date fireDate = cronExpression.getNextValidTimeAfter(now);
return fireDate.getTime() - now.getTime();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
index 82d06ab..ceb6b57 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java
@@ -30,7 +30,7 @@ public class ConfiguratonFileWatcher implements FileWatcher {
private final Reconfigurable reconfigurable;
private final List<ConfigurationListener> listeners;
- public ConfiguratonFileWatcher(Reconfigurable reconfigurable, final List<ConfigurationListener> listeners) {
+ public ConfiguratonFileWatcher(final Reconfigurable reconfigurable, final List<ConfigurationListener> listeners) {
this.reconfigurable = reconfigurable;
this.listeners = listeners;
}
@@ -41,7 +41,7 @@ public class ConfiguratonFileWatcher implements FileWatcher {
@Override
- public void fileModified(File file) {
+ public void fileModified(final File file) {
for (final ConfigurationListener listener : listeners) {
final Thread thread = new Log4jThread(new ReconfigurationWorker(listener, reconfigurable));
thread.setDaemon(true);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 147c20f..f152ac3 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
@@ -1,344 +1,344 @@
-/*
- * 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 java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.impl.Log4jContextFactory;
-import org.apache.logging.log4j.core.util.NetUtils;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Initializes and configure the Logging system. This class provides several ways to construct a LoggerContext using
- * the location of a configuration file, a context name, and various optional parameters.
- */
-public final class Configurator {
-
- private static final String FQCN = Configurator.class.getName();
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static Log4jContextFactory getFactory() {
- final LoggerContextFactory factory = LogManager.getFactory();
- if (factory instanceof Log4jContextFactory) {
- return (Log4jContextFactory) factory;
- } else if (factory != null) {
- LOGGER.error("LogManager returned an instance of {} which does not implement {}. Unable to initialize Log4j.",
- factory.getClass().getName(), Log4jContextFactory.class.getName());
- return null;
- } else {
- LOGGER.fatal("LogManager did not return a LoggerContextFactory. This indicates something has gone terribly wrong!");
- return null;
- }
- }
-
- /**
- * Initializes the Logging Context.
- * @param loader The ClassLoader for the Context (or null).
- * @param source The InputSource for the configuration.
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(final ClassLoader loader,
- final ConfigurationSource source) {
- return initialize(loader, source, null);
- }
-
- /**
- * Initializes the Logging Context.
- * @param loader The ClassLoader for the Context (or null).
- * @param source The InputSource for the configuration.
- * @param externalContext The external context to be attached to the LoggerContext.
- * @return The LoggerContext.
- */
-
- public static LoggerContext initialize(final ClassLoader loader,
- final ConfigurationSource source,
- final Object externalContext)
- {
-
- try {
- final Log4jContextFactory factory = getFactory();
- return factory == null ? null :
- factory.getContext(FQCN, loader, externalContext, false, source);
- } catch (final Exception ex) {
- LOGGER.error("There was a problem obtaining a LoggerContext using the configuration source [{}]", source, ex);
- }
- return null;
- }
-
- /**
- * Initializes the Logging Context.
- * @param name The Context name.
- * @param loader The ClassLoader for the Context (or null).
- * @param configLocation The configuration for the logging context.
- * @return The LoggerContext or null if an error occurred (check the status logger).
- */
- public static LoggerContext initialize(final String name, final ClassLoader loader, final String configLocation) {
- return initialize(name, loader, configLocation, null);
-
- }
-
- /**
- * Initializes the Logging Context.
- * @param name The Context name.
- * @param loader The ClassLoader for the Context (or null).
- * @param configLocation The configuration for the logging context (or null, or blank).
- * @param externalContext The external context to be attached to the LoggerContext
- * @return The LoggerContext or null if an error occurred (check the status logger).
- */
- public static LoggerContext initialize(final String name, final ClassLoader loader, final String configLocation,
- final Object externalContext) {
- if (Strings.isBlank(configLocation)) {
- return initialize(name, loader, (URI) null, externalContext);
- }
- if (configLocation.contains(",")) {
- 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());
- if (scheme == null && uri.getScheme() != null) {
- scheme = uri.getScheme();
- }
- uris.add(uri);
- }
- return initialize(name, loader, uris, externalContext);
- } else {
- return initialize(name, loader, NetUtils.toURI(configLocation), externalContext);
- }
- }
-
- /**
- * Initializes the Logging Context.
- * @param name The Context name.
- * @param loader The ClassLoader for the Context (or null).
- * @param configLocation The configuration for the logging context.
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(final String name, final ClassLoader loader, final URI configLocation) {
- return initialize(name, loader, configLocation, null);
- }
-
- /**
- * Initializes the Logging Context.
- * @param name The Context name.
- * @param loader The ClassLoader for the Context (or null).
- * @param configLocation The configuration for the logging context (or null).
- * @param externalContext The external context to be attached to the LoggerContext
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(final String name, final ClassLoader loader, final URI configLocation,
- final Object externalContext) {
-
- try {
- final Log4jContextFactory factory = getFactory();
- return factory == null ? null :
- factory.getContext(FQCN, loader, externalContext, false, configLocation, name);
- } catch (final Exception ex) {
- LOGGER.error("There was a problem initializing the LoggerContext [{}] using configuration at [{}].",
- name, configLocation, ex);
- }
- return null;
- }
-
- public static LoggerContext initialize(final String name, final ClassLoader loader, final List<URI> configLocations,
- final Object externalContext) {
- try {
- final Log4jContextFactory factory = getFactory();
- return factory == null ?
- null :
- factory.getContext(FQCN, loader, externalContext, false, configLocations, name);
- } catch (final Exception ex) {
- LOGGER.error("There was a problem initializing the LoggerContext [{}] using configurations at [{}].", name,
- configLocations, ex);
- }
- return null;
- }
-
- /**
- * Initializes the Logging Context.
- * @param name The Context name.
- * @param configLocation The configuration for the logging context.
- * @return The LoggerContext or null if an error occurred (check the status logger).
- */
- public static LoggerContext initialize(final String name, final String configLocation) {
- return initialize(name, null, configLocation);
- }
-
- /**
- * Initializes the Logging Context.
- * @param configuration The Configuration.
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(Configuration configuration) {
- return initialize(null, configuration, null);
- }
-
- /**
- * Initializes the Logging Context.
- * @param loader The ClassLoader.
- * @param configuration The Configuration.
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(final ClassLoader loader, Configuration configuration) {
- return initialize(loader, configuration, null);
- }
-
- /**
- * Initializes the Logging Context.
- * @param loader The ClassLoader.
- * @param configuration The Configuration.
- * @param externalContext - The external context to be attached to the LoggerContext.
- * @return The LoggerContext.
- */
- public static LoggerContext initialize(final ClassLoader loader, Configuration configuration, final Object externalContext) {
- try {
- final Log4jContextFactory factory = getFactory();
- return factory == null ? null :
- factory.getContext(FQCN, loader, externalContext, false, configuration);
- } catch (final Exception ex) {
- LOGGER.error("There was a problem initializing the LoggerContext using configuration {}",
- configuration.getName(), ex);
- }
- return null;
- }
-
- /**
- * Sets the levels of <code>parentLogger</code> and all 'child' loggers to the given <code>level</code>.
- * @param parentLogger the parent logger
- * @param level the new level
- */
- public static void setAllLevels(final String parentLogger, final Level level) {
- // 1) get logger config
- // 2) if exact match, use it, if not, create it.
- // 3) set level on logger config
- // 4) update child logger configs with level
- // 5) update loggers
- final LoggerContext loggerContext = LoggerContext.getContext(false);
- final Configuration config = loggerContext.getConfiguration();
- boolean set = setLevel(parentLogger, level, config);
- for (final Map.Entry<String, LoggerConfig> entry : config.getLoggers().entrySet()) {
- if (entry.getKey().startsWith(parentLogger)) {
- set |= setLevel(entry.getValue(), level);
- }
- }
- if (set) {
- loggerContext.updateLoggers();
- }
- }
-
- private static boolean setLevel(final LoggerConfig loggerConfig, final Level level) {
- final boolean set = !loggerConfig.getLevel().equals(level);
- if (set) {
- loggerConfig.setLevel(level);
- }
- return set;
- }
-
- /**
- * Sets logger levels.
- *
- * @param levelMap
- * a levelMap where keys are level names and values are new
- * Levels.
- */
- public static void setLevel(final Map<String, Level> levelMap) {
- final LoggerContext loggerContext = LoggerContext.getContext(false);
- final Configuration config = loggerContext.getConfiguration();
- boolean set = false;
- for (final Map.Entry<String, Level> entry : levelMap.entrySet()) {
- final String loggerName = entry.getKey();
- final Level level = entry.getValue();
- set |= setLevel(loggerName, level, config);
- }
- if (set) {
- loggerContext.updateLoggers();
- }
- }
-
- /**
- * Sets a logger's level.
- *
- * @param loggerName
- * the logger name
- * @param level
- * the new level
- */
- public static void setLevel(final String loggerName, final Level level) {
- final LoggerContext loggerContext = LoggerContext.getContext(false);
- if (Strings.isEmpty(loggerName)) {
- setRootLevel(level);
- } else {
- if (setLevel(loggerName, level, loggerContext.getConfiguration())) {
- loggerContext.updateLoggers();
- }
- }
- }
-
- private static boolean setLevel(final String loggerName, final Level level, final Configuration config) {
- boolean set;
- LoggerConfig loggerConfig = config.getLoggerConfig(loggerName);
- if (!loggerName.equals(loggerConfig.getName())) {
- // TODO Should additivity be inherited?
- loggerConfig = new LoggerConfig(loggerName, level, true);
- config.addLogger(loggerName, loggerConfig);
- loggerConfig.setLevel(level);
- set = true;
- } else {
- set = setLevel(loggerConfig, level);
- }
- return set;
- }
-
- /**
- * Sets the root logger's level.
- *
- * @param level
- * the new level
- */
- public static void setRootLevel(final Level level) {
- final LoggerContext loggerContext = LoggerContext.getContext(false);
- final LoggerConfig loggerConfig = loggerContext.getConfiguration().getRootLogger();
- if (!loggerConfig.getLevel().equals(level)) {
- loggerConfig.setLevel(level);
- loggerContext.updateLoggers();
- }
- }
-
- /**
- * Shuts down the given logging context.
- * @param ctx the logging context to shut down, may be null.
- */
- public static void shutdown(final LoggerContext ctx) {
- if (ctx != null) {
- ctx.stop();
- }
- }
-
- private Configurator() {
- // empty
- }
-}
+/*
+ * 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 java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.impl.Log4jContextFactory;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.apache.logging.log4j.spi.LoggerContextFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.Strings;
+
+/**
+ * Initializes and configure the Logging system. This class provides several ways to construct a LoggerContext using
+ * the location of a configuration file, a context name, and various optional parameters.
+ */
+public final class Configurator {
+
+ private static final String FQCN = Configurator.class.getName();
+
+ private static final Logger LOGGER = StatusLogger.getLogger();
+
+ private static Log4jContextFactory getFactory() {
+ final LoggerContextFactory factory = LogManager.getFactory();
+ if (factory instanceof Log4jContextFactory) {
+ return (Log4jContextFactory) factory;
+ } else if (factory != null) {
+ LOGGER.error("LogManager returned an instance of {} which does not implement {}. Unable to initialize Log4j.",
+ factory.getClass().getName(), Log4jContextFactory.class.getName());
+ return null;
+ } else {
+ LOGGER.fatal("LogManager did not return a LoggerContextFactory. This indicates something has gone terribly wrong!");
+ return null;
+ }
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param source The InputSource for the configuration.
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final ClassLoader loader,
+ final ConfigurationSource source) {
+ return initialize(loader, source, null);
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param source The InputSource for the configuration.
+ * @param externalContext The external context to be attached to the LoggerContext.
+ * @return The LoggerContext.
+ */
+
+ public static LoggerContext initialize(final ClassLoader loader,
+ final ConfigurationSource source,
+ final Object externalContext)
+ {
+
+ try {
+ final Log4jContextFactory factory = getFactory();
+ return factory == null ? null :
+ factory.getContext(FQCN, loader, externalContext, false, source);
+ } catch (final Exception ex) {
+ LOGGER.error("There was a problem obtaining a LoggerContext using the configuration source [{}]", source, ex);
+ }
+ return null;
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param name The Context name.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param configLocation The configuration for the logging context.
+ * @return The LoggerContext or null if an error occurred (check the status logger).
+ */
+ public static LoggerContext initialize(final String name, final ClassLoader loader, final String configLocation) {
+ return initialize(name, loader, configLocation, null);
+
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param name The Context name.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param configLocation The configuration for the logging context (or null, or blank).
+ * @param externalContext The external context to be attached to the LoggerContext
+ * @return The LoggerContext or null if an error occurred (check the status logger).
+ */
+ public static LoggerContext initialize(final String name, final ClassLoader loader, final String configLocation,
+ final Object externalContext) {
+ if (Strings.isBlank(configLocation)) {
+ return initialize(name, loader, (URI) null, externalContext);
+ }
+ if (configLocation.contains(",")) {
+ 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());
+ if (scheme == null && uri.getScheme() != null) {
+ scheme = uri.getScheme();
+ }
+ uris.add(uri);
+ }
+ return initialize(name, loader, uris, externalContext);
+ } else {
+ return initialize(name, loader, NetUtils.toURI(configLocation), externalContext);
+ }
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param name The Context name.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param configLocation The configuration for the logging context.
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final String name, final ClassLoader loader, final URI configLocation) {
+ return initialize(name, loader, configLocation, null);
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param name The Context name.
+ * @param loader The ClassLoader for the Context (or null).
+ * @param configLocation The configuration for the logging context (or null).
+ * @param externalContext The external context to be attached to the LoggerContext
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final String name, final ClassLoader loader, final URI configLocation,
+ final Object externalContext) {
+
+ try {
+ final Log4jContextFactory factory = getFactory();
+ return factory == null ? null :
+ factory.getContext(FQCN, loader, externalContext, false, configLocation, name);
+ } catch (final Exception ex) {
+ LOGGER.error("There was a problem initializing the LoggerContext [{}] using configuration at [{}].",
+ name, configLocation, ex);
+ }
+ return null;
+ }
+
+ public static LoggerContext initialize(final String name, final ClassLoader loader, final List<URI> configLocations,
+ final Object externalContext) {
+ try {
+ final Log4jContextFactory factory = getFactory();
+ return factory == null ?
+ null :
+ factory.getContext(FQCN, loader, externalContext, false, configLocations, name);
+ } catch (final Exception ex) {
+ LOGGER.error("There was a problem initializing the LoggerContext [{}] using configurations at [{}].", name,
+ configLocations, ex);
+ }
+ return null;
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param name The Context name.
+ * @param configLocation The configuration for the logging context.
+ * @return The LoggerContext or null if an error occurred (check the status logger).
+ */
+ public static LoggerContext initialize(final String name, final String configLocation) {
+ return initialize(name, null, configLocation);
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param configuration The Configuration.
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final Configuration configuration) {
+ return initialize(null, configuration, null);
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param loader The ClassLoader.
+ * @param configuration The Configuration.
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final ClassLoader loader, final Configuration configuration) {
+ return initialize(loader, configuration, null);
+ }
+
+ /**
+ * Initializes the Logging Context.
+ * @param loader The ClassLoader.
+ * @param configuration The Configuration.
+ * @param externalContext - The external context to be attached to the LoggerContext.
+ * @return The LoggerContext.
+ */
+ public static LoggerContext initialize(final ClassLoader loader, final Configuration configuration, final Object externalContext) {
+ try {
+ final Log4jContextFactory factory = getFactory();
+ return factory == null ? null :
+ factory.getContext(FQCN, loader, externalContext, false, configuration);
+ } catch (final Exception ex) {
+ LOGGER.error("There was a problem initializing the LoggerContext using configuration {}",
+ configuration.getName(), ex);
+ }
+ return null;
+ }
+
+ /**
+ * Sets the levels of <code>parentLogger</code> and all 'child' loggers to the given <code>level</code>.
+ * @param parentLogger the parent logger
+ * @param level the new level
+ */
+ public static void setAllLevels(final String parentLogger, final Level level) {
+ // 1) get logger config
+ // 2) if exact match, use it, if not, create it.
+ // 3) set level on logger config
+ // 4) update child logger configs with level
+ // 5) update loggers
+ final LoggerContext loggerContext = LoggerContext.getContext(false);
+ final Configuration config = loggerContext.getConfiguration();
+ boolean set = setLevel(parentLogger, level, config);
+ for (final Map.Entry<String, LoggerConfig> entry : config.getLoggers().entrySet()) {
+ if (entry.getKey().startsWith(parentLogger)) {
+ set |= setLevel(entry.getValue(), level);
+ }
+ }
+ if (set) {
+ loggerContext.updateLoggers();
+ }
+ }
+
+ private static boolean setLevel(final LoggerConfig loggerConfig, final Level level) {
+ final boolean set = !loggerConfig.getLevel().equals(level);
+ if (set) {
+ loggerConfig.setLevel(level);
+ }
+ return set;
+ }
+
+ /**
+ * Sets logger levels.
+ *
+ * @param levelMap
+ * a levelMap where keys are level names and values are new
+ * Levels.
+ */
+ public static void setLevel(final Map<String, Level> levelMap) {
+ final LoggerContext loggerContext = LoggerContext.getContext(false);
+ final Configuration config = loggerContext.getConfiguration();
+ boolean set = false;
+ for (final Map.Entry<String, Level> entry : levelMap.entrySet()) {
+ final String loggerName = entry.getKey();
+ final Level level = entry.getValue();
+ set |= setLevel(loggerName, level, config);
+ }
+ if (set) {
+ loggerContext.updateLoggers();
+ }
+ }
+
+ /**
+ * Sets a logger's level.
+ *
+ * @param loggerName
+ * the logger name
+ * @param level
+ * the new level
+ */
+ public static void setLevel(final String loggerName, final Level level) {
+ final LoggerContext loggerContext = LoggerContext.getContext(false);
+ if (Strings.isEmpty(loggerName)) {
+ setRootLevel(level);
+ } else {
+ if (setLevel(loggerName, level, loggerContext.getConfiguration())) {
+ loggerContext.updateLoggers();
+ }
+ }
+ }
+
+ private static boolean setLevel(final String loggerName, final Level level, final Configuration config) {
+ boolean set;
+ LoggerConfig loggerConfig = config.getLoggerConfig(loggerName);
+ if (!loggerName.equals(loggerConfig.getName())) {
+ // TODO Should additivity be inherited?
+ loggerConfig = new LoggerConfig(loggerName, level, true);
+ config.addLogger(loggerName, loggerConfig);
+ loggerConfig.setLevel(level);
+ set = true;
+ } else {
+ set = setLevel(loggerConfig, level);
+ }
+ return set;
+ }
+
+ /**
+ * Sets the root logger's level.
+ *
+ * @param level
+ * the new level
+ */
+ public static void setRootLevel(final Level level) {
+ final LoggerContext loggerContext = LoggerContext.getContext(false);
+ final LoggerConfig loggerConfig = loggerContext.getConfiguration().getRootLogger();
+ if (!loggerConfig.getLevel().equals(level)) {
+ loggerConfig.setLevel(level);
+ loggerContext.updateLoggers();
+ }
+ }
+
+ /**
+ * Shuts down the given logging context.
+ * @param ctx the logging context to shut down, may be null.
+ */
+ public static void shutdown(final LoggerContext ctx) {
+ if (ctx != null) {
+ ctx.stop();
+ }
+ }
+
+ private Configurator() {
+ // empty
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultReliabilityStrategy.java
index fd77429..18fcae4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultReliabilityStrategy.java
@@ -1,107 +1,107 @@
-/*
- * 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 java.util.Objects;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.util.Supplier;
-
-/**
- * Reliability strategy that assumes reconfigurations will never take place.
- */
-public class DefaultReliabilityStrategy implements ReliabilityStrategy {
-
- private final LoggerConfig loggerConfig;
-
- public DefaultReliabilityStrategy(final LoggerConfig loggerConfig) {
- this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
- * org.apache.logging.log4j.message.Message, java.lang.Throwable)
- */
- @Override
- public void log(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, Marker marker, Level level,
- Message data, Throwable t) {
- loggerConfig.log(loggerName, fqcn, marker, level, data, t);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * org.apache.logging.log4j.core.LogEvent)
- */
- @Override
- public void log(Supplier<LoggerConfig> reconfigured, LogEvent event) {
- loggerConfig.log(event);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
- * LoggerConfig, org.apache.logging.log4j.util.Supplier)
- */
- @Override
- public LoggerConfig getActiveLoggerConfig(Supplier<LoggerConfig> next) {
- return this.loggerConfig;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent()
- */
- @Override
- public void afterLogEvent() {
- // no action
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
- */
- @Override
- public void beforeStopAppenders() {
- // no action
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
- * .config.Configuration)
- */
- @Override
- public void beforeStopConfiguration(Configuration configuration) {
- // no action
- }
-
-}
+/*
+ * 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 java.util.Objects;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.util.Supplier;
+
+/**
+ * Reliability strategy that assumes reconfigurations will never take place.
+ */
+public class DefaultReliabilityStrategy implements ReliabilityStrategy {
+
+ private final LoggerConfig loggerConfig;
+
+ public DefaultReliabilityStrategy(final LoggerConfig loggerConfig) {
+ this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
+ * org.apache.logging.log4j.message.Message, java.lang.Throwable)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn, final Marker marker, final Level level,
+ final Message data, final Throwable t) {
+ loggerConfig.log(loggerName, fqcn, marker, level, data, t);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * org.apache.logging.log4j.core.LogEvent)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
+ loggerConfig.log(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
+ * LoggerConfig, org.apache.logging.log4j.util.Supplier)
+ */
+ @Override
+ public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
+ return this.loggerConfig;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent()
+ */
+ @Override
+ public void afterLogEvent() {
+ // no action
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
+ */
+ @Override
+ public void beforeStopAppenders() {
+ // no action
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
+ * .config.Configuration)
+ */
+ @Override
+ public void beforeStopConfiguration(final Configuration configuration) {
+ // no action
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
index f5fbfcc..c930f8b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LockingReliabilityStrategy.java
@@ -1,135 +1,135 @@
-/*
- * 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 java.util.Objects;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.util.Supplier;
-
-/**
- * ReliabilityStrategy that uses read/write locks to prevent the LoggerConfig from stopping while it is in use.
- */
-public class LockingReliabilityStrategy implements ReliabilityStrategy {
- private final LoggerConfig loggerConfig;
- private final ReadWriteLock reconfigureLock = new ReentrantReadWriteLock();
- private volatile boolean isStopping = false;
-
- public LockingReliabilityStrategy(final LoggerConfig loggerConfig) {
- this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig was null");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
- * org.apache.logging.log4j.message.Message, java.lang.Throwable)
- */
- @Override
- public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn,
- final Marker marker, final Level level, final Message data, final Throwable t) {
-
- final LoggerConfig config = getActiveLoggerConfig(reconfigured);
- try {
- config.log(loggerName, fqcn, marker, level, data, t);
- } finally {
- config.getReliabilityStrategy().afterLogEvent();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
- * org.apache.logging.log4j.core.LogEvent)
- */
- @Override
- public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
- final LoggerConfig config = getActiveLoggerConfig(reconfigured);
- try {
- config.log(event);
- } finally {
- config.getReliabilityStrategy().afterLogEvent();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
- * LoggerConfig, org.apache.logging.log4j.util.Supplier)
- */
- @Override
- public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
- LoggerConfig result = this.loggerConfig;
- if (!beforeLogEvent()) {
- result = next.get();
- return result.getReliabilityStrategy().getActiveLoggerConfig(next);
- }
- return result;
- }
-
- private boolean beforeLogEvent() {
- reconfigureLock.readLock().lock();
- if (isStopping) {
- reconfigureLock.readLock().unlock();
- return false;
- }
- return true;
- }
-
- @Override
- public void afterLogEvent() {
- reconfigureLock.readLock().unlock();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
- */
- @Override
- public void beforeStopAppenders() {
- reconfigureLock.writeLock().lock();
- try {
- isStopping = true;
- } finally {
- reconfigureLock.writeLock().unlock();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
- * .config.Configuration)
- */
- @Override
- public void beforeStopConfiguration(Configuration configuration) {
- // no action
- }
-
-}
+/*
+ * 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 java.util.Objects;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.util.Supplier;
+
+/**
+ * ReliabilityStrategy that uses read/write locks to prevent the LoggerConfig from stopping while it is in use.
+ */
+public class LockingReliabilityStrategy implements ReliabilityStrategy {
+ private final LoggerConfig loggerConfig;
+ private final ReadWriteLock reconfigureLock = new ReentrantReadWriteLock();
+ private volatile boolean isStopping = false;
+
+ public LockingReliabilityStrategy(final LoggerConfig loggerConfig) {
+ this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig was null");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level,
+ * org.apache.logging.log4j.message.Message, java.lang.Throwable)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final String loggerName, final String fqcn,
+ final Marker marker, final Level level, final Message data, final Throwable t) {
+
+ final LoggerConfig config = getActiveLoggerConfig(reconfigured);
+ try {
+ config.log(loggerName, fqcn, marker, level, data, t);
+ } finally {
+ config.getReliabilityStrategy().afterLogEvent();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier,
+ * org.apache.logging.log4j.core.LogEvent)
+ */
+ @Override
+ public void log(final Supplier<LoggerConfig> reconfigured, final LogEvent event) {
+ final LoggerConfig config = getActiveLoggerConfig(reconfigured);
+ try {
+ config.log(event);
+ } finally {
+ config.getReliabilityStrategy().afterLogEvent();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config.
+ * LoggerConfig, org.apache.logging.log4j.util.Supplier)
+ */
+ @Override
+ public LoggerConfig getActiveLoggerConfig(final Supplier<LoggerConfig> next) {
+ LoggerConfig result = this.loggerConfig;
+ if (!beforeLogEvent()) {
+ result = next.get();
+ return result.getReliabilityStrategy().getActiveLoggerConfig(next);
+ }
+ return result;
+ }
+
+ private boolean beforeLogEvent() {
+ reconfigureLock.readLock().lock();
+ if (isStopping) {
+ reconfigureLock.readLock().unlock();
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void afterLogEvent() {
+ reconfigureLock.readLock().unlock();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders()
+ */
+ @Override
+ public void beforeStopAppenders() {
+ reconfigureLock.writeLock().lock();
+ try {
+ isStopping = true;
+ } finally {
+ reconfigureLock.writeLock().unlock();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core
+ * .config.Configuration)
+ */
+ @Override
+ public void beforeStopConfiguration(final Configuration configuration) {
+ // no action
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
index 8043ff5..e26407a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
@@ -145,7 +145,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public T build(boolean initialize) {
+ public T build(final boolean initialize) {
T configuration;
try {
if (source == null) {
@@ -215,7 +215,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public LoggerComponentBuilder newAsyncLogger(final String name, final Level level, boolean includeLocation) {
+ public LoggerComponentBuilder newAsyncLogger(final String name, final Level level, final boolean includeLocation) {
return new DefaultLoggerComponentBuilder(this, name, level.toString(), "AsyncLogger", includeLocation);
}
@@ -225,7 +225,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public LoggerComponentBuilder newAsyncLogger(final String name, final String level, boolean includeLocation) {
+ public LoggerComponentBuilder newAsyncLogger(final String name, final String level, final boolean includeLocation) {
return new DefaultLoggerComponentBuilder(this, name, level, "AsyncLogger");
}
@@ -235,7 +235,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public RootLoggerComponentBuilder newAsyncRootLogger(final Level level, boolean includeLocation) {
+ public RootLoggerComponentBuilder newAsyncRootLogger(final Level level, final boolean includeLocation) {
return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot", includeLocation);
}
@@ -245,7 +245,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public RootLoggerComponentBuilder newAsyncRootLogger(final String level, boolean includeLocation) {
+ public RootLoggerComponentBuilder newAsyncRootLogger(final String level, final boolean includeLocation) {
return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot", includeLocation);
}
@@ -295,7 +295,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public LoggerComponentBuilder newLogger(final String name, final Level level, boolean includeLocation) {
+ public LoggerComponentBuilder newLogger(final String name, final Level level, final boolean includeLocation) {
return new DefaultLoggerComponentBuilder(this, name, level.toString(), includeLocation);
}
@@ -305,7 +305,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public LoggerComponentBuilder newLogger(final String name, final String level, boolean includeLocation) {
+ public LoggerComponentBuilder newLogger(final String name, final String level, final boolean includeLocation) {
return new DefaultLoggerComponentBuilder(this, name, level, includeLocation);
}
@@ -315,7 +315,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public RootLoggerComponentBuilder newRootLogger(final Level level, boolean includeLocation) {
+ public RootLoggerComponentBuilder newRootLogger(final Level level, final boolean includeLocation) {
return new DefaultRootLoggerComponentBuilder(this, level.toString(), includeLocation);
}
@@ -325,7 +325,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public RootLoggerComponentBuilder newRootLogger(final String level, boolean includeLocation) {
+ public RootLoggerComponentBuilder newRootLogger(final String level, final boolean includeLocation) {
return new DefaultRootLoggerComponentBuilder(this, level, includeLocation);
}
@@ -390,7 +390,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
}
@Override
- public ConfigurationBuilder<T> addRootProperty(String key, String value) {
+ public ConfigurationBuilder<T> addRootProperty(final String key, final String value) {
root.getAttributes().put(key, value);
return this;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
index 37aba83..891e795 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
@@ -47,7 +47,7 @@ class DefaultLoggerComponentBuilder extends DefaultComponentAndConfigurationBuil
* @param includeLocation
*/
public DefaultLoggerComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name,
- final String level, boolean includeLocation) {
+ final String level, final boolean includeLocation) {
super(builder, name, "Logger");
addAttribute("level", level);
addAttribute("includeLocation", includeLocation);
@@ -75,7 +75,7 @@ class DefaultLoggerComponentBuilder extends DefaultComponentAndConfigurationBuil
* @param includeLocation
*/
public DefaultLoggerComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name,
- final String level, final String type, boolean includeLocation) {
+ final String level, final String type, final boolean includeLocation) {
super(builder, name, type);
addAttribute("level", level);
addAttribute("includeLocation", includeLocation);
[02/10] 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/d7a9ff76
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d7a9ff76
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d7a9ff76
Branch: refs/heads/master
Commit: d7a9ff762b39e404d2609dc2ed723f07ab5bce06
Parents: 132e948
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 10:02:15 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 10:02:15 2016 -0700
----------------------------------------------------------------------
.../src/test/java/org/apache/log4j/LogWithMDCTest.java | 6 +++---
.../src/test/java/org/apache/log4j/LogWithRouteTest.java | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d7a9ff76/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
index e7c3345..c48e35e 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
@@ -39,11 +39,11 @@ public class LogWithMDCTest {
public void testMDC() throws Exception {
MDC.put("Key1", "John");
MDC.put("Key2", "Smith");
- Logger logger = Logger.getLogger("org.apache.test.logging");
+ final Logger logger = Logger.getLogger("org.apache.test.logging");
logger.debug("This is a test");
- ListAppender listApp = (ListAppender) CTX.getAppender("List");
+ final ListAppender listApp = (ListAppender) CTX.getAppender("List");
assertNotNull(listApp);
- List<String> msgs = listApp.getMessages();
+ final List<String> msgs = listApp.getMessages();
assertNotNull("No messages received", msgs);
assertTrue(msgs.size() == 1);
assertTrue("Key1 is missing", msgs.get(0).contains("Key1=John"));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d7a9ff76/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
index 1e7e964..06ad4e8 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
@@ -40,11 +40,11 @@ public class LogWithRouteTest {
public void testMDC() throws Exception {
MDC.put("Type", "Service");
MDC.put("Name", "John Smith");
- Logger logger = Logger.getLogger("org.apache.test.logging");
+ final Logger logger = Logger.getLogger("org.apache.test.logging");
logger.debug("This is a test");
- ListAppender listApp = (ListAppender) CTX.getAppender("List");
+ final ListAppender listApp = (ListAppender) CTX.getAppender("List");
assertNotNull(listApp);
- List<String> msgs = listApp.getMessages();
+ final List<String> msgs = listApp.getMessages();
assertNotNull("No messages received", msgs);
assertTrue(msgs.size() == 1);
assertTrue("Type is missing", msgs.get(0).contains("Type=Service"));
[10/10] logging-log4j2 git commit: Logo for 2.6.1.
Posted by gg...@apache.org.
Logo for 2.6.1.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/018ca8a3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/018ca8a3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/018ca8a3
Branch: refs/heads/master
Commit: 018ca8a30334c5a94263ecd1af2388c1299c8d0d
Parents: 7a5dcd4
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 3 11:01:12 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 3 11:01:12 2016 -0700
----------------------------------------------------------------------
src/site/resources/logo/logo-lightning-2.6.1.png | Bin 0 -> 41622 bytes
src/site/resources/logo/logo-lightning-2.6.1.xcf | Bin 0 -> 65630 bytes
2 files changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/018ca8a3/src/site/resources/logo/logo-lightning-2.6.1.png
----------------------------------------------------------------------
diff --git a/src/site/resources/logo/logo-lightning-2.6.1.png b/src/site/resources/logo/logo-lightning-2.6.1.png
new file mode 100644
index 0000000..7c30e4c
Binary files /dev/null and b/src/site/resources/logo/logo-lightning-2.6.1.png differ
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/018ca8a3/src/site/resources/logo/logo-lightning-2.6.1.xcf
----------------------------------------------------------------------
diff --git a/src/site/resources/logo/logo-lightning-2.6.1.xcf b/src/site/resources/logo/logo-lightning-2.6.1.xcf
new file mode 100644
index 0000000..7ff0b9c
Binary files /dev/null and b/src/site/resources/logo/logo-lightning-2.6.1.xcf differ
[06/10] logging-log4j2 git commit: Add final modifier to method
parameters.
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
index a74a35b..0e22b3e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
@@ -34,7 +34,7 @@ public class GcFreeAsynchronousLoggingTest {
/**
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName());
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsynchronousLoggingTest.class);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 ead935e..af12699 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
@@ -70,7 +70,7 @@ public class GcFreeLoggingTestUtil {
final AtomicBoolean samplingEnabled = new AtomicBoolean(true);
final Sampler sampler = new Sampler() {
@Override
- public void sampleAllocation(int count, String desc, Object newObj, long size) {
+ public void sampleAllocation(final int count, final String desc, final Object newObj, final long size) {
if (!samplingEnabled.get()) {
return;
}
@@ -108,7 +108,7 @@ public class GcFreeLoggingTestUtil {
Thread.sleep(100);
}
- public static void runTest(Class<?> cls) throws Exception {
+ public static void runTest(final Class<?> cls) throws Exception {
final String javaHome = System.getProperty("java.home");
final String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
final String classpath = System.getProperty("java.class.path");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
index c18861b..90a0dc5 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
@@ -34,7 +34,7 @@ public class GcFreeMixedSyncAyncLoggingTest {
/**
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
System.setProperty("AsyncLoggerConfig.RingBufferSize", "128"); // minimum ringbuffer size
GcFreeLoggingTestUtil.executeLogging("gcFreeMixedSyncAsyncLogging.xml", GcFreeMixedSyncAyncLoggingTest.class);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
index 731c2af..3787aa2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
@@ -34,7 +34,7 @@ public class GcFreeSynchronousLoggingTest {
/**
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeSynchronousLoggingTest.class);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 d074368..c64e7a0 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
@@ -105,7 +105,7 @@ public class AsyncAppenderQueueFullPolicyTest {
public static class CountingAsyncQueueFullPolicy extends DefaultAsyncQueueFullPolicy {
static AtomicLong queueFull = new AtomicLong();
@Override
- public EventRoute getRoute(long backgroundThreadId, Level level) {
+ public EventRoute getRoute(final long backgroundThreadId, final Level level) {
queueFull.incrementAndGet();
return EventRoute.ENQUEUE;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 2d002ea..83f2476 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
@@ -1,147 +1,147 @@
-/*
- * 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.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.kafka.clients.producer.MockProducer;
-import org.apache.kafka.clients.producer.Producer;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class KafkaAppenderTest {
-
- private static final MockProducer<byte[], byte[]> kafka = new MockProducer<byte[], byte[]>(true, null, null) {
- @Override
- public void close() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ignore) {
- }
- }
-
- @Override
- public void close(long timeout, TimeUnit timeUnit) {
- try {
- Thread.sleep(timeUnit.toMillis(timeout));
- } catch (InterruptedException ignore) {
- }
- }
- };
-
- private static final String LOG_MESSAGE = "Hello, world!";
- private static final String TOPIC_NAME = "kafka-topic";
-
- private static Log4jLogEvent createLogEvent() {
- return Log4jLogEvent.newBuilder()
- .setLoggerName(KafkaAppenderTest.class.getName())
- .setLoggerFqcn(KafkaAppenderTest.class.getName())
- .setLevel(Level.INFO)
- .setMessage(new SimpleMessage(LOG_MESSAGE))
- .build();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- KafkaManager.producerFactory = new KafkaProducerFactory() {
- @Override
- public Producer<byte[], byte[]> newKafkaProducer(final Properties config) {
- return kafka;
- }
- };
- }
-
- @Rule
- public LoggerContextRule ctx = new LoggerContextRule("KafkaAppenderTest.xml");
-
- @Before
- public void setUp() throws Exception {
- kafka.clear();
- }
-
- @Test
- public void testAppend() throws Exception {
- final Appender appender = ctx.getRequiredAppender("KafkaAppender");
- appender.append(createLogEvent());
- final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
- assertEquals(1, history.size());
- final ProducerRecord<byte[], byte[]> item = history.get(0);
- assertNotNull(item);
- assertEquals(TOPIC_NAME, item.topic());
- assertNull(item.key());
- assertEquals(LOG_MESSAGE, new String(item.value(), StandardCharsets.UTF_8));
- }
-
- @Test
- public void testAppendWithLayout() throws Exception {
- final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithLayout");
- appender.append(createLogEvent());
- final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
- assertEquals(1, history.size());
- final ProducerRecord<byte[], byte[]> item = history.get(0);
- assertNotNull(item);
- assertEquals(TOPIC_NAME, item.topic());
- assertNull(item.key());
- assertEquals("[" + LOG_MESSAGE + "]", new String(item.value(), StandardCharsets.UTF_8));
- }
-
- @Test
- public void testAppendWithSerializedLayout() throws Exception {
- final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithSerializedLayout");
- LogEvent logEvent = createLogEvent();
- appender.append(logEvent);
- final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
- assertEquals(1, history.size());
- final ProducerRecord<byte[], byte[]> item = history.get(0);
- assertNotNull(item);
- assertEquals(TOPIC_NAME, item.topic());
- assertNull(item.key());
- assertEquals(LOG_MESSAGE, deserializeLogEvent(item.value()).getMessage().getFormattedMessage());
- }
-
- private LogEvent deserializeLogEvent(byte[] data) throws IOException, ClassNotFoundException {
- ByteArrayInputStream bis = new ByteArrayInputStream(data);
- try (ObjectInput ois = new ObjectInputStream(bis)) {
- return (LogEvent) ois.readObject();
- }
- }
-
- @Test(timeout = 2000)
- public void testClose() throws Exception {
- final Appender appender = ctx.getRequiredAppender("KafkaAppender");
- appender.stop();
- }
+/*
+ * 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.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.kafka.clients.producer.MockProducer;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class KafkaAppenderTest {
+
+ private static final MockProducer<byte[], byte[]> kafka = new MockProducer<byte[], byte[]>(true, null, null) {
+ @Override
+ public void close() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ignore) {
+ }
+ }
+
+ @Override
+ public void close(final long timeout, final TimeUnit timeUnit) {
+ try {
+ Thread.sleep(timeUnit.toMillis(timeout));
+ } catch (InterruptedException ignore) {
+ }
+ }
+ };
+
+ private static final String LOG_MESSAGE = "Hello, world!";
+ private static final String TOPIC_NAME = "kafka-topic";
+
+ private static Log4jLogEvent createLogEvent() {
+ return Log4jLogEvent.newBuilder()
+ .setLoggerName(KafkaAppenderTest.class.getName())
+ .setLoggerFqcn(KafkaAppenderTest.class.getName())
+ .setLevel(Level.INFO)
+ .setMessage(new SimpleMessage(LOG_MESSAGE))
+ .build();
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ KafkaManager.producerFactory = new KafkaProducerFactory() {
+ @Override
+ public Producer<byte[], byte[]> newKafkaProducer(final Properties config) {
+ return kafka;
+ }
+ };
+ }
+
+ @Rule
+ public LoggerContextRule ctx = new LoggerContextRule("KafkaAppenderTest.xml");
+
+ @Before
+ public void setUp() throws Exception {
+ kafka.clear();
+ }
+
+ @Test
+ public void testAppend() throws Exception {
+ final Appender appender = ctx.getRequiredAppender("KafkaAppender");
+ appender.append(createLogEvent());
+ final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
+ assertEquals(1, history.size());
+ final ProducerRecord<byte[], byte[]> item = history.get(0);
+ assertNotNull(item);
+ assertEquals(TOPIC_NAME, item.topic());
+ assertNull(item.key());
+ assertEquals(LOG_MESSAGE, new String(item.value(), StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void testAppendWithLayout() throws Exception {
+ final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithLayout");
+ appender.append(createLogEvent());
+ final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
+ assertEquals(1, history.size());
+ final ProducerRecord<byte[], byte[]> item = history.get(0);
+ assertNotNull(item);
+ assertEquals(TOPIC_NAME, item.topic());
+ assertNull(item.key());
+ assertEquals("[" + LOG_MESSAGE + "]", new String(item.value(), StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void testAppendWithSerializedLayout() throws Exception {
+ final Appender appender = ctx.getRequiredAppender("KafkaAppenderWithSerializedLayout");
+ LogEvent logEvent = createLogEvent();
+ appender.append(logEvent);
+ final List<ProducerRecord<byte[], byte[]>> history = kafka.history();
+ assertEquals(1, history.size());
+ final ProducerRecord<byte[], byte[]> item = history.get(0);
+ assertNotNull(item);
+ assertEquals(TOPIC_NAME, item.topic());
+ assertNull(item.key());
+ assertEquals(LOG_MESSAGE, deserializeLogEvent(item.value()).getMessage().getFormattedMessage());
+ }
+
+ private LogEvent deserializeLogEvent(final byte[] data) throws IOException, ClassNotFoundException {
+ ByteArrayInputStream bis = new ByteArrayInputStream(data);
+ try (ObjectInput ois = new ObjectInputStream(bis)) {
+ return (LogEvent) ois.readObject();
+ }
+ }
+
+ @Test(timeout = 2000)
+ public void testClose() throws Exception {
+ final Appender appender = ctx.getRequiredAppender("KafkaAppender");
+ appender.stop();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 294d7c7..56bb8c5 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
@@ -91,7 +91,7 @@ public class RollingAppenderCustomDeleteActionTest {
}
}
- public static void main(String[] args) {
+ public static void main(final String[] args) {
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";
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 17686a7..4595b59 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
@@ -91,13 +91,13 @@ public class RollingAppenderDeleteAccumulatedCount1Test {
}
}
- private void updateLastModified(Path... paths) throws IOException {
+ private void updateLastModified(final Path... paths) throws IOException {
for (Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
- private Path writeTextTo(String location) throws IOException {
+ private Path writeTextTo(final String location) throws IOException {
Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 d2e471a..5d3e736 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
@@ -92,13 +92,13 @@ public class RollingAppenderDeleteAccumulatedCount2Test {
}
}
- private void updateLastModified(Path... paths) throws IOException {
+ private void updateLastModified(final Path... paths) throws IOException {
for (Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
- private Path writeTextTo(String location) throws IOException {
+ private Path writeTextTo(final String location) throws IOException {
Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 9c11416..e185d58 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
@@ -87,7 +87,7 @@ public class RollingAppenderDeleteMaxDepthTest {
assertTrue(p4 + " should not have been deleted", Files.exists(p4));
}
- private Path writeTextTo(String location) throws IOException {
+ private Path writeTextTo(final String location) throws IOException {
Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
@@ -109,7 +109,7 @@ public class RollingAppenderDeleteMaxDepthTest {
}
}
- public static void main(String[] args) {
+ public static void main(final String[] args) {
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";
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 7156abc..4fde77e 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
@@ -91,13 +91,13 @@ public class RollingAppenderDeleteNestedTest {
}
}
- private void updateLastModified(Path... paths) throws IOException {
+ private void updateLastModified(final Path... paths) throws IOException {
for (Path path : paths) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis() + 2000));
}
}
- private Path writeTextTo(String location) throws IOException {
+ private Path writeTextTo(final String location) throws IOException {
Path path = Paths.get(location);
Files.createDirectories(path.getParent());
try (BufferedWriter buffy = Files.newBufferedWriter(path, Charset.defaultCharset())) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 f25a9e7..adcfd68 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
@@ -96,7 +96,7 @@ public class RollingAppenderNoUnconditionalDeleteTest {
deleteDir(directory.getParentFile());
}
- private void deleteDir(File dir) {
+ private void deleteDir(final File dir) {
if (dir.exists()) {
final File[] files = dir.listFiles();
for (final File file : files) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/CountingCondition.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/CountingCondition.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/CountingCondition.java
index 9355582..12b61f6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/CountingCondition.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/CountingCondition.java
@@ -1,62 +1,62 @@
-/*
- * 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 org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
-
-/**
- * Test helper class.
- */
-public class CountingCondition implements PathCondition {
-
- private final boolean accept;
- private int acceptCount;
- private int beforeFileTreeWalkCount;
-
- public CountingCondition(boolean accept) {
- this.accept = accept;
- }
-
- @Override
- public boolean accept(Path baseDir, Path path, BasicFileAttributes attrs) {
- acceptCount++;
- return accept;
- }
-
- @Override
- public void beforeFileTreeWalk() {
- beforeFileTreeWalkCount++;
- }
-
- /**
- * @return the acceptCount
- */
- public int getAcceptCount() {
- return acceptCount;
- }
-
- /**
- * @return the beforeFileTreeWalkCount
- */
- public int getBeforeFileTreeWalkCount() {
- return beforeFileTreeWalkCount;
- }
-}
+/*
+ * 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 org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
+
+/**
+ * Test helper class.
+ */
+public class CountingCondition implements PathCondition {
+
+ private final boolean accept;
+ private int acceptCount;
+ private int beforeFileTreeWalkCount;
+
+ public CountingCondition(final boolean accept) {
+ this.accept = accept;
+ }
+
+ @Override
+ public boolean accept(final Path baseDir, final Path path, final BasicFileAttributes attrs) {
+ acceptCount++;
+ return accept;
+ }
+
+ @Override
+ public void beforeFileTreeWalk() {
+ beforeFileTreeWalkCount++;
+ }
+
+ /**
+ * @return the acceptCount
+ */
+ public int getAcceptCount() {
+ return acceptCount;
+ }
+
+ /**
+ * @return the beforeFileTreeWalkCount
+ */
+ public int getBeforeFileTreeWalkCount() {
+ return beforeFileTreeWalkCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 4a1f14c..c745dd3 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
@@ -1,119 +1,119 @@
-/*
- * 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.FileSystems;
-import java.nio.file.FileVisitOption;
-import java.nio.file.FileVisitor;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.EnumSet;
-
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.appender.rolling.action.DeleteAction;
-import org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor;
-import org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the {@code DeleteAction} class.
- */
-public class DeleteActionTest {
-
- private static DeleteAction createAnyFilter(String path, boolean followLinks, int maxDepth, boolean testMode) {
- PathCondition[] pathFilters = {new FixedCondition(true)};
- return create(path, followLinks, maxDepth, testMode, pathFilters);
- }
-
- private static DeleteAction create(String path, boolean followLinks, int maxDepth, boolean testMode,
- PathCondition[] conditions) {
- Configuration config = new BasicConfigurationFactory().new BasicConfiguration();
- 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);
-
- Path actual = delete.getBasePath();
- 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);
- assertEquals("${sys:user.home}/a/b/c", delete.getBasePathString());
- }
-
- @Test
- public void testGetMaxDepthReturnsConstructorValue() {
- DeleteAction delete = createAnyFilter("any", false, 23, false);
- assertEquals(23, delete.getMaxDepth());
- }
-
- @Test
- public void testGetOptionsReturnsEmptySetIfNotFollowingLinks() {
- DeleteAction delete = createAnyFilter("any", false, 0, false);
- assertEquals(Collections.emptySet(), delete.getOptions());
- }
-
- @Test
- public void testGetOptionsReturnsSetWithFollowLinksIfFollowingLinks() {
- 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)};
-
- 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());
- assertTrue(visitor instanceof DeletingVisitor);
- }
-
- @Test
- public void testCreateFileVisitorTestModeIsActionTestMode() {
- DeleteAction delete = createAnyFilter("any", true, 0, false);
- assertFalse(delete.isTestMode());
- FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
- assertTrue(visitor instanceof DeletingVisitor);
- assertFalse(((DeletingVisitor) visitor).isTestMode());
-
- DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true);
- assertTrue(deleteTestMode.isTestMode());
- FileVisitor<Path> testVisitor = deleteTestMode.createFileVisitor(delete.getBasePath(),
- delete.getPathConditions());
- assertTrue(testVisitor instanceof DeletingVisitor);
- assertTrue(((DeletingVisitor) testVisitor).isTestMode());
- }
-}
+/*
+ * 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.FileSystems;
+import java.nio.file.FileVisitOption;
+import java.nio.file.FileVisitor;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+
+import org.apache.logging.log4j.core.BasicConfigurationFactory;
+import org.apache.logging.log4j.core.appender.rolling.action.DeleteAction;
+import org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor;
+import org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the {@code DeleteAction} class.
+ */
+public class DeleteActionTest {
+
+ private static DeleteAction createAnyFilter(final String path, final boolean followLinks, final int maxDepth, final boolean testMode) {
+ 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,
+ null, config);
+ return delete;
+ }
+
+ @Test
+ public void testGetBasePathResolvesLookups() {
+ 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";
+
+ assertEquals(FileSystems.getDefault().getPath(expected), actual);
+ }
+
+ @Test
+ public void testGetBasePathStringReturnsOriginalParam() {
+ 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);
+ assertEquals(23, delete.getMaxDepth());
+ }
+
+ @Test
+ public void testGetOptionsReturnsEmptySetIfNotFollowingLinks() {
+ DeleteAction delete = createAnyFilter("any", false, 0, false);
+ assertEquals(Collections.emptySet(), delete.getOptions());
+ }
+
+ @Test
+ public void testGetOptionsReturnsSetWithFollowLinksIfFollowingLinks() {
+ 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)};
+
+ 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());
+ assertTrue(visitor instanceof DeletingVisitor);
+ }
+
+ @Test
+ public void testCreateFileVisitorTestModeIsActionTestMode() {
+ DeleteAction delete = createAnyFilter("any", true, 0, false);
+ assertFalse(delete.isTestMode());
+ FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
+ assertTrue(visitor instanceof DeletingVisitor);
+ assertFalse(((DeletingVisitor) visitor).isTestMode());
+
+ DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true);
+ assertTrue(deleteTestMode.isTestMode());
+ 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/7a5dcd43/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 4e96a2e..f35f44f 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
@@ -1,135 +1,135 @@
-/*
- * 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.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the {@code DeletingVisitor} class.
- */
-public class DeletingVisitorTest {
- /**
- * Modifies {@code DeletingVisitor} for testing: instead of actually deleting a file, it adds the path to a list for
- * later verification.
- */
- static class DeletingVisitorHelper extends DeletingVisitor {
- List<Path> deleted = new ArrayList<>();
-
- public DeletingVisitorHelper(final Path basePath, final List<? extends PathCondition> pathFilters,
- final boolean testMode) {
- super(basePath, pathFilters, testMode);
- }
-
- @Override
- protected void delete(final Path file) throws IOException {
- deleted.add(file); // overrides and stores path instead of deleting
- }
- }
-
- @Test
- public void testAcceptedFilesAreDeleted() throws IOException {
- Path base = Paths.get("/a/b/c");
- final FixedCondition ACCEPT_ALL = new FixedCondition(true);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(ACCEPT_ALL), false);
-
- 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 FixedCondition REJECT_ALL = new FixedCondition(false);
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(REJECT_ALL), false);
-
- 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 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);
-
- 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 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);
-
- 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 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);
-
- Path any = Paths.get("/a/b/c/any");
- visitor.visitFile(any, null);
- assertFalse(visitor.deleted.contains(any));
- }
-
- @Test
- public void testVisitFileRelativizesAgainstBase() throws IOException {
-
- PathCondition filter = new PathCondition() {
-
- @Override
- public boolean accept(Path baseDir, Path relativePath, BasicFileAttributes attrs) {
- Path expected = Paths.get("relative");
- assertEquals(expected, relativePath);
- return true;
- }
-
- @Override
- public void beforeFileTreeWalk() {
- }
- };
- Path base = Paths.get("/a/b/c");
- DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(filter), false);
-
- Path child = Paths.get("/a/b/c/relative");
- visitor.visitFile(child, null);
- }
-}
+/*
+ * 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.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the {@code DeletingVisitor} class.
+ */
+public class DeletingVisitorTest {
+ /**
+ * Modifies {@code DeletingVisitor} for testing: instead of actually deleting a file, it adds the path to a list for
+ * later verification.
+ */
+ static class DeletingVisitorHelper extends DeletingVisitor {
+ List<Path> deleted = new ArrayList<>();
+
+ public DeletingVisitorHelper(final Path basePath, final List<? extends PathCondition> pathFilters,
+ final boolean testMode) {
+ super(basePath, pathFilters, testMode);
+ }
+
+ @Override
+ protected void delete(final Path file) throws IOException {
+ deleted.add(file); // overrides and stores path instead of deleting
+ }
+ }
+
+ @Test
+ public void testAcceptedFilesAreDeleted() throws IOException {
+ Path base = Paths.get("/a/b/c");
+ final FixedCondition ACCEPT_ALL = new FixedCondition(true);
+ DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(ACCEPT_ALL), false);
+
+ 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 FixedCondition REJECT_ALL = new FixedCondition(false);
+ DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(REJECT_ALL), false);
+
+ 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 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);
+
+ 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 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);
+
+ 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 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);
+
+ Path any = Paths.get("/a/b/c/any");
+ visitor.visitFile(any, null);
+ assertFalse(visitor.deleted.contains(any));
+ }
+
+ @Test
+ public void testVisitFileRelativizesAgainstBase() throws IOException {
+
+ PathCondition filter = new PathCondition() {
+
+ @Override
+ public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
+ Path expected = Paths.get("relative");
+ assertEquals(expected, relativePath);
+ return true;
+ }
+
+ @Override
+ public void beforeFileTreeWalk() {
+ }
+ };
+ Path base = Paths.get("/a/b/c");
+ DeletingVisitorHelper visitor = new DeletingVisitorHelper(base, Arrays.asList(filter), false);
+
+ Path child = Paths.get("/a/b/c/relative");
+ visitor.visitFile(child, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FixedCondition.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FixedCondition.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FixedCondition.java
index e78f878..8815d5a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FixedCondition.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/FixedCondition.java
@@ -1,44 +1,44 @@
-/*
- * 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 org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
-
-/**
- * Test helper class.
- */
-public class FixedCondition implements PathCondition {
-
- private final boolean accept;
-
- public FixedCondition(boolean accept) {
- this.accept = accept;
- }
-
- @Override
- public boolean accept(Path baseDir, Path path, BasicFileAttributes attrs) {
- return accept;
- }
-
- @Override
- public void beforeFileTreeWalk() {
- }
-}
+/*
+ * 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 org.apache.logging.log4j.core.appender.rolling.action.PathCondition;
+
+/**
+ * Test helper class.
+ */
+public class FixedCondition implements PathCondition {
+
+ private final boolean accept;
+
+ public FixedCondition(final boolean accept) {
+ this.accept = accept;
+ }
+
+ @Override
+ public boolean accept(final Path baseDir, final Path path, final BasicFileAttributes attrs) {
+ return accept;
+ }
+
+ @Override
+ public void beforeFileTreeWalk() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 5158789..dcd5ffd 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
@@ -1,93 +1,93 @@
-/*
- * 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.nio.file.attribute.FileTime;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests the {@code PathSortByModificationTime} class.
- */
-public class PathSortByModificationTimeTest {
-
- /**
- * Test method for
- * {@link org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime#isRecentFirst()}.
- */
- @Test
- public void testIsRecentFirstReturnsConstructorValue() {
- assertTrue(((PathSortByModificationTime) PathSortByModificationTime.createSorter(true)).isRecentFirst());
- assertFalse(((PathSortByModificationTime) PathSortByModificationTime.createSorter(false)).isRecentFirst());
- }
-
- @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();
- a1.lastModified = FileTime.fromMillis(100);
- a2.lastModified = FileTime.fromMillis(222);
-
- assertEquals("same path, 2nd more recent", 1, sorter.compare(path(p1, a1), path(p1, a2)));
- assertEquals("path ignored, 2nd more recent", 1, sorter.compare(path(p1, a1), path(p2, a2)));
- assertEquals("path ignored, 2nd more recent", 1, sorter.compare(path(p2, a1), path(p1, a2)));
-
- assertEquals("same path, 1st more recent", -1, sorter.compare(path(p1, a2), path(p1, a1)));
- assertEquals("path ignored, 1st more recent", -1, sorter.compare(path(p1, a2), path(p2, a1)));
- assertEquals("path ignored, 1st more recent", -1, sorter.compare(path(p2, a2), path(p1, a1)));
-
- assertEquals("same path, same time", 0, sorter.compare(path(p1, a1), path(p1, a1)));
- assertEquals("p2 < p1, same time", 1, sorter.compare(path(p1, a1), path(p2, a1)));
- assertEquals("p2 < p1, same time", -1, sorter.compare(path(p2, a1), path(p1, a1)));
- }
-
- @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();
- a1.lastModified = FileTime.fromMillis(100);
- a2.lastModified = FileTime.fromMillis(222);
-
- assertEquals("same path, 2nd more recent", -1, sorter.compare(path(p1, a1), path(p1, a2)));
- assertEquals("path ignored, 2nd more recent", -1, sorter.compare(path(p1, a1), path(p2, a2)));
- assertEquals("path ignored, 2nd more recent", -1, sorter.compare(path(p2, a1), path(p1, a2)));
-
- assertEquals("same path, 1st more recent", 1, sorter.compare(path(p1, a2), path(p1, a1)));
- assertEquals("path ignored, 1st more recent", 1, sorter.compare(path(p1, a2), path(p2, a1)));
- assertEquals("path ignored, 1st more recent", 1, sorter.compare(path(p2, a2), path(p1, a1)));
-
- assertEquals("same path, same time", 0, sorter.compare(path(p1, a1), path(p1, a1)));
- assertEquals("p1 < p2, same time", -1, sorter.compare(path(p1, a1), path(p2, a1)));
- assertEquals("p1 < p2, same time", 1, sorter.compare(path(p2, a1), path(p1, a1)));
- }
-
- private PathWithAttributes path(Path path, DummyFileAttributes attributes) {
- return new PathWithAttributes(path, attributes);
- }
-
-}
+/*
+ * 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.nio.file.attribute.FileTime;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests the {@code PathSortByModificationTime} class.
+ */
+public class PathSortByModificationTimeTest {
+
+ /**
+ * Test method for
+ * {@link org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime#isRecentFirst()}.
+ */
+ @Test
+ public void testIsRecentFirstReturnsConstructorValue() {
+ assertTrue(((PathSortByModificationTime) PathSortByModificationTime.createSorter(true)).isRecentFirst());
+ assertFalse(((PathSortByModificationTime) PathSortByModificationTime.createSorter(false)).isRecentFirst());
+ }
+
+ @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();
+ a1.lastModified = FileTime.fromMillis(100);
+ a2.lastModified = FileTime.fromMillis(222);
+
+ assertEquals("same path, 2nd more recent", 1, sorter.compare(path(p1, a1), path(p1, a2)));
+ assertEquals("path ignored, 2nd more recent", 1, sorter.compare(path(p1, a1), path(p2, a2)));
+ assertEquals("path ignored, 2nd more recent", 1, sorter.compare(path(p2, a1), path(p1, a2)));
+
+ assertEquals("same path, 1st more recent", -1, sorter.compare(path(p1, a2), path(p1, a1)));
+ assertEquals("path ignored, 1st more recent", -1, sorter.compare(path(p1, a2), path(p2, a1)));
+ assertEquals("path ignored, 1st more recent", -1, sorter.compare(path(p2, a2), path(p1, a1)));
+
+ assertEquals("same path, same time", 0, sorter.compare(path(p1, a1), path(p1, a1)));
+ assertEquals("p2 < p1, same time", 1, sorter.compare(path(p1, a1), path(p2, a1)));
+ assertEquals("p2 < p1, same time", -1, sorter.compare(path(p2, a1), path(p1, a1)));
+ }
+
+ @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();
+ a1.lastModified = FileTime.fromMillis(100);
+ a2.lastModified = FileTime.fromMillis(222);
+
+ assertEquals("same path, 2nd more recent", -1, sorter.compare(path(p1, a1), path(p1, a2)));
+ assertEquals("path ignored, 2nd more recent", -1, sorter.compare(path(p1, a1), path(p2, a2)));
+ assertEquals("path ignored, 2nd more recent", -1, sorter.compare(path(p2, a1), path(p1, a2)));
+
+ assertEquals("same path, 1st more recent", 1, sorter.compare(path(p1, a2), path(p1, a1)));
+ assertEquals("path ignored, 1st more recent", 1, sorter.compare(path(p1, a2), path(p2, a1)));
+ assertEquals("path ignored, 1st more recent", 1, sorter.compare(path(p2, a2), path(p1, a1)));
+
+ assertEquals("same path, same time", 0, sorter.compare(path(p1, a1), path(p1, a1)));
+ assertEquals("p1 < p2, same time", -1, sorter.compare(path(p1, a1), path(p2, a1)));
+ assertEquals("p1 < p2, same time", 1, sorter.compare(path(p2, a1), path(p1, a1)));
+ }
+
+ private PathWithAttributes path(final Path path, final DummyFileAttributes attributes) {
+ return new PathWithAttributes(path, attributes);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 9920690..c6624ea 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
@@ -106,7 +106,7 @@ public class RoutingAppenderWithPurgingTest {
assertEquals("Incorrect number of appenders with manual purge.", 0, routingAppenderManual.getAppenders().size());
}
- private void assertFileExistance(String... files) {
+ private void assertFileExistance(final String... files) {
for (String file : files) {
assertTrue("File should exist - " + file + " file ", new File(file).exists());
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
index de74115..2be6499 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
@@ -199,7 +199,7 @@ public class PerfTestDriver {
private final Class<? extends IPerfTestRunner> implementationClass;
- private Runner(Class<? extends IPerfTestRunner> cls) {
+ private Runner(final Class<? extends IPerfTestRunner> cls) {
this.implementationClass = cls;
}
}
@@ -277,7 +277,7 @@ public class PerfTestDriver {
return tests;
}
- private static void add(final List<Setup> tests, int threadCount, final String config, final Runner runner, final String name,
+ private static void add(final List<Setup> tests, final int threadCount, final String config, final Runner runner, final String name,
final String... systemProperties) throws IOException {
final WaitStrategy wait = WaitStrategy.get();
final Class<?> perfTest = threadCount == 1 ? PerfTest.class : MultiThreadPerfTest.class;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 1ad25db..57140b5 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
@@ -94,7 +94,7 @@ import org.apache.logging.log4j.core.util.Loader;
public class ResponseTimeTest {
private static final String LATENCY_MSG = new String(new char[64]);
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
if (args.length < 2) {
System.out.println("Please specify thread count, target throughput (msg/sec) " +
"and logger library (Log4j1, Log4j2, Logback, JUL)");
@@ -244,7 +244,7 @@ public class ResponseTimeTest {
static AtomicLong ringbufferFull = new AtomicLong();
@Override
- public EventRoute getRoute(long backgroundThreadId, Level level) {
+ public EventRoute getRoute(final long backgroundThreadId, final Level level) {
ringbufferFull.incrementAndGet();
System.out.print('!');
return super.getRoute(backgroundThreadId, level);
@@ -283,27 +283,27 @@ public class ResponseTimeTest {
private double catchUpRateMultiple;
private final IdleStrategy idleStrategy;
- public Pacer(double unitsPerSec, IdleStrategy idleStrategy) {
+ public Pacer(final double unitsPerSec, final IdleStrategy idleStrategy) {
this(unitsPerSec, 3.0, idleStrategy); // Default to catching up at 3x the set throughput
}
- public Pacer(double unitsPerSec, double catchUpRateMultiple, IdleStrategy idleStrategy) {
+ public Pacer(final double unitsPerSec, final double catchUpRateMultiple, final IdleStrategy idleStrategy) {
this.idleStrategy = idleStrategy;
setThroughout(unitsPerSec);
setCatchupRateMultiple(catchUpRateMultiple);
initialStartTime = System.nanoTime();
}
- public void setInitialStartTime(long initialStartTime) {
+ public void setInitialStartTime(final long initialStartTime) {
this.initialStartTime = initialStartTime;
}
- public void setThroughout(double unitsPerSec) {
+ public void setThroughout(final double unitsPerSec) {
throughputInUnitsPerNsec = unitsPerSec / 1000000000.0;
catchUpThroughputInUnitsPerNsec = catchUpRateMultiple * throughputInUnitsPerNsec;
}
- public void setCatchupRateMultiple(double multiple) {
+ public void setCatchupRateMultiple(final double multiple) {
catchUpRateMultiple = multiple;
catchUpThroughputInUnitsPerNsec = catchUpRateMultiple * throughputInUnitsPerNsec;
}
@@ -357,7 +357,7 @@ public class ResponseTimeTest {
*
* @param unitCount
*/
- public void acquire(long unitCount) {
+ public void acquire(final long unitCount) {
long nsecToNextOperation = nsecToNextOperation();
if (nsecToNextOperation > 0) {
sleepNs(nsecToNextOperation);
@@ -365,7 +365,7 @@ public class ResponseTimeTest {
unitsCompleted += unitCount;
}
- private void sleepNs(long ns) {
+ private void sleepNs(final long ns) {
long now = System.nanoTime();
long deadline = now + ns;
while ((now = System.nanoTime()) < deadline) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 d886d00..dacc1a5 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
@@ -38,7 +38,7 @@ import org.apache.logging.log4j.spi.LoggerContext;
public class SimplePerfTest {
static final int ITERATIONS = 100000;
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName());
Logger logger = LogManager.getLogger();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 85a7df1..ecf57f0 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
@@ -164,7 +164,7 @@ public class CompositeConfigurationTest {
} */
- private void runTest(LoggerContextRule rule, Statement statement) {
+ private void runTest(final LoggerContextRule rule, final Statement statement) {
try {
rule.apply(statement, Description
.createTestDescription(getClass(), Thread.currentThread().getStackTrace()[1].getMethodName()))
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
index 6ce49dc..420ec2b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
@@ -1,47 +1,47 @@
-/*
- * 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 java.io.File;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ConfiguratorTest {
-
- @Test
- public void testInitializeFromAbsoluteFilePath() {
- final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
- testInitializeFromFilePath(path);
- }
-
- @Test
- public void testInitializeFromRelativeFilePath() {
- final String path = new File("src/test/resources/log4j-list.xml").toString();
- testInitializeFromFilePath(path);
- }
-
- private void testInitializeFromFilePath(String path) {
- final LoggerContext loggerContext = Configurator.initialize(getClass().getName(), null, path);
- try {
- Assert.assertNotNull(loggerContext.getConfiguration().getAppender("List"));
- } finally {
- loggerContext.stop();
- }
- }
-}
+/*
+ * 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 java.io.File;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ConfiguratorTest {
+
+ @Test
+ public void testInitializeFromAbsoluteFilePath() {
+ final String path = new File("src/test/resources/log4j-list.xml").getAbsolutePath();
+ testInitializeFromFilePath(path);
+ }
+
+ @Test
+ public void testInitializeFromRelativeFilePath() {
+ final String path = new File("src/test/resources/log4j-list.xml").toString();
+ testInitializeFromFilePath(path);
+ }
+
+ private void testInitializeFromFilePath(final String path) {
+ final LoggerContext loggerContext = Configurator.initialize(getClass().getName(), null, path);
+ try {
+ Assert.assertNotNull(loggerContext.getConfiguration().getAppender("List"));
+ } finally {
+ loggerContext.stop();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 f938824..ea2c954 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
@@ -65,7 +65,7 @@ public class ConfigurationAssemblerTest {
}
}
- private void validate(Configuration config) {
+ private void validate(final Configuration config) {
assertNotNull(config);
assertNotNull(config.getName());
assertFalse(config.getName().isEmpty());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 a6e8017..659f163 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
@@ -36,7 +36,7 @@ import java.net.URI;
//@Order(50)
public class CustomConfigurationFactory extends ConfigurationFactory {
- static Configuration addTestFixtures(final String name, ConfigurationBuilder<BuiltConfiguration> builder) {
+ static Configuration addTestFixtures(final String name, final ConfigurationBuilder<BuiltConfiguration> builder) {
builder.setConfigurationName(name);
builder.setStatusLevel(Level.ERROR);
builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true));
@@ -56,7 +56,7 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
}
@Override
- public Configuration getConfiguration(ConfigurationSource source) {
+ public Configuration getConfiguration(final ConfigurationSource source) {
return getConfiguration(source.toString(), null);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 332b03c..beba5d3 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
@@ -257,12 +257,12 @@ public class AbstractFilterableTest {
private class EqualFilter extends AbstractFilter {
private final String key;
- public EqualFilter(String key) {
+ public EqualFilter(final String key) {
this.key = key;
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof EqualFilter)) return false;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 df4adfb..f5f2e87 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
@@ -221,7 +221,7 @@ public class Log4jLogEventTest {
}
@SuppressWarnings("deprecation")
- private void verifyNanoTimeWithAllConstructors(long expected) {
+ private void verifyNanoTimeWithAllConstructors(final long expected) {
assertEquals(expected, Log4jLogEvent.getNanoClock().nanoTime());
assertEquals("No-arg constructor", expected, new Log4jLogEvent().getNanoTime());
@@ -464,11 +464,11 @@ public class Log4jLogEventTest {
different("null exception", builder(event).setThrown(null), event);
}
- private static Log4jLogEvent.Builder builder(LogEvent event) {
+ private static Log4jLogEvent.Builder builder(final LogEvent event) {
return new Log4jLogEvent.Builder(event);
}
- private void different(String reason, Log4jLogEvent.Builder builder, LogEvent event) {
+ private void different(final String reason, final Log4jLogEvent.Builder builder, final LogEvent event) {
final LogEvent other = builder.build();
assertNotEquals(reason, other, event);
assertNotEquals(reason + " hashCode", other.hashCode(), event.hashCode());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
index 787c33b..98e3ec7 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
@@ -73,7 +73,7 @@ public class ThrowableProxyTest {
return arr.toByteArray();
}
- private void testIoContainer(ObjectMapper objectMapper ) throws IOException {
+ private void testIoContainer(final ObjectMapper objectMapper ) throws IOException {
final Fixture expected = new Fixture();
final String s = objectMapper.writeValueAsString(expected);
final Fixture actual = objectMapper.readValue(s, Fixture.class);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
index 58136de7..ed95e17 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java
@@ -94,7 +94,7 @@ public class CsvLogEventLayoutTest {
testLayout(format, CsvLogEventLayout.createLayout(format), null, null);
}
- private void testLayout(final CSVFormat format, final AbstractCsvLayout layout, String header, String footer) {
+ private void testLayout(final CSVFormat format, final AbstractCsvLayout layout, final String header, final String footer) {
final Map<String, Appender> appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 061458f..f1826a2 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
@@ -90,7 +90,7 @@ public class CsvParameterLayoutTest {
assertEquals("text/csv; charset=UTF-8", layout.getContentType());
}
- static void testLayoutNormalApi(final Logger root, final AbstractCsvLayout layout, boolean messageApi) throws Exception {
+ static void testLayoutNormalApi(final Logger root, final AbstractCsvLayout layout, final boolean messageApi) throws Exception {
final Map<String, Appender> appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);