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 2018/10/30 02:49:32 UTC
[05/13] logging-log4j2 git commit: Use final. Remove trailing spaces.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ClockFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ClockFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ClockFactory.java
index 8b965b6..01a448a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ClockFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ClockFactory.java
@@ -68,7 +68,7 @@ public final class ClockFactory {
}
private static Map<String, Supplier<Clock>> aliases() {
- Map<String, Supplier<Clock>> result = new HashMap<>();
+ final Map<String, Supplier<Clock>> result = new HashMap<>();
result.put("SystemClock", new Supplier<Clock>() { @Override public Clock get() { return new SystemClock(); } });
result.put("SystemMillisClock", new Supplier<Clock>() { @Override public Clock get() { return new SystemMillisClock(); } });
result.put("CachedClock", new Supplier<Clock>() { @Override public Clock get() { return CachedClock.instance(); } });
@@ -84,7 +84,7 @@ public final class ClockFactory {
LOGGER.trace("Using default SystemClock for timestamps.");
return logSupportedPrecision(new SystemClock());
}
- Supplier<Clock> specified = aliases().get(userRequest);
+ final Supplier<Clock> specified = aliases().get(userRequest);
if (specified != null) {
LOGGER.trace("Using specified {} for timestamps.", userRequest);
return logSupportedPrecision(specified.get());
@@ -100,8 +100,8 @@ public final class ClockFactory {
}
}
- private static Clock logSupportedPrecision(Clock clock) {
- String support = clock instanceof PreciseClock ? "supports" : "does not support";
+ private static Clock logSupportedPrecision(final Clock clock) {
+ final String support = clock instanceof PreciseClock ? "supports" : "does not support";
LOGGER.debug("{} {} precise timestamps.", clock.getClass().getName(), support);
return clock;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/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 e3d6c2b..91f5ae5 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
@@ -37,7 +37,7 @@ public final class DummyNanoClock implements NanoClock {
/**
* Returns the constructor value.
- *
+ *
* @return the constructor value
*/
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExecutorServices.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExecutorServices.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExecutorServices.java
index 37a44f5..064b38b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExecutorServices.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ExecutorServices.java
@@ -32,7 +32,7 @@ public class ExecutorServices {
* <p>
* If the timeout is 0, then a plain shutdown takes place.
* </p>
- *
+ *
* @param executorService
* the pool to shutdown.
* @param timeout
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/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 609a005..6fd73c2 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
@@ -112,7 +112,7 @@ public final class FileUtils {
/**
* Asserts that the given directory exists and creates it if necessary.
- *
+ *
* @param dir the directory that shall exist
* @param createDirectoryIfNotExisting specifies if the directory shall be created if it does not exist.
* @throws java.io.IOException thrown if the directory could not be created.
@@ -131,10 +131,10 @@ public final class FileUtils {
throw new IOException("File " + dir + " exists and is not a directory. Unable to create directory.");
}
}
-
+
/**
* Creates the parent directories for the given File.
- *
+ *
* @param file
* @throws IOException
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileWatcher.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileWatcher.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileWatcher.java
index ab7752e..d7ddb54 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileWatcher.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileWatcher.java
@@ -20,14 +20,14 @@ import java.io.File;
/**
* Watches for changes in a {@link File} and performs an action when the file is modified.
- *
+ *
* @see WatchManager
*/
public interface FileWatcher {
/**
* Called when a {@link WatchManager} detects that the given {@link File} changed.
- *
+ *
* @param file
* the file that changed.
* @see WatchManager
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JndiCloser.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JndiCloser.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JndiCloser.java
index 2114b40..32178f1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JndiCloser.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JndiCloser.java
@@ -1,60 +1,60 @@
-/*
- * 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;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-/**
- * Helper class for closing JNDI resources.
- *
- * This class is separate from {@link Closer} because JNDI is not in Android.
- */
-public final class JndiCloser {
-
- private JndiCloser() {
- }
-
- /**
- * Closes the specified {@code Context}.
- *
- * @param context the JNDI Context to close, may be {@code null}
- * @throws NamingException if a problem occurred closing the specified JNDI Context
- */
- public static void close(final Context context) throws NamingException {
- if (context != null) {
- context.close();
- }
- }
-
- /**
- * Closes the specified {@code Context}, ignoring any exceptions thrown by the close operation.
- *
- * @param context the JNDI Context to close, may be {@code null}
- */
- public static boolean closeSilently(final Context context) {
- try {
- close(context);
- return true;
- } catch (final NamingException ignored) {
- // ignored
- return false;
- }
- }
-
-}
+/*
+ * 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;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+/**
+ * Helper class for closing JNDI resources.
+ *
+ * This class is separate from {@link Closer} because JNDI is not in Android.
+ */
+public final class JndiCloser {
+
+ private JndiCloser() {
+ }
+
+ /**
+ * Closes the specified {@code Context}.
+ *
+ * @param context the JNDI Context to close, may be {@code null}
+ * @throws NamingException if a problem occurred closing the specified JNDI Context
+ */
+ public static void close(final Context context) throws NamingException {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ /**
+ * Closes the specified {@code Context}, ignoring any exceptions thrown by the close operation.
+ *
+ * @param context the JNDI Context to close, may be {@code null}
+ */
+ public static boolean closeSilently(final Context context) {
+ try {
+ close(context);
+ return true;
+ } catch (final NamingException ignored) {
+ // ignored
+ return false;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java
index 1380b7a..ee36fea 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java
@@ -276,7 +276,7 @@ public final class Loader {
InstantiationException,
NoSuchMethodException,
InvocationTargetException {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClassLoader());
return LoaderUtil.newInstanceOf(className);
@@ -305,7 +305,7 @@ public final class Loader {
IllegalAccessException,
InvocationTargetException,
InstantiationException {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClassLoader());
return LoaderUtil.newCheckedInstanceOf(className, clazz);
@@ -332,7 +332,7 @@ public final class Loader {
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException,
IllegalAccessException {
final String className = PropertiesUtil.getProperties().getStringProperty(propertyName);
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClassLoader());
return LoaderUtil.newCheckedInstanceOfProperty(propertyName, clazz);
@@ -348,7 +348,7 @@ public final class Loader {
* @return {@code true} if the class could be found or {@code false} otherwise.
*/
public static boolean isClassAvailable(final String className) {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClassLoader());
return LoaderUtil.isClassAvailable(className);
@@ -371,7 +371,7 @@ public final class Loader {
*/
public static Class<?> loadClass(final String className) throws ClassNotFoundException {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClassLoader());
return LoaderUtil.loadClass(className);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
index 8b636f6..112b9d0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Log4jThreadFactory.java
@@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* Creates {@link Log4jThread}s.
- *
+ *
* @since 2.7
*/
public class Log4jThreadFactory implements ThreadFactory {
@@ -31,7 +31,7 @@ public class Log4jThreadFactory implements ThreadFactory {
/**
* Creates a new daemon thread factory.
- *
+ *
* @param threadFactoryName
* The thread factory name.
* @return a new daemon thread factory.
@@ -64,7 +64,7 @@ public class Log4jThreadFactory implements ThreadFactory {
/**
* Constructs an initialized thread factory.
- *
+ *
* @param threadFactoryName
* The thread factory name.
* @param daemon
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java
index e72beb6..11df6e4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java
@@ -79,7 +79,7 @@ public final class NetUtils {
/**
* Converts a URI string or file path to a URI object.
- *
+ *
* @param path the URI string or path
* @return the URI object
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NullOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NullOutputStream.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NullOutputStream.java
index 7403215..8fe9008 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NullOutputStream.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NullOutputStream.java
@@ -26,13 +26,13 @@ import java.io.OutputStream;
* This output stream has no destination (file/socket etc.) and all bytes written to it are ignored and lost.
* </p>
* Originally from Apache Commons IO.
- *
+ *
* @since 2.3
*/
public class NullOutputStream extends OutputStream {
private static final NullOutputStream INSTANCE = new NullOutputStream();
-
+
/**
* @deprecated Deprecated in 2.7: use {@link #getInstance()}.
*/
@@ -41,20 +41,20 @@ public class NullOutputStream extends OutputStream {
/**
* Gets the singleton instance.
- *
+ *
* @return the singleton instance.
*/
public static NullOutputStream getInstance() {
return INSTANCE;
}
-
+
private NullOutputStream() {
// do nothing
}
-
+
/**
* Does nothing - output to <code>/dev/null</code>.
- *
+ *
* @param b
* The bytes to write
* @param off
@@ -69,7 +69,7 @@ public class NullOutputStream extends OutputStream {
/**
* Does nothing - output to <code>/dev/null</code>.
- *
+ *
* @param b
* The byte to write
*/
@@ -80,7 +80,7 @@ public class NullOutputStream extends OutputStream {
/**
* Does nothing - output to <code>/dev/null</code>.
- *
+ *
* @param b
* The bytes to write
* @throws IOException
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Patterns.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Patterns.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Patterns.java
index 1177148..5427197 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Patterns.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Patterns.java
@@ -18,7 +18,7 @@ package org.apache.logging.log4j.core.util;
/**
* Pattern strings used throughout Log4j.
- *
+ *
* @see java.util.regex.Pattern
*/
public final class Patterns {
@@ -38,7 +38,7 @@ public final class Patterns {
/**
* Creates a pattern string for {@code separator} surrounded by whitespace.
- *
+ *
* @param separator The separator.
* @return a pattern for {@code separator} surrounded by whitespace.
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringBuilderWriter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringBuilderWriter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringBuilderWriter.java
index d366bd6..4dc823c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringBuilderWriter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/StringBuilderWriter.java
@@ -1,168 +1,168 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.io.Writer;
-
-/**
- * {@link Writer} implementation that outputs to a {@link StringBuilder}.
- * <p>
- * <strong>NOTE:</strong> This implementation, as an alternative to
- * <code>java.io.StringWriter</code>, provides an <i>un-synchronized</i>
- * (i.e. for use in a single thread) implementation for better performance.
- * For safe usage with multiple {@link Thread}s then
- * <code>java.io.StringWriter</code> should be used.
- *
- * <h3>History</h3>
- * <ol>
- * <li>Copied from Apache Commons IO revision 1681000.</li>
- * <li>Pick up Javadoc updates from revision 1722253.</li>
- * <ol>
- */
-public class StringBuilderWriter extends Writer implements Serializable {
-
- private static final long serialVersionUID = -146927496096066153L;
- private final StringBuilder builder;
-
- /**
- * Constructs a new {@link StringBuilder} instance with default capacity.
- */
- public StringBuilderWriter() {
- this.builder = new StringBuilder();
- }
-
- /**
- * Constructs a new {@link StringBuilder} instance with the specified capacity.
- *
- * @param capacity The initial capacity of the underlying {@link StringBuilder}
- */
- public StringBuilderWriter(final int capacity) {
- this.builder = new StringBuilder(capacity);
- }
-
- /**
- * Constructs a new instance with the specified {@link StringBuilder}.
- *
- * <p>If {@code builder} is null a new instance with default capacity will be created.</p>
- *
- * @param builder The String builder. May be null.
- */
- public StringBuilderWriter(final StringBuilder builder) {
- this.builder = builder != null ? builder : new StringBuilder();
- }
-
- /**
- * Appends a single character to this Writer.
- *
- * @param value The character to append
- * @return This writer instance
- */
- @Override
- public Writer append(final char value) {
- builder.append(value);
- return this;
- }
-
- /**
- * Appends a character sequence to this Writer.
- *
- * @param value The character to append
- * @return This writer instance
- */
- @Override
- public Writer append(final CharSequence value) {
- builder.append(value);
- return this;
- }
-
- /**
- * Appends a portion of a character sequence to the {@link StringBuilder}.
- *
- * @param value The character to append
- * @param start The index of the first character
- * @param end The index of the last character + 1
- * @return This writer instance
- */
- @Override
- public Writer append(final CharSequence value, final int start, final int end) {
- builder.append(value, start, end);
- return this;
- }
-
- /**
- * Closing this writer has no effect.
- */
- @Override
- public void close() {
- // no-op
- }
-
- /**
- * Flushing this writer has no effect.
- */
- @Override
- public void flush() {
- // no-op
- }
-
-
- /**
- * Writes a String to the {@link StringBuilder}.
- *
- * @param value The value to write
- */
- @Override
- public void write(final String value) {
- if (value != null) {
- builder.append(value);
- }
- }
-
- /**
- * Writes a portion of a character array to the {@link StringBuilder}.
- *
- * @param value The value to write
- * @param offset The index of the first character
- * @param length The number of characters to write
- */
- @Override
- public void write(final char[] value, final int offset, final int length) {
- if (value != null) {
- builder.append(value, offset, length);
- }
- }
-
- /**
- * Returns the underlying builder.
- *
- * @return The underlying builder
- */
- public StringBuilder getBuilder() {
- return builder;
- }
-
- /**
- * Returns {@link StringBuilder#toString()}.
- *
- * @return The contents of the String builder.
- */
- @Override
- public String toString() {
- return builder.toString();
- }
-}
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.io.Writer;
+
+/**
+ * {@link Writer} implementation that outputs to a {@link StringBuilder}.
+ * <p>
+ * <strong>NOTE:</strong> This implementation, as an alternative to
+ * <code>java.io.StringWriter</code>, provides an <i>un-synchronized</i>
+ * (i.e. for use in a single thread) implementation for better performance.
+ * For safe usage with multiple {@link Thread}s then
+ * <code>java.io.StringWriter</code> should be used.
+ *
+ * <h3>History</h3>
+ * <ol>
+ * <li>Copied from Apache Commons IO revision 1681000.</li>
+ * <li>Pick up Javadoc updates from revision 1722253.</li>
+ * <ol>
+ */
+public class StringBuilderWriter extends Writer implements Serializable {
+
+ private static final long serialVersionUID = -146927496096066153L;
+ private final StringBuilder builder;
+
+ /**
+ * Constructs a new {@link StringBuilder} instance with default capacity.
+ */
+ public StringBuilderWriter() {
+ this.builder = new StringBuilder();
+ }
+
+ /**
+ * Constructs a new {@link StringBuilder} instance with the specified capacity.
+ *
+ * @param capacity The initial capacity of the underlying {@link StringBuilder}
+ */
+ public StringBuilderWriter(final int capacity) {
+ this.builder = new StringBuilder(capacity);
+ }
+
+ /**
+ * Constructs a new instance with the specified {@link StringBuilder}.
+ *
+ * <p>If {@code builder} is null a new instance with default capacity will be created.</p>
+ *
+ * @param builder The String builder. May be null.
+ */
+ public StringBuilderWriter(final StringBuilder builder) {
+ this.builder = builder != null ? builder : new StringBuilder();
+ }
+
+ /**
+ * Appends a single character to this Writer.
+ *
+ * @param value The character to append
+ * @return This writer instance
+ */
+ @Override
+ public Writer append(final char value) {
+ builder.append(value);
+ return this;
+ }
+
+ /**
+ * Appends a character sequence to this Writer.
+ *
+ * @param value The character to append
+ * @return This writer instance
+ */
+ @Override
+ public Writer append(final CharSequence value) {
+ builder.append(value);
+ return this;
+ }
+
+ /**
+ * Appends a portion of a character sequence to the {@link StringBuilder}.
+ *
+ * @param value The character to append
+ * @param start The index of the first character
+ * @param end The index of the last character + 1
+ * @return This writer instance
+ */
+ @Override
+ public Writer append(final CharSequence value, final int start, final int end) {
+ builder.append(value, start, end);
+ return this;
+ }
+
+ /**
+ * Closing this writer has no effect.
+ */
+ @Override
+ public void close() {
+ // no-op
+ }
+
+ /**
+ * Flushing this writer has no effect.
+ */
+ @Override
+ public void flush() {
+ // no-op
+ }
+
+
+ /**
+ * Writes a String to the {@link StringBuilder}.
+ *
+ * @param value The value to write
+ */
+ @Override
+ public void write(final String value) {
+ if (value != null) {
+ builder.append(value);
+ }
+ }
+
+ /**
+ * Writes a portion of a character array to the {@link StringBuilder}.
+ *
+ * @param value The value to write
+ * @param offset The index of the first character
+ * @param length The number of characters to write
+ */
+ @Override
+ public void write(final char[] value, final int offset, final int length) {
+ if (value != null) {
+ builder.append(value, offset, length);
+ }
+ }
+
+ /**
+ * Returns the underlying builder.
+ *
+ * @return The underlying builder
+ */
+ public StringBuilder getBuilder() {
+ return builder;
+ }
+
+ /**
+ * Returns {@link StringBuilder#toString()}.
+ *
+ * @return The contents of the String builder.
+ */
+ @Override
+ public String toString() {
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java
index eb9c328..68255ac 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/TypeUtil.java
@@ -39,13 +39,13 @@ import java.util.Objects;
* @since 2.1
*/
public final class TypeUtil {
-
+
private TypeUtil() {
}
/**
* Gets all declared fields for the given class (including superclasses).
- *
+ *
* @param cls the class to examine
* @return all declared fields for the given class (including superclasses).
* @see Class#getDeclaredFields()
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/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 b38d899..31a98ef 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
@@ -32,7 +32,7 @@ import org.apache.logging.log4j.status.StatusLogger;
/**
* Manages {@link FileWatcher}s.
- *
+ *
* @see FileWatcher
* @see ConfigurationScheduler
*/
@@ -55,7 +55,7 @@ public class WatchManager extends AbstractLifeCycle {
* This allows you to start, stop, reset and start again a manager, without triggering file modified events if the a
* watched file has changed during the period of time when the manager was stopped.
* </p>
- *
+ *
* @since 2.11.0
*/
public void reset() {
@@ -72,7 +72,7 @@ public class WatchManager extends AbstractLifeCycle {
* This allows you to start, stop, reset and start again a manager, without triggering file modified events if the
* given watched file has changed during the period of time when the manager was stopped.
* </p>
- *
+ *
* @param file
* the file for the monitor to reset.
* @since 2.11.0
@@ -108,7 +108,7 @@ public class WatchManager extends AbstractLifeCycle {
/**
* Gets how often this manager checks for file modifications.
- *
+ *
* @return how often, in seconds, this manager checks for file modifications.
*/
public int getIntervalSeconds() {
@@ -134,7 +134,7 @@ public class WatchManager extends AbstractLifeCycle {
/**
* Unwatches the given file.
- *
+ *
* @param file
* the file to stop watching.
* @since 2.11.0
@@ -146,7 +146,7 @@ public class WatchManager extends AbstractLifeCycle {
/**
* Watches the given file.
- *
+ *
* @param file
* the file to watch.
* @param watcher
@@ -171,7 +171,7 @@ public class WatchManager extends AbstractLifeCycle {
private String millisToString(final long millis) {
return new Date(millis).toString();
}
-
+
private final class WatchRunnable implements Runnable {
// Use a hard class reference here in case a refactoring changes the class name.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DateParser.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DateParser.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DateParser.java
index 16940c6..8d4a359 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DateParser.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DateParser.java
@@ -30,34 +30,34 @@ import java.util.TimeZone;
* <p>
* Warning: Since binary compatible methods may be added to this interface in any
* release, developers are not expected to implement this interface.
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 3.2
*/
public interface DateParser {
/**
- * Equivalent to DateFormat.parse(String).
- *
- * See {@link java.text.DateFormat#parse(String)} for more information.
- * @param source A <code>String</code> whose beginning should be parsed.
+ * Equivalent to DateFormat.parse(String).
+ *
+ * See {@link java.text.DateFormat#parse(String)} for more information.
+ * @param source A <code>String</code> whose beginning should be parsed.
* @return A <code>Date</code> parsed from the string
* @throws ParseException if the beginning of the specified string cannot be parsed.
*/
Date parse(String source) throws ParseException;
/**
- * Equivalent to DateFormat.parse(String, ParsePosition).
- *
- * See {@link java.text.DateFormat#parse(String, ParsePosition)} for more information.
- *
+ * Equivalent to DateFormat.parse(String, ParsePosition).
+ *
+ * See {@link java.text.DateFormat#parse(String, ParsePosition)} for more information.
+ *
* @param source A <code>String</code>, part of which should be parsed.
- * @param pos A <code>ParsePosition</code> object with index and error index information
- * as described above.
- * @return A <code>Date</code> parsed from the string. In case of error, returns null.
+ * @param pos A <code>ParsePosition</code> object with index and error index information
+ * as described above.
+ * @return A <code>Date</code> parsed from the string. In case of error, returns null.
* @throws NullPointerException if text or pos is null.
*/
Date parse(String source, ParsePosition pos);
@@ -74,7 +74,7 @@ public interface DateParser {
* @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated)
* @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is
* out of range.
- *
+ *
* @since 3.5
*/
boolean parse(String source, ParsePosition pos, Calendar calendar);
@@ -83,7 +83,7 @@ public interface DateParser {
//-----------------------------------------------------------------------
/**
* <p>Gets the pattern used by this parser.</p>
- *
+ *
* @return the pattern, {@link java.text.SimpleDateFormat} compatible
*/
String getPattern();
@@ -92,40 +92,40 @@ public interface DateParser {
* <p>
* Gets the time zone used by this parser.
* </p>
- *
+ *
* <p>
* The default {@link TimeZone} used to create a {@link Date} when the {@link TimeZone} is not specified by
* the format pattern.
* </p>
- *
+ *
* @return the time zone
*/
TimeZone getTimeZone();
/**
* <p>Gets the locale used by this parser.</p>
- *
+ *
* @return the locale
*/
Locale getLocale();
/**
* Parses text from a string to produce a Date.
- *
+ *
* @param source A <code>String</code> whose beginning should be parsed.
* @return a <code>java.util.Date</code> object
* @throws ParseException if the beginning of the specified string cannot be parsed.
- * @see java.text.DateFormat#parseObject(String)
+ * @see java.text.DateFormat#parseObject(String)
*/
Object parseObject(String source) throws ParseException;
/**
* Parses a date/time string according to the given parse position.
- *
+ *
* @param source A <code>String</code> whose beginning should be parsed.
* @param pos the parse position
* @return a <code>java.util.Date</code> object
- * @see java.text.DateFormat#parseObject(String, ParsePosition)
+ * @see java.text.DateFormat#parseObject(String, ParsePosition)
*/
Object parseObject(String source, ParsePosition pos);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DatePrinter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DatePrinter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DatePrinter.java
index 91f5e1a..adcf59e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DatePrinter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/DatePrinter.java
@@ -23,18 +23,18 @@ import java.util.Locale;
import java.util.TimeZone;
/**
- * DatePrinter is the "missing" interface for the format methods of
+ * DatePrinter is the "missing" interface for the format methods of
* {@link java.text.DateFormat}. You can obtain an object implementing this
* interface by using one of the FastDateFormat factory methods.
* <p>
* Warning: Since binary compatible methods may be added to this interface in any
* release, developers are not expected to implement this interface.
* </p>
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 3.2
*/
public interface DatePrinter {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateFormat.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateFormat.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateFormat.java
index db38bd1..0e8f036 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateFormat.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateFormat.java
@@ -29,16 +29,16 @@ import java.util.TimeZone;
* <p>FastDateFormat is a fast and thread-safe version of
* {@link java.text.SimpleDateFormat}.</p>
*
- * <p>To obtain an instance of FastDateFormat, use one of the static factory methods:
- * {@link #getInstance(String, TimeZone, Locale)}, {@link #getDateInstance(int, TimeZone, Locale)},
- * {@link #getTimeInstance(int, TimeZone, Locale)}, or {@link #getDateTimeInstance(int, int, TimeZone, Locale)}
+ * <p>To obtain an instance of FastDateFormat, use one of the static factory methods:
+ * {@link #getInstance(String, TimeZone, Locale)}, {@link #getDateInstance(int, TimeZone, Locale)},
+ * {@link #getTimeInstance(int, TimeZone, Locale)}, or {@link #getDateTimeInstance(int, int, TimeZone, Locale)}
* </p>
- *
+ *
* <p>Since FastDateFormat is thread safe, you can use a static member instance:</p>
* <code>
* private static final FastDateFormat DATE_FORMATTER = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT);
* </code>
- *
+ *
* <p>This class can be used as a direct replacement to
* {@code SimpleDateFormat} in most formatting and parsing situations.
* This class is especially useful in multi-threaded server environments.
@@ -65,15 +65,15 @@ import java.util.TimeZone;
* interpreted as a number.</i> Starting with Java 1.7 a pattern of 'Y' or
* 'YYY' will be formatted as '2003', while it was '03' in former Java
* versions. FastDateFormat implements the behavior of Java 7.</p>
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 2.0
*/
public class FastDateFormat extends Format implements DateParser, DatePrinter {
-
+
/**
* Required for serialization support.
*
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateParser.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateParser.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateParser.java
index 4ba5668..9e5e6ec 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateParser.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDateParser.java
@@ -43,14 +43,14 @@ import java.util.regex.Pattern;
* <p>FastDateParser is a fast and thread-safe version of
* {@link java.text.SimpleDateFormat}.</p>
*
- * <p>To obtain a proxy to a FastDateParser, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)}
+ * <p>To obtain a proxy to a FastDateParser, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)}
* or another variation of the factory methods of {@link FastDateFormat}.</p>
- *
+ *
* <p>Since FastDateParser is thread safe, you can use a static member instance:</p>
* <code>
* private static final DateParser DATE_PARSER = FastDateFormat.getInstance("yyyy-MM-dd");
* </code>
- *
+ *
* <p>This class can be used as a direct replacement for
* <code>SimpleDateFormat</code> in most parsing situations.
* This class is especially useful in multi-threaded server environments.
@@ -66,11 +66,11 @@ import java.util.regex.Pattern;
*
* <p>Timing tests indicate this class is as about as fast as SimpleDateFormat
* in single thread applications and about 25% faster in multi-thread applications.</p>
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 3.2
* @see FastDatePrinter
*/
@@ -107,8 +107,8 @@ public class FastDateParser implements DateParser, Serializable {
/**
* <p>Constructs a new FastDateParser.</p>
- *
- * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the
+ *
+ * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the
* factory methods of {@link FastDateFormat} to get a cached FastDateParser instance.
*
* @param pattern non-null {@link java.text.SimpleDateFormat} compatible
@@ -385,8 +385,8 @@ public class FastDateParser implements DateParser, Serializable {
/**
* This implementation updates the ParsePosition if the parse succeeds.
- * However, it sets the error index to the position before the failed field unlike
- * the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} which sets
+ * However, it sets the error index to the position before the failed field unlike
+ * the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} which sets
* the error index to after the failed field.
* <p>
* To determine if the parse has succeeded, the caller must check if the current parse position
@@ -409,7 +409,7 @@ public class FastDateParser implements DateParser, Serializable {
* Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed.
* Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to
* the offset of the source text which does not match the supplied format.
- *
+ *
* @param source The text to parse.
* @param pos On input, the position in the source to start parsing, on output, updated position.
* @param calendar The calendar into which to set parsed fields.
@@ -570,7 +570,7 @@ public class FastDateParser implements DateParser, Serializable {
return getLocaleSpecificStrategy(Calendar.ERA, definingCalendar);
case 'H': // Hour in day (0-23)
return HOUR_OF_DAY_STRATEGY;
- case 'K': // Hour in am/pm (0-11)
+ case 'K': // Hour in am/pm (0-11)
return HOUR_STRATEGY;
case 'M':
return width>=3 ?getLocaleSpecificStrategy(Calendar.MONTH, definingCalendar) :NUMBER_MONTH_STRATEGY;
@@ -636,7 +636,7 @@ public class FastDateParser implements DateParser, Serializable {
final ConcurrentMap<Locale, Strategy> cache = getCache(field);
Strategy strategy = cache.get(locale);
if (strategy == null) {
- strategy = field == Calendar.ZONE_OFFSET
+ strategy = field == Calendar.ZONE_OFFSET
? new TimeZoneStrategy(locale)
: new CaseInsensitiveTextStrategy(field, definingCalendar, locale);
final Strategy inCache = cache.putIfAbsent(locale, strategy);
@@ -705,7 +705,7 @@ public class FastDateParser implements DateParser, Serializable {
CaseInsensitiveTextStrategy(final int field, final Calendar definingCalendar, final Locale locale) {
this.field = field;
this.locale = locale;
-
+
final StringBuilder regex = new StringBuilder();
regex.append("((?iu)");
lKeyValues = appendDisplayNames(definingCalendar, locale, field, regex);
@@ -905,9 +905,9 @@ public class FastDateParser implements DateParser, Serializable {
}
}
}
-
+
private static class ISO8601TimeZoneStrategy extends PatternStrategy {
- // Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm
+ // Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm
/**
* Construct a Strategy that parses a TimeZone
@@ -916,7 +916,7 @@ public class FastDateParser implements DateParser, Serializable {
ISO8601TimeZoneStrategy(final String pattern) {
createPattern(pattern);
}
-
+
/**
* {@inheritDoc}
*/
@@ -928,14 +928,14 @@ public class FastDateParser implements DateParser, Serializable {
cal.setTimeZone(TimeZone.getTimeZone("GMT" + value));
}
}
-
+
private static final Strategy ISO_8601_1_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}))");
private static final Strategy ISO_8601_2_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}\\d{2}))");
private static final Strategy ISO_8601_3_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}(?::)\\d{2}))");
/**
* Factory method for ISO8601TimeZoneStrategies.
- *
+ *
* @param tokenLen a token indicating the length of the TimeZone String to be formatted.
* @return a ISO8601TimeZoneStrategy that can format TimeZone String of length {@code tokenLen}. If no such
* strategy exists, an IllegalArgumentException will be thrown.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDatePrinter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDatePrinter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDatePrinter.java
index 4f33b6b..307b16c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDatePrinter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FastDatePrinter.java
@@ -37,14 +37,14 @@ import org.apache.logging.log4j.core.util.Throwables;
* <p>FastDatePrinter is a fast and thread-safe version of
* {@link java.text.SimpleDateFormat}.</p>
*
- * <p>To obtain a FastDatePrinter, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)}
+ * <p>To obtain a FastDatePrinter, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)}
* or another variation of the factory methods of {@link FastDateFormat}.</p>
- *
+ *
* <p>Since FastDatePrinter is thread safe, you can use a static member instance:</p>
* <code>
* private static final DatePrinter DATE_PRINTER = FastDateFormat.getInstance("yyyy-MM-dd");
* </code>
- *
+ *
* <p>This class can be used as a direct replacement to
* {@code SimpleDateFormat} in most formatting situations.
* This class is especially useful in multi-threaded server environments.
@@ -63,7 +63,7 @@ import org.apache.logging.log4j.core.util.Throwables;
* ISO 8601 extended format time zones (eg. {@code +08:00} or {@code -11:00}).
* This introduces a minor incompatibility with Java 1.4, but at a gain of
* useful functionality.</p>
- *
+ *
* <p>Starting with JDK7, ISO 8601 support was added using the pattern {@code 'X'}.
* To maintain compatibility, {@code 'ZZ'} will continue to be supported, but using
* one of the {@code 'X'} formats is recommended.
@@ -73,11 +73,11 @@ import org.apache.logging.log4j.core.util.Throwables;
* interpreted as a number.</i> Starting with Java 1.7 a pattern of 'Y' or
* 'YYY' will be formatted as '2003', while it was '03' in former Java
* versions. FastDatePrinter implements the behavior of Java 7.</p>
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 3.2
* @see FastDateParser
*/
@@ -143,7 +143,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
//-----------------------------------------------------------------------
/**
* <p>Constructs a new FastDatePrinter.</p>
- * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the
+ * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the
* factory methods of {@link FastDateFormat} to get a cached FastDatePrinter instance.
*
* @param pattern {@link java.text.SimpleDateFormat} compatible pattern
@@ -280,9 +280,9 @@ public class FastDatePrinter implements DatePrinter, Serializable {
case 'K': // hour in am/pm (0..11)
rule = selectNumberRule(Calendar.HOUR, tokenLen);
break;
- case 'X': // ISO 8601
+ case 'X': // ISO 8601
rule = Iso8601_Rule.getRule(tokenLen);
- break;
+ break;
case 'z': // time zone (text)
if (tokenLen >= 4) {
rule = new TimeZoneNameRule(mTimeZone, mLocale, TimeZone.LONG);
@@ -607,7 +607,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
}
final FastDatePrinter other = (FastDatePrinter) obj;
return mPattern.equals(other.mPattern)
- && mTimeZone.equals(other.mTimeZone)
+ && mTimeZone.equals(other.mTimeZone)
&& mLocale.equals(other.mLocale);
}
@@ -1322,7 +1322,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
TimeZoneNameRule(final TimeZone timeZone, final Locale locale, final int style) {
mLocale = locale;
mStyle = style;
-
+
mStandard = getTimeZoneDisplay(timeZone, false, style, locale);
mDaylight = getTimeZoneDisplay(timeZone, true, style, locale);
}
@@ -1359,7 +1359,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
private static class TimeZoneNumberRule implements Rule {
static final TimeZoneNumberRule INSTANCE_COLON = new TimeZoneNumberRule(true);
static final TimeZoneNumberRule INSTANCE_NO_COLON = new TimeZoneNumberRule(false);
-
+
final boolean mColon;
/**
@@ -1384,7 +1384,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/
@Override
public void appendTo(final Appendable buffer, final Calendar calendar) throws IOException {
-
+
int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
if (offset < 0) {
@@ -1411,9 +1411,9 @@ public class FastDatePrinter implements DatePrinter, Serializable {
* or {@code +/-HH:MM}.</p>
*/
private static class Iso8601_Rule implements Rule {
-
+
// Sign TwoDigitHours or Z
- static final Iso8601_Rule ISO8601_HOURS = new Iso8601_Rule(3);
+ static final Iso8601_Rule ISO8601_HOURS = new Iso8601_Rule(3);
// Sign TwoDigitHours Minutes or Z
static final Iso8601_Rule ISO8601_HOURS_MINUTES = new Iso8601_Rule(5);
// Sign TwoDigitHours : Minutes or Z
@@ -1435,10 +1435,10 @@ public class FastDatePrinter implements DatePrinter, Serializable {
case 3:
return Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
default:
- throw new IllegalArgumentException("invalid number of X");
+ throw new IllegalArgumentException("invalid number of X");
}
- }
-
+ }
+
final int length;
/**
@@ -1468,7 +1468,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
buffer.append("Z");
return;
}
-
+
if (offset < 0) {
buffer.append('-');
offset = -offset;
@@ -1482,7 +1482,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
if (length<5) {
return;
}
-
+
if (length==6) {
buffer.append(':');
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/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 f814b62..f58a29b 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
@@ -539,11 +539,11 @@ public class FixedDateFormat {
1, // 5
};
- private void formatNanoOfMillisecond(int nanoOfMillisecond, final char[] buffer, int pos) {
+ private void formatNanoOfMillisecond(final int nanoOfMillisecond, final char[] buffer, int pos) {
int temp;
int remain = nanoOfMillisecond;
for (int i = 0; i < secondFractionDigits - FixedFormat.MILLI_FRACTION_DIGITS; i++) {
- int divisor = TABLE[i];
+ final int divisor = TABLE[i];
temp = remain / divisor;
buffer[pos++] = ((char) (temp + '0'));
remain -= divisor * temp; // equivalent of remain % 10
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FormatCache.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FormatCache.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FormatCache.java
index e146a1d..92f001a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FormatCache.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/datetime/FormatCache.java
@@ -27,31 +27,31 @@ import java.util.concurrent.ConcurrentMap;
/**
* <p>FormatCache is a cache and factory for {@link Format}s.</p>
- *
+ *
* <p>
* Copied and modified from <a href="https://commons.apache.org/proper/commons-lang/">Apache Commons Lang</a>.
* </p>
- *
+ *
* @since Apache Commons Lang 3.0
*/
// TODO: Before making public move from getDateTimeInstance(Integer,...) to int; or some other approach.
abstract class FormatCache<F extends Format> {
-
+
/**
* No date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG
*/
static final int NONE= -1;
-
- private final ConcurrentMap<MultipartKey, F> cInstanceCache
+
+ private final ConcurrentMap<MultipartKey, F> cInstanceCache
= new ConcurrentHashMap<>(7);
-
- private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache
+
+ private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache
= new ConcurrentHashMap<>(7);
/**
* <p>Gets a formatter instance using the default pattern in the
* default timezone and locale.</p>
- *
+ *
* @return a date/time formatter
*/
public F getInstance() {
@@ -61,7 +61,7 @@ abstract class FormatCache<F extends Format> {
/**
* <p>Gets a formatter instance using the specified pattern, time zone
* and locale.</p>
- *
+ *
* @param pattern {@link java.text.SimpleDateFormat} compatible
* pattern, non-null
* @param timeZone the time zone, null means use the default TimeZone
@@ -82,22 +82,22 @@ abstract class FormatCache<F extends Format> {
}
final MultipartKey key = new MultipartKey(pattern, timeZone, locale);
F format = cInstanceCache.get(key);
- if (format == null) {
+ if (format == null) {
format = createInstance(pattern, timeZone, locale);
final F previousValue= cInstanceCache.putIfAbsent(key, format);
if (previousValue != null) {
// another thread snuck in and did the same work
// we should return the instance that is in ConcurrentMap
- format= previousValue;
+ format= previousValue;
}
}
return format;
}
-
+
/**
* <p>Create a format instance using the specified pattern, time zone
* and locale.</p>
- *
+ *
* @param pattern {@link java.text.SimpleDateFormat} compatible pattern, this will not be null.
* @param timeZone time zone, this will not be null.
* @param locale locale, this will not be null.
@@ -106,11 +106,11 @@ abstract class FormatCache<F extends Format> {
* or <code>null</code>
*/
abstract protected F createInstance(String pattern, TimeZone timeZone, Locale locale);
-
+
/**
* <p>Gets a date/time formatter instance using the specified style,
* time zone and locale.</p>
- *
+ *
* @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format
* @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format
* @param timeZone optional time zone, overrides time zone of
@@ -120,7 +120,7 @@ abstract class FormatCache<F extends Format> {
* @throws IllegalArgumentException if the Locale has no date/time
* pattern defined
*/
- // This must remain private, see LANG-884
+ // This must remain private, see LANG-884
private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final TimeZone timeZone, Locale locale) {
if (locale == null) {
locale = Locale.getDefault();
@@ -132,7 +132,7 @@ abstract class FormatCache<F extends Format> {
/**
* <p>Gets a date/time formatter instance using the specified style,
* time zone and locale.</p>
- *
+ *
* @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT
* @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT
* @param timeZone optional time zone, overrides time zone of
@@ -150,7 +150,7 @@ abstract class FormatCache<F extends Format> {
/**
* <p>Gets a date formatter instance using the specified style,
* time zone and locale.</p>
- *
+ *
* @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT
* @param timeZone optional time zone, overrides time zone of
* formatted date, null means use default Locale
@@ -167,7 +167,7 @@ abstract class FormatCache<F extends Format> {
/**
* <p>Gets a time formatter instance using the specified style,
* time zone and locale.</p>
- *
+ *
* @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT
* @param timeZone optional time zone, overrides time zone of
* formatted date, null means use default Locale
@@ -183,7 +183,7 @@ abstract class FormatCache<F extends Format> {
/**
* <p>Gets a date/time format for the specified styles and locale.</p>
- *
+ *
* @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format
* @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format
* @param locale The non-null locale of the desired format
@@ -199,10 +199,10 @@ abstract class FormatCache<F extends Format> {
try {
DateFormat formatter;
if (dateStyle == null) {
- formatter = DateFormat.getTimeInstance(timeStyle.intValue(), locale);
+ formatter = DateFormat.getTimeInstance(timeStyle.intValue(), locale);
}
else if (timeStyle == null) {
- formatter = DateFormat.getDateInstance(dateStyle.intValue(), locale);
+ formatter = DateFormat.getDateInstance(dateStyle.intValue(), locale);
}
else {
formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
index 7bb7297..7a480f3 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.java
@@ -36,10 +36,10 @@ import org.junit.Test;
public class CustomLevelsTest {
private static final String CONFIG = "log4j-customLevels.xml";
-
+
@ClassRule
public static LoggerContextRule context = new LoggerContextRule(CONFIG);
-
+
private ListAppender listAppender;
private Level diagLevel;
private Level noticeLevel;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
index c3cc5b4..0e27cea 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/DeadlockTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
public class DeadlockTest {
private static final String CONFIG = "log4j-deadlock.xml";
-
+
@ClassRule
public static LoggerContextRule context = new LoggerContextRule(CONFIG);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/EventParameterMemoryLeakTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/EventParameterMemoryLeakTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/EventParameterMemoryLeakTest.java
index 9996f8b..0205720 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/EventParameterMemoryLeakTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/EventParameterMemoryLeakTest.java
@@ -50,7 +50,7 @@ public class EventParameterMemoryLeakTest {
assertTrue("Deleted old file before test", !file.exists() || file.delete());
final Logger log = LogManager.getLogger("com.foo.Bar");
- CountDownLatch latch = new CountDownLatch(1);
+ final CountDownLatch latch = new CountDownLatch(1);
Object parameter = new ParameterObject("paramValue", latch);
log.info("Message with parameter {}", parameter);
log.info(parameter);
@@ -71,7 +71,7 @@ public class EventParameterMemoryLeakTest {
assertThat(line3, containsString("paramValue"));
assertThat(line4, containsString("paramValue"));
assertNull("Expected only three lines", line5);
- GarbageCollectionHelper gcHelper = new GarbageCollectionHelper();
+ final GarbageCollectionHelper gcHelper = new GarbageCollectionHelper();
gcHelper.run();
try {
assertTrue("Parameter should have been garbage collected", latch.await(30, TimeUnit.SECONDS));
@@ -83,7 +83,7 @@ public class EventParameterMemoryLeakTest {
private static final class ParameterObject {
private final String value;
private final CountDownLatch latch;
- ParameterObject(String value, CountDownLatch latch) {
+ ParameterObject(final String value, final CountDownLatch latch) {
this.value = value;
this.latch = latch;
}
@@ -103,7 +103,7 @@ public class EventParameterMemoryLeakTest {
private static final class ObjectThrowable extends RuntimeException {
private final Object object;
- ObjectThrowable(Object object) {
+ ObjectThrowable(final Object object) {
super(String.valueOf(object));
this.object = object;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/GarbageCollectionHelper.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GarbageCollectionHelper.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GarbageCollectionHelper.java
index 01b9d8a..0e0c9ad 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GarbageCollectionHelper.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GarbageCollectionHelper.java
@@ -40,7 +40,7 @@ final class GarbageCollectionHelper implements Closeable, Runnable {
try {
// 1mb of heap
sink.write(new byte[1024 * 1024]);
- } catch (IOException ignored) {
+ } catch (final IOException ignored) {
}
// May no-op depending on the jvm configuration
System.gc();
@@ -64,7 +64,7 @@ final class GarbageCollectionHelper implements Closeable, Runnable {
try {
assertTrue("GarbageCollectionHelper did not shut down cleanly",
latch.await(10, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/LateConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LateConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LateConfigTest.java
index 03d1575..0421e18 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LateConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LateConfigTest.java
@@ -47,7 +47,7 @@ public class LateConfigTest {
public static void tearDownClass() {
Configurator.shutdown(context);
StatusLogger.getLogger().reset();
- }
+ }
@Test
public void testReconfiguration() throws Exception {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
index bd5ae3e..3aa0559 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LogEventTest.java
@@ -96,7 +96,7 @@ public class LogEventTest {
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new FilteredObjectInputStream(bais);
-
+
final LogEvent actual = (LogEvent) ois.readObject();
assertNotEquals("Different event: nanoTime", copy, actual);
assertNotEquals("Different nanoTime", copy.getNanoTime(), actual.getNanoTime());
@@ -123,7 +123,7 @@ public class LogEventTest {
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInputStream ois = new FilteredObjectInputStream(bais);
-
+
final LogEvent actual = (LogEvent) ois.readObject();
assertEquals("both zero nanoTime", event2, actual);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/ReusableParameterizedMessageMemoryLeakTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/ReusableParameterizedMessageMemoryLeakTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/ReusableParameterizedMessageMemoryLeakTest.java
index c08f705..c4d212d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/ReusableParameterizedMessageMemoryLeakTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/ReusableParameterizedMessageMemoryLeakTest.java
@@ -30,12 +30,12 @@ public class ReusableParameterizedMessageMemoryLeakTest {
@Test
@SuppressWarnings("UnusedAssignment") // parameter set to null to allow garbage collection
public void testParametersAreNotLeaked() throws Exception {
- CountDownLatch latch = new CountDownLatch(1);
- ReusableMessage message = (ReusableMessage) ReusableMessageFactory.INSTANCE.newMessage(
+ final CountDownLatch latch = new CountDownLatch(1);
+ final ReusableMessage message = (ReusableMessage) ReusableMessageFactory.INSTANCE.newMessage(
"foo {}", new ParameterObject("paramValue", latch));
// Large enough for the parameters, but smaller than the default reusable array size.
message.swapParameters(new Object[5]);
- GarbageCollectionHelper gcHelper = new GarbageCollectionHelper();
+ final GarbageCollectionHelper gcHelper = new GarbageCollectionHelper();
gcHelper.run();
try {
assertTrue("Parameter should have been garbage collected", latch.await(30, TimeUnit.SECONDS));
@@ -47,7 +47,7 @@ public class ReusableParameterizedMessageMemoryLeakTest {
private static final class ParameterObject {
private final String value;
private final CountDownLatch latch;
- ParameterObject(String value, CountDownLatch latch) {
+ ParameterObject(final String value, final CountDownLatch latch) {
this.value = value;
this.latch = latch;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/TestPatternConverters.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/TestPatternConverters.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/TestPatternConverters.java
index 5cba8e0..0f6fca9 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/TestPatternConverters.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/TestPatternConverters.java
@@ -44,7 +44,7 @@ public final class TestPatternConverters {
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
toAppendTo.append('[');
- Object[] parameters = event.getMessage().getParameters();
+ final Object[] parameters = event.getMessage().getParameters();
if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
StringBuilders.appendValue(toAppendTo, parameters[i]);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
index d0ff679..1b28e85 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderBuilderTest.java
@@ -35,7 +35,7 @@ public class ConsoleAppenderBuilderTest {
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1636
- *
+ *
* Tested with Oracle 7 and 8 and IBM Java 8.
*/
@Test
@@ -53,7 +53,7 @@ public class ConsoleAppenderBuilderTest {
@Test
public void testSetNullErrorHandlerIsNotAllowed() {
final ConsoleAppender appender = ConsoleAppender.newBuilder().setName("test").build();
- ErrorHandler handler = appender.getHandler();
+ final ErrorHandler handler = appender.getHandler();
Assert.assertNotNull(handler);
// This could likely be allowed to throw, but we're just testing that
// setting null does not actually set a null handler.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderDefaultSuppressedThrowable.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderDefaultSuppressedThrowable.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderDefaultSuppressedThrowable.java
index 8437232..7587bf6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderDefaultSuppressedThrowable.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderDefaultSuppressedThrowable.java
@@ -30,7 +30,7 @@ import org.apache.logging.log4j.core.config.Configurator;
* <p>
* Running from a Windows command line from the root of the project:
* </p>
- *
+ *
* <pre>
* java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.14\jansi-1.14.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderNoAnsiStyleLayoutMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml
* </pre>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
index 0c2ed98..4cf9b7a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsTest.java
@@ -130,7 +130,7 @@ public class FileAppenderPermissionsTest {
}
assertFalse("Appender did not stop", appender.isStarted());
}
-
+
@Test
public void testFileUserGroupAPI() throws Exception {
final File file = new File(DIR, "AppenderTest-" + (1000 + fileIndex) + ".log");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsXmlConfigTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsXmlConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsXmlConfigTest.java
index b041aa6..636c6c5 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsXmlConfigTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderPermissionsXmlConfigTest.java
@@ -62,5 +62,5 @@ public class FileAppenderPermissionsXmlConfigTest {
Files.getPosixFilePermissions(Paths.get("target/permissions1/AppenderTest-1.log"))));
}
-
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
index 5e063ee..bfc6963 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
@@ -41,7 +41,7 @@ public class HangingAppender extends AbstractAppender {
private final long shutdownDelay;
public HangingAppender(final String name, final long delay, final long startupDelay, final long shutdownDelay,
- Property[] properties) {
+ final Property[] properties) {
super(name, null, null, true, Property.EMPTY_ARRAY);
this.delay = delay;
this.startupDelay = startupDelay;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
index ad83d5b..e5097d4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java
@@ -164,7 +164,7 @@ public class HttpAppenderTest {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.build();
@@ -181,7 +181,7 @@ public class HttpAppenderTest {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("https://localhost:" + wireMockRule.httpsPort() + "/test/log4j/"))
.setSslConfiguration(SslConfiguration.createSSLConfiguration(null,
@@ -202,7 +202,7 @@ public class HttpAppenderTest {
wireMockRule.stubFor(put(urlEqualTo("/test/log4j/1234"))
.willReturn(SUCCESS_RESPONSE));
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setMethod("PUT")
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/1234"))
@@ -220,7 +220,7 @@ public class HttpAppenderTest {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.setHeaders(new Property[] {
@@ -262,7 +262,7 @@ public class HttpAppenderTest {
error = null;
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.build();
@@ -283,7 +283,7 @@ public class HttpAppenderTest {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(FAILURE_RESPONSE));
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration()).setIgnoreExceptions(false)
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.build();
@@ -292,7 +292,7 @@ public class HttpAppenderTest {
@Test(expected = AppenderLoggingException.class)
public void testAppendConnectError() throws Exception {
- final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout((Layout<? extends Serializable>) JsonLayout.createDefaultLayout())
+ final Appender appender = HttpAppender.newBuilder().setName("Http").setLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration()).setIgnoreExceptions(false)
.setUrl(new URL("http://localhost:"+(wireMockRule.port()+1)+"/test/log4j/"))
.build();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
index f46af07..bfb233e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
@@ -27,7 +27,7 @@ import org.apache.logging.log4j.core.config.Configurator;
* <p>
* Running from a Windows command line from the root of the project:
* </p>
- *
+ *
* <pre>
* java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.14\jansi-1.14.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiMessagesMain log4j-core/target/test-classes/log4j2-console.xml
* </pre>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
index 323ca13..dd2d100 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/JsonCompleteFileAppenderTest.java
@@ -16,16 +16,13 @@
*/
package org.apache.logging.log4j.core.appender;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.categories.Layouts;
-import org.apache.logging.log4j.core.filter.TimeFilterTest;
import org.apache.logging.log4j.core.impl.Log4jLogEventTest;
import org.apache.logging.log4j.core.selector.ContextSelector;
import org.apache.logging.log4j.core.selector.CoreContextSelectors;
@@ -87,9 +84,9 @@ public class JsonCompleteFileAppenderTest {
logger.error(logMsg, new IllegalArgumentException("badarg"));
this.loggerContextRule.getLoggerContext().stop(); // stops async thread
- List<String> lines = Files.readAllLines(logFile.toPath(), Charset.forName("UTF8"));
+ final List<String> lines = Files.readAllLines(logFile.toPath(), Charset.forName("UTF8"));
- String[] expected = {
+ final String[] expected = {
"[", // equals
"{", // equals
" \"thread\" : \"main\",", //
@@ -104,7 +101,7 @@ public class JsonCompleteFileAppenderTest {
" },", //
};
for (int i = 0; i < expected.length; i++) {
- String line = lines.get(i);
+ final String line = lines.get(i);
assertTrue("line " + i + " incorrect: [" + line + "], does not contain: [" + expected[i] + ']', line.contains(expected[i]));
}
final String location = "testFlushAtEndOfBatch";