Repository: logging-log4j2 Updated Branches: refs/heads/master c513f1333 -> 19c92876f
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java index 91f9bcb..a52921d 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java @@ -112,7 +112,7 @@ public class JndiManager extends AbstractManager { } @Override - protected void releaseSub(long timeout, TimeUnit timeUnit) { + protected void releaseSub(final long timeout, final TimeUnit timeUnit) { JndiCloser.closeSilently(this.context); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SslSocketManager.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SslSocketManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SslSocketManager.java index 73e2230..ec5c64a 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SslSocketManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SslSocketManager.java @@ -60,7 +60,7 @@ public class SslSocketManager extends TcpSocketManager { public SslSocketManager(final String name, final OutputStream os, final Socket sock, final SslConfiguration sslConfig, final InetAddress inetAddress, final String host, final int port, final int connectTimeoutMillis, final int delay, final boolean immediateFail, - final Layout<? extends Serializable> layout, int bufferSize) { + final Layout<? extends Serializable> layout, final int bufferSize) { super(name, os, sock, inetAddress, host, port, connectTimeoutMillis, delay, immediateFail, layout, bufferSize); this.sslConfig = sslConfig; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 a1b8f2d..73933f7 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 @@ -79,7 +79,7 @@ public class TcpSocketManager extends AbstractSocketManager { */ public TcpSocketManager(final String name, final OutputStream os, final Socket socket, final InetAddress inetAddress, final String host, final int port, final int connectTimeoutMillis, final int delay, - final boolean immediateFail, final Layout<? extends Serializable> layout, int bufferSize) { + final boolean immediateFail, final Layout<? extends Serializable> layout, final int bufferSize) { super(name, os, inetAddress, host, port, layout, true, bufferSize); this.connectTimeoutMillis = connectTimeoutMillis; this.reconnectionDelay = delay; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java index e13bae6..13ba63c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java @@ -21,17 +21,17 @@ package org.apache.logging.log4j.core.pattern; */ public final class HtmlTextRenderer implements TextRenderer { - public HtmlTextRenderer(String[] formats) { + public HtmlTextRenderer(final String[] formats) { // TODO Auto-generated constructor stub } @Override - public void render(String input, StringBuilder output, String styleName) { + public void render(final String input, final StringBuilder output, final String styleName) { // TODO Auto-generated method stub } @Override - public void render(StringBuilder input, StringBuilder output) { + public void render(final StringBuilder input, final StringBuilder output) { // TODO Auto-generated method stub } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java index b9ac604..f71e230 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java @@ -1,332 +1,332 @@ -/* - * 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.pattern; - -import static org.fusesource.jansi.AnsiRenderer.Code.BG_RED; -import static org.fusesource.jansi.AnsiRenderer.Code.BOLD; -import static org.fusesource.jansi.AnsiRenderer.Code.RED; -import static org.fusesource.jansi.AnsiRenderer.Code.WHITE; -import static org.fusesource.jansi.AnsiRenderer.Code.YELLOW; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import org.apache.logging.log4j.status.StatusLogger; -import org.fusesource.jansi.Ansi; -import org.fusesource.jansi.AnsiRenderer; -import org.fusesource.jansi.AnsiRenderer.Code; - -/** - * Renders an input as ANSI escaped output. - * - * Uses the JAnsi rendering syntax as the default to render a message into an ANSI escaped string. - * - * The default syntax for embedded ANSI codes is: - * - * <pre> - * @|<em>code</em>(,<em>code</em>)* <em>text</em>|@ - * </pre> - * - * For example, to render the message {@code "Hello"} in green, use: - * - * <pre> - * @|green Hello|@ - * </pre> - * - * To render the message {@code "Hello"} in bold and red, use: - * - * <pre> - * @|bold,red Warning!|@ - * </pre> - * - * You can also define custom style names in the configuration with the syntax: - * - * <pre> - * %message{ansi}{StyleName=value(,value)*( StyleName=value(,value)*)*}%n - * </pre> - * - * For example: - * - * <pre> - * %message{ansi}{WarningStyle=red,bold KeyStyle=white ValueStyle=blue}%n - * </pre> - * - * The call site can look like this: - * - * <pre> - * logger.info("@|KeyStyle {}|@ = @|ValueStyle {}|@", entry.getKey(), entry.getValue()); - * </pre> - * - * Note: This class originally copied and then heavily modified code from JAnsi's AnsiRenderer (which is licensed as - * Apache 2.0.) - * - * @see AnsiRenderer - */ -public final class JAnsiTextRenderer implements TextRenderer { - - public static final Map<String, Code[]> DefaultExceptionStyleMap; - static final Map<String, Code[]> DefaultMessageStyleMap; - private static final Map<String, Map<String, Code[]>> PrefedinedStyleMaps; - - private static void put(Map<String, Code[]> map, String name, Code... codes) { - map.put(name, codes); - } - - static { - Map<String, Map<String, Code[]>> tempPreDefs = new HashMap<>(); - // Default style: Spock - { - // TODO Should the keys be in an enum? - Map<String, Code[]> map = new HashMap<>(); - put(map, "Prefix", WHITE); - put(map, "Name", BG_RED, WHITE); - put(map, "NameMessageSeparator", BG_RED, WHITE); - put(map, "Message", BG_RED, WHITE, BOLD); - put(map, "At", WHITE); - put(map, "CauseLabel", WHITE); - put(map, "Text", WHITE); - put(map, "More", WHITE); - put(map, "Suppressed", WHITE); - // StackTraceElement - put(map, "StackTraceElement.ClassName", YELLOW); - put(map, "StackTraceElement.ClassMethodSeparator", YELLOW); - put(map, "StackTraceElement.MethodName", YELLOW); - put(map, "StackTraceElement.NativeMethod", YELLOW); - put(map, "StackTraceElement.FileName", RED); - put(map, "StackTraceElement.LineNumber", RED); - put(map, "StackTraceElement.Container", RED); - put(map, "StackTraceElement.ContainerSeparator", WHITE); - put(map, "StackTraceElement.UnknownSource", RED); - // ExtraClassInfo - put(map, "ExtraClassInfo.Inexact", YELLOW); - put(map, "ExtraClassInfo.Container", YELLOW); - put(map, "ExtraClassInfo.ContainerSeparator", YELLOW); - put(map, "ExtraClassInfo.Location", YELLOW); - put(map, "ExtraClassInfo.Version", YELLOW); - // Save - DefaultExceptionStyleMap = Collections.unmodifiableMap(map); - tempPreDefs.put("Spock", DefaultExceptionStyleMap); - } - // Style: Kirk - { - // TODO Should the keys be in an enum? - Map<String, Code[]> map = new HashMap<>(); - put(map, "Prefix", WHITE); - put(map, "Name", BG_RED, YELLOW, BOLD); - put(map, "NameMessageSeparator", BG_RED, YELLOW); - put(map, "Message", BG_RED, WHITE, BOLD); - put(map, "At", WHITE); - put(map, "CauseLabel", WHITE); - put(map, "Text", WHITE); - put(map, "More", WHITE); - put(map, "Suppressed", WHITE); - // StackTraceElement - put(map, "StackTraceElement.ClassName", BG_RED, WHITE); - put(map, "StackTraceElement.ClassMethodSeparator", BG_RED, YELLOW); - put(map, "StackTraceElement.MethodName", BG_RED, YELLOW); - put(map, "StackTraceElement.NativeMethod", BG_RED, YELLOW); - put(map, "StackTraceElement.FileName", RED); - put(map, "StackTraceElement.LineNumber", RED); - put(map, "StackTraceElement.Container", RED); - put(map, "StackTraceElement.ContainerSeparator", WHITE); - put(map, "StackTraceElement.UnknownSource", RED); - // ExtraClassInfo - put(map, "ExtraClassInfo.Inexact", YELLOW); - put(map, "ExtraClassInfo.Container", WHITE); - put(map, "ExtraClassInfo.ContainerSeparator", WHITE); - put(map, "ExtraClassInfo.Location", YELLOW); - put(map, "ExtraClassInfo.Version", YELLOW); - // Save - tempPreDefs.put("Kirk", Collections.unmodifiableMap(map)); - } - { - Map<String, Code[]> temp = new HashMap<>(); - // TODO - DefaultMessageStyleMap = Collections.unmodifiableMap(temp); - } - PrefedinedStyleMaps = Collections.unmodifiableMap(tempPreDefs); - } - - private final String beginToken; - private final int beginTokenLen; - private final String endToken; - private final int endTokenLen; - private final Map<String, Code[]> styleMap; - - public JAnsiTextRenderer(final String[] formats, Map<String, Code[]> defaultStyleMap) { - String tempBeginToken = AnsiRenderer.BEGIN_TOKEN; - String tempEndToken = AnsiRenderer.END_TOKEN; - Map<String, Code[]> map; - if (formats.length > 1) { - final String allStylesStr = formats[1]; - // Style def split - final String[] allStyleAssignmentsArr = allStylesStr.split(" "); - map = new HashMap<>(allStyleAssignmentsArr.length + defaultStyleMap.size()); - map.putAll(defaultStyleMap); - for (final String styleAssignmentStr : allStyleAssignmentsArr) { - final String[] styleAssignmentArr = styleAssignmentStr.split("="); - if (styleAssignmentArr.length != 2) { - StatusLogger.getLogger().warn("{} parsing style \"{}\", expected format: StyleName=Code(,Code)*", - getClass().getSimpleName(), styleAssignmentStr); - } else { - final String styleName = styleAssignmentArr[0]; - final String codeListStr = styleAssignmentArr[1]; - final String[] codeNames = codeListStr.split(","); - if (codeNames.length == 0) { - StatusLogger.getLogger().warn( - "{} parsing style \"{}\", expected format: StyleName=Code(,Code)*", - getClass().getSimpleName(), styleAssignmentStr); - } else { - switch (styleName) { - case "BeginToken": - tempBeginToken = codeNames[0]; - break; - case "EndToken": - tempEndToken = codeNames[0]; - break; - case "StyleMapName": - final String predefinedMapName = codeNames[0]; - Map<String, Code[]> predefinedMap = PrefedinedStyleMaps.get(predefinedMapName); - if (predefinedMap != null) { - map.putAll(predefinedMap); - } else { - StatusLogger.getLogger().warn("Unknown predefined map name {}, pick one of {}", - predefinedMapName, null); - } - break; - default: - final Code[] codes = new Code[codeNames.length]; - for (int i = 0; i < codes.length; i++) { - codes[i] = toCode(codeNames[i]); - } - map.put(styleName, codes); - } - } - } - } - } else { - map = defaultStyleMap; - } - styleMap = map; - beginToken = tempBeginToken; - endToken = tempEndToken; - beginTokenLen = tempBeginToken.length(); - endTokenLen = tempEndToken.length(); - } - - public Map<String, Code[]> getStyleMap() { - return styleMap; - } - - private void render(final Ansi ansi, final Code code) { - if (code.isColor()) { - if (code.isBackground()) { - ansi.bg(code.getColor()); - } else { - ansi.fg(code.getColor()); - } - } else if (code.isAttribute()) { - ansi.a(code.getAttribute()); - } - } - - private void render(final Ansi ansi, final Code... codes) { - for (final Code code : codes) { - render(ansi, code); - } - } - - /** - * Renders the given text with the given names which can be ANSI code names or Log4j style names. - * - * @param text - * The text to render - * @param names - * ANSI code names or Log4j style names. - * @return A rendered string containing ANSI codes. - */ - private String render(final String text, final String... names) { - final Ansi ansi = Ansi.ansi(); - for (final String name : names) { - final Code[] codes = styleMap.get(name); - if (codes != null) { - render(ansi, codes); - } else { - render(ansi, toCode(name)); - } - } - return ansi.a(text).reset().toString(); - } - - // EXACT COPY OF StringBuilder version of the method but typed as String for input - @Override - public void render(final String input, final StringBuilder output, final String styleName) - throws IllegalArgumentException { - output.append(render(input, styleName)); - } - - @Override - public void render(final StringBuilder input, final StringBuilder output) throws IllegalArgumentException { - int i = 0; - int j, k; - - while (true) { - j = input.indexOf(beginToken, i); - if (j == -1) { - if (i == 0) { - output.append(input); - return; - } - output.append(input.substring(i, input.length())); - return; - } - output.append(input.substring(i, j)); - k = input.indexOf(endToken, j); - - if (k == -1) { - output.append(input); - return; - } - j += beginTokenLen; - final String spec = input.substring(j, k); - - final String[] items = spec.split(AnsiRenderer.CODE_TEXT_SEPARATOR, 2); - if (items.length == 1) { - output.append(input); - return; - } - final String replacement = render(items[1], items[0].split(",")); - - output.append(replacement); - - i = k + endTokenLen; - } - } - - private Code toCode(final String name) { - return Code.valueOf(name.toUpperCase(Locale.ENGLISH)); - } - - @Override - public String toString() { - return "JAnsiMessageRenderer [beginToken=" + beginToken + ", beginTokenLen=" + beginTokenLen + ", endToken=" - + endToken + ", endTokenLen=" + endTokenLen + ", styleMap=" + styleMap + "]"; - } - -} +/* + * 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.pattern; + +import static org.fusesource.jansi.AnsiRenderer.Code.BG_RED; +import static org.fusesource.jansi.AnsiRenderer.Code.BOLD; +import static org.fusesource.jansi.AnsiRenderer.Code.RED; +import static org.fusesource.jansi.AnsiRenderer.Code.WHITE; +import static org.fusesource.jansi.AnsiRenderer.Code.YELLOW; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import org.apache.logging.log4j.status.StatusLogger; +import org.fusesource.jansi.Ansi; +import org.fusesource.jansi.AnsiRenderer; +import org.fusesource.jansi.AnsiRenderer.Code; + +/** + * Renders an input as ANSI escaped output. + * + * Uses the JAnsi rendering syntax as the default to render a message into an ANSI escaped string. + * + * The default syntax for embedded ANSI codes is: + * + * <pre> + * @|<em>code</em>(,<em>code</em>)* <em>text</em>|@ + * </pre> + * + * For example, to render the message {@code "Hello"} in green, use: + * + * <pre> + * @|green Hello|@ + * </pre> + * + * To render the message {@code "Hello"} in bold and red, use: + * + * <pre> + * @|bold,red Warning!|@ + * </pre> + * + * You can also define custom style names in the configuration with the syntax: + * + * <pre> + * %message{ansi}{StyleName=value(,value)*( StyleName=value(,value)*)*}%n + * </pre> + * + * For example: + * + * <pre> + * %message{ansi}{WarningStyle=red,bold KeyStyle=white ValueStyle=blue}%n + * </pre> + * + * The call site can look like this: + * + * <pre> + * logger.info("@|KeyStyle {}|@ = @|ValueStyle {}|@", entry.getKey(), entry.getValue()); + * </pre> + * + * Note: This class originally copied and then heavily modified code from JAnsi's AnsiRenderer (which is licensed as + * Apache 2.0.) + * + * @see AnsiRenderer + */ +public final class JAnsiTextRenderer implements TextRenderer { + + public static final Map<String, Code[]> DefaultExceptionStyleMap; + static final Map<String, Code[]> DefaultMessageStyleMap; + private static final Map<String, Map<String, Code[]>> PrefedinedStyleMaps; + + private static void put(final Map<String, Code[]> map, final String name, final Code... codes) { + map.put(name, codes); + } + + static { + Map<String, Map<String, Code[]>> tempPreDefs = new HashMap<>(); + // Default style: Spock + { + // TODO Should the keys be in an enum? + Map<String, Code[]> map = new HashMap<>(); + put(map, "Prefix", WHITE); + put(map, "Name", BG_RED, WHITE); + put(map, "NameMessageSeparator", BG_RED, WHITE); + put(map, "Message", BG_RED, WHITE, BOLD); + put(map, "At", WHITE); + put(map, "CauseLabel", WHITE); + put(map, "Text", WHITE); + put(map, "More", WHITE); + put(map, "Suppressed", WHITE); + // StackTraceElement + put(map, "StackTraceElement.ClassName", YELLOW); + put(map, "StackTraceElement.ClassMethodSeparator", YELLOW); + put(map, "StackTraceElement.MethodName", YELLOW); + put(map, "StackTraceElement.NativeMethod", YELLOW); + put(map, "StackTraceElement.FileName", RED); + put(map, "StackTraceElement.LineNumber", RED); + put(map, "StackTraceElement.Container", RED); + put(map, "StackTraceElement.ContainerSeparator", WHITE); + put(map, "StackTraceElement.UnknownSource", RED); + // ExtraClassInfo + put(map, "ExtraClassInfo.Inexact", YELLOW); + put(map, "ExtraClassInfo.Container", YELLOW); + put(map, "ExtraClassInfo.ContainerSeparator", YELLOW); + put(map, "ExtraClassInfo.Location", YELLOW); + put(map, "ExtraClassInfo.Version", YELLOW); + // Save + DefaultExceptionStyleMap = Collections.unmodifiableMap(map); + tempPreDefs.put("Spock", DefaultExceptionStyleMap); + } + // Style: Kirk + { + // TODO Should the keys be in an enum? + Map<String, Code[]> map = new HashMap<>(); + put(map, "Prefix", WHITE); + put(map, "Name", BG_RED, YELLOW, BOLD); + put(map, "NameMessageSeparator", BG_RED, YELLOW); + put(map, "Message", BG_RED, WHITE, BOLD); + put(map, "At", WHITE); + put(map, "CauseLabel", WHITE); + put(map, "Text", WHITE); + put(map, "More", WHITE); + put(map, "Suppressed", WHITE); + // StackTraceElement + put(map, "StackTraceElement.ClassName", BG_RED, WHITE); + put(map, "StackTraceElement.ClassMethodSeparator", BG_RED, YELLOW); + put(map, "StackTraceElement.MethodName", BG_RED, YELLOW); + put(map, "StackTraceElement.NativeMethod", BG_RED, YELLOW); + put(map, "StackTraceElement.FileName", RED); + put(map, "StackTraceElement.LineNumber", RED); + put(map, "StackTraceElement.Container", RED); + put(map, "StackTraceElement.ContainerSeparator", WHITE); + put(map, "StackTraceElement.UnknownSource", RED); + // ExtraClassInfo + put(map, "ExtraClassInfo.Inexact", YELLOW); + put(map, "ExtraClassInfo.Container", WHITE); + put(map, "ExtraClassInfo.ContainerSeparator", WHITE); + put(map, "ExtraClassInfo.Location", YELLOW); + put(map, "ExtraClassInfo.Version", YELLOW); + // Save + tempPreDefs.put("Kirk", Collections.unmodifiableMap(map)); + } + { + Map<String, Code[]> temp = new HashMap<>(); + // TODO + DefaultMessageStyleMap = Collections.unmodifiableMap(temp); + } + PrefedinedStyleMaps = Collections.unmodifiableMap(tempPreDefs); + } + + private final String beginToken; + private final int beginTokenLen; + private final String endToken; + private final int endTokenLen; + private final Map<String, Code[]> styleMap; + + public JAnsiTextRenderer(final String[] formats, final Map<String, Code[]> defaultStyleMap) { + String tempBeginToken = AnsiRenderer.BEGIN_TOKEN; + String tempEndToken = AnsiRenderer.END_TOKEN; + Map<String, Code[]> map; + if (formats.length > 1) { + final String allStylesStr = formats[1]; + // Style def split + final String[] allStyleAssignmentsArr = allStylesStr.split(" "); + map = new HashMap<>(allStyleAssignmentsArr.length + defaultStyleMap.size()); + map.putAll(defaultStyleMap); + for (final String styleAssignmentStr : allStyleAssignmentsArr) { + final String[] styleAssignmentArr = styleAssignmentStr.split("="); + if (styleAssignmentArr.length != 2) { + StatusLogger.getLogger().warn("{} parsing style \"{}\", expected format: StyleName=Code(,Code)*", + getClass().getSimpleName(), styleAssignmentStr); + } else { + final String styleName = styleAssignmentArr[0]; + final String codeListStr = styleAssignmentArr[1]; + final String[] codeNames = codeListStr.split(","); + if (codeNames.length == 0) { + StatusLogger.getLogger().warn( + "{} parsing style \"{}\", expected format: StyleName=Code(,Code)*", + getClass().getSimpleName(), styleAssignmentStr); + } else { + switch (styleName) { + case "BeginToken": + tempBeginToken = codeNames[0]; + break; + case "EndToken": + tempEndToken = codeNames[0]; + break; + case "StyleMapName": + final String predefinedMapName = codeNames[0]; + Map<String, Code[]> predefinedMap = PrefedinedStyleMaps.get(predefinedMapName); + if (predefinedMap != null) { + map.putAll(predefinedMap); + } else { + StatusLogger.getLogger().warn("Unknown predefined map name {}, pick one of {}", + predefinedMapName, null); + } + break; + default: + final Code[] codes = new Code[codeNames.length]; + for (int i = 0; i < codes.length; i++) { + codes[i] = toCode(codeNames[i]); + } + map.put(styleName, codes); + } + } + } + } + } else { + map = defaultStyleMap; + } + styleMap = map; + beginToken = tempBeginToken; + endToken = tempEndToken; + beginTokenLen = tempBeginToken.length(); + endTokenLen = tempEndToken.length(); + } + + public Map<String, Code[]> getStyleMap() { + return styleMap; + } + + private void render(final Ansi ansi, final Code code) { + if (code.isColor()) { + if (code.isBackground()) { + ansi.bg(code.getColor()); + } else { + ansi.fg(code.getColor()); + } + } else if (code.isAttribute()) { + ansi.a(code.getAttribute()); + } + } + + private void render(final Ansi ansi, final Code... codes) { + for (final Code code : codes) { + render(ansi, code); + } + } + + /** + * Renders the given text with the given names which can be ANSI code names or Log4j style names. + * + * @param text + * The text to render + * @param names + * ANSI code names or Log4j style names. + * @return A rendered string containing ANSI codes. + */ + private String render(final String text, final String... names) { + final Ansi ansi = Ansi.ansi(); + for (final String name : names) { + final Code[] codes = styleMap.get(name); + if (codes != null) { + render(ansi, codes); + } else { + render(ansi, toCode(name)); + } + } + return ansi.a(text).reset().toString(); + } + + // EXACT COPY OF StringBuilder version of the method but typed as String for input + @Override + public void render(final String input, final StringBuilder output, final String styleName) + throws IllegalArgumentException { + output.append(render(input, styleName)); + } + + @Override + public void render(final StringBuilder input, final StringBuilder output) throws IllegalArgumentException { + int i = 0; + int j, k; + + while (true) { + j = input.indexOf(beginToken, i); + if (j == -1) { + if (i == 0) { + output.append(input); + return; + } + output.append(input.substring(i, input.length())); + return; + } + output.append(input.substring(i, j)); + k = input.indexOf(endToken, j); + + if (k == -1) { + output.append(input); + return; + } + j += beginTokenLen; + final String spec = input.substring(j, k); + + final String[] items = spec.split(AnsiRenderer.CODE_TEXT_SEPARATOR, 2); + if (items.length == 1) { + output.append(input); + return; + } + final String replacement = render(items[1], items[0].split(",")); + + output.append(replacement); + + i = k + endTokenLen; + } + } + + private Code toCode(final String name) { + return Code.valueOf(name.toUpperCase(Locale.ENGLISH)); + } + + @Override + public String toString() { + return "JAnsiMessageRenderer [beginToken=" + beginToken + ", beginTokenLen=" + beginTokenLen + ", endToken=" + + endToken + ", endTokenLen=" + endTokenLen + ", styleMap=" + styleMap + "]"; + } + +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java index 1fd2d2b..2287133 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java @@ -57,7 +57,7 @@ public final class MessagePatternConverter extends LogEventPatternConverter { this.textRenderer = loadMessageRenderer(noLookupsIdx >= 0 ? ArrayUtils.remove(options, noLookupsIdx) : options); } - private int loadNoLookups(String[] options) { + private int loadNoLookups(final String[] options) { if (options != null) { for (int i = 0; i < options.length; i++) { final String option = options[i]; @@ -69,7 +69,7 @@ public final class MessagePatternConverter extends LogEventPatternConverter { return -1; } - private TextRenderer loadMessageRenderer(String[] options) { + private TextRenderer loadMessageRenderer(final String[] options) { if (options != null) { for (String option : options) { switch (option.toUpperCase(Locale.ROOT)) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java index 9e26bba..5233432 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java @@ -28,12 +28,12 @@ public final class PlainTextRenderer implements TextRenderer { } @Override - public void render(String input, StringBuilder output, String styleName) { + public void render(final String input, final StringBuilder output, final String styleName) { output.append(input); } @Override - public void render(StringBuilder input, StringBuilder output) { + public void render(final StringBuilder input, final StringBuilder output) { output.append(input); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 6b75a83..52916b1 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 @@ -44,7 +44,7 @@ public class ExecutorServices { * @return {@code true} if the given executor terminated and {@code false} if the timeout elapsed before * termination. */ - public static boolean shutdown(ExecutorService executorService, long timeout, TimeUnit timeUnit, String source) { + public static boolean shutdown(final ExecutorService executorService, final long timeout, final TimeUnit timeUnit, final String source) { if (executorService == null || executorService.isTerminated()) { return true; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 cded615..d982dea 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 @@ -177,7 +177,7 @@ public class FixedDateFormat { * @param tz the time zone to use * @return the {@code FastDateFormat} object for formatting the date part of the pattern or {@code null} */ - public FastDateFormat getFastDateFormat(TimeZone tz) { + public FastDateFormat getFastDateFormat(final TimeZone tz) { return getDatePattern() == null ? null : FastDateFormat.getInstance(getDatePattern(), tz); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java index 989f861..0bc391d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java @@ -65,7 +65,7 @@ public class FileAppenderTest { private static final Path PATH = Paths.get(FILE_NAME); private static final int THREADS = 2; - public FileAppenderTest(boolean createOnDemand) { + public FileAppenderTest(final boolean createOnDemand) { super(); this.createOnDemand = createOnDemand; } @@ -176,7 +176,7 @@ public class FileAppenderTest { testMultipleLockingAppenderThreads(false, threadCount); } - private void testMultipleLockingAppenderThreads(final boolean lock, int threadCount) + private void testMultipleLockingAppenderThreads(final boolean lock, final int threadCount) throws InterruptedException, Exception { final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount); final Exception[] exceptionRef = new Exception[1]; @@ -228,8 +228,8 @@ public class FileAppenderTest { verifyFile(logEventCount * processCount); } - private static void writer(final boolean locking, final int logEventCount, final String name, boolean createOnDemand, - boolean concurrent) throws Exception { + private static void writer(final boolean locking, final int logEventCount, final String name, final boolean createOnDemand, + final boolean concurrent) throws Exception { final Layout<String> layout = createPatternLayout(); // @formatter:off final FileAppender appender = FileAppender.newBuilder() http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 aad7d27..09ac0c6 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 @@ -41,7 +41,7 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class JsonCompleteFileAppenderTest { - public JsonCompleteFileAppenderTest(Class<ContextSelector> contextSelector) { + public JsonCompleteFileAppenderTest(final Class<ContextSelector> contextSelector) { this.loggerContextRule = new LoggerContextRule("JsonCompleteFileAppenderTest.xml", contextSelector); this.cleanFiles = new CleanFiles(logFile); this.ruleChain = RuleChain.outerRule(cleanFiles).around(loggerContextRule); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java index 231da77..45a6074 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java @@ -118,7 +118,7 @@ public class SocketAppenderTest { testTcpAppender(tcpServer, logger, Constants.ENCODER_BYTE_BUFFER_SIZE); } - static void testTcpAppender(TcpSocketTestServer tcpTestServer, final Logger logger, final int bufferSize) + static void testTcpAppender(final TcpSocketTestServer tcpTestServer, final Logger logger, final int bufferSize) throws Exception { // @formatter:off final SocketAppender appender = SocketAppender.newBuilder() http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java index 8309ddf..1260d71 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java @@ -43,7 +43,7 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class XmlCompleteFileAppenderTest { - public XmlCompleteFileAppenderTest(Class<ContextSelector> contextSelector) { + public XmlCompleteFileAppenderTest(final Class<ContextSelector> contextSelector) { this.loggerContextRule = new LoggerContextRule("XmlCompleteFileAppenderTest.xml", contextSelector); this.cleanFiles = new CleanFiles(logFile); this.ruleChain = RuleChain.outerRule(cleanFiles).around(loggerContextRule); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 de07b51..ccf7ad1 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 @@ -118,7 +118,7 @@ public class RoutingAppenderWithPurgingTest { } - 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/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunConversant.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunConversant.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunConversant.java index 9b2adff..a36b20c 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunConversant.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunConversant.java @@ -25,7 +25,7 @@ import com.conversantmedia.util.concurrent.SpinPolicy; public class RunConversant extends AbstractRunQueue { @Override - BlockingQueue<String> createQueue(int capacity) { + BlockingQueue<String> createQueue(final int capacity) { return DisruptorBlockingQueueFactory.<String>createFactory(SpinPolicy.SPINNING).create(capacity); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunJCTools.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunJCTools.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunJCTools.java index a5a632c..7fe753b 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunJCTools.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/RunJCTools.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory.WaitStrat public class RunJCTools extends AbstractRunQueue { @Override - BlockingQueue<String> createQueue(int capacity) { + BlockingQueue<String> createQueue(final int capacity) { return JCToolsBlockingQueueFactory.<String>createFactory(WaitStrategy.SPIN).create(capacity); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java index 4bd1af9..6559572 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java @@ -46,14 +46,14 @@ public class ResolverUtilCustomProtocolTest { static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory { @Override - public URLStreamHandler createURLStreamHandler(String protocol) { + public URLStreamHandler createURLStreamHandler(final String protocol) { return new URLStreamHandler() { @Override - protected URLConnection openConnection(URL url) { + protected URLConnection openConnection(final URL url) { return open(url, null); } - private URLConnection open(URL url, Proxy proxy) { + private URLConnection open(final URL url, final Proxy proxy) { return new URLConnection(url) { @Override public void connect() throws IOException { @@ -63,7 +63,7 @@ public class ResolverUtilCustomProtocolTest { } @Override - protected URLConnection openConnection(URL url, Proxy proxy) { + protected URLConnection openConnection(final URL url, final Proxy proxy) { return open(url, proxy); } @@ -78,32 +78,32 @@ public class ResolverUtilCustomProtocolTest { static class SingleURLClassLoader extends ClassLoader { private final URL url; - public SingleURLClassLoader(URL url) { + public SingleURLClassLoader(final URL url) { this.url = url; } - public SingleURLClassLoader(URL url, ClassLoader parent) { + public SingleURLClassLoader(final URL url, final ClassLoader parent) { super(parent); this.url = url; } @Override - protected URL findResource(String name) { + protected URL findResource(final String name) { return url; } @Override - public URL getResource(String name) { + public URL getResource(final String name) { return findResource(name); } @Override - public Enumeration<URL> getResources(String name) throws IOException { + public Enumeration<URL> getResources(final String name) throws IOException { return findResources(name); } @Override - protected Enumeration<URL> findResources(String name) throws IOException { + protected Enumeration<URL> findResources(final String name) throws IOException { return Collections.enumeration(Arrays.asList(findResource(name))); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java index c0f1e3a..b5b894f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java @@ -165,7 +165,7 @@ public class ResolverUtilTest { resolverUtil.getClasses().iterator().next()); } - static URLClassLoader compileJarAndCreateClassLoader(String suffix) throws IOException, Exception { + static URLClassLoader compileJarAndCreateClassLoader(final String suffix) throws IOException, Exception { File workDir = compile(suffix); File jarFile = new File(workDir, "customplugin" + suffix + ".jar"); URI jarURI = jarFile.toURI(); @@ -174,12 +174,12 @@ public class ResolverUtilTest { return URLClassLoader.newInstance(new URL[] {jarURI.toURL()}); } - static URLClassLoader compileAndCreateClassLoader(String suffix) throws IOException { + static URLClassLoader compileAndCreateClassLoader(final String suffix) throws IOException { final File workDir = compile(suffix); return URLClassLoader.newInstance(new URL[] {workDir.toURI().toURL()}); } - static File compile(String suffix) throws IOException { + static File compile(final String suffix) throws IOException { final File orig = new File("target/test-classes/customplugin/FixedStringLayout.java.source"); final File workDir = new File("target/resolverutil" + suffix); final File f = new File(workDir, "customplugin" + suffix + "/FixedString" + suffix + "Layout.java"); @@ -197,7 +197,7 @@ public class ResolverUtilTest { return workDir; } - static void createJar(URI jarURI, File workDir, File f) throws Exception { + static void createJar(final URI jarURI, final File workDir, final File f) throws Exception { Map<String, String> env = new HashMap<>(); env.put("create", "true"); URI uri = URI.create("jar:file://" + jarURI.getRawPath()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java index c331a29..9f3d0b6 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java @@ -123,7 +123,7 @@ public final class ThrowableFormatOptionsTest { testFullAnsiEmptyConfig(tfo); } - private void testFullAnsiEmptyConfig(ThrowableFormatOptions tfo) { + private void testFullAnsiEmptyConfig(final ThrowableFormatOptions tfo) { TextRenderer textRenderer = tfo.getTextRenderer(); Assert.assertNotNull(textRenderer); Assert.assertTrue(textRenderer instanceof JAnsiTextRenderer); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 3bae771..9c0b861 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 @@ -137,12 +137,12 @@ public class ThrowableProxyTest { private final Permissions permissions; - public SimplePolicy(Permissions permissions) { + public SimplePolicy(final Permissions permissions) { this.permissions = permissions; } @Override - public PermissionCollection getPermissions(CodeSource codesource) { + public PermissionCollection getPermissions(final CodeSource codesource) { return permissions; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java index 24a38b6..da023df 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.Logger; public class Log4j2_1482_CoreTest extends Log4j2_1482_Test { @Override - protected void log(int runNumber) { + protected void log(final int runNumber) { if (runNumber == 2) { // System.out.println("Set a breakpoint here."); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java index d25a6ac..f14d348 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java @@ -44,7 +44,7 @@ public abstract class Log4j2_1482_Test { private static final int LOOP_COUNT = 10; - static void assertFileContents(int runNumber) throws IOException { + static void assertFileContents(final int runNumber) throws IOException { Path path = Paths.get(FOLDER + "/audit.tmp"); List<String> lines = Files.readAllLines(path, Charset.defaultCharset()); int i = 1; @@ -66,7 +66,7 @@ public abstract class Log4j2_1482_Test { protected abstract void log(int runNumber) ; - private void loopingRun(int loopCount) throws IOException { + private void loopingRun(final int loopCount) throws IOException { for (int i = 1; i <= loopCount; i++) { try (LoggerContext loggerContext = Configurator.initialize(getClass().getName(), CONFIG_LOCATION)) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java index 39a2324..917416e 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java @@ -48,7 +48,7 @@ public class CleanFiles extends AbstractExternalFileCleaner { } @Override - protected boolean clean(Path path, int tryIndex) throws IOException { + protected boolean clean(final Path path, final int tryIndex) throws IOException { return Files.deleteIfExists(path); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java index 5bddd12..09704ec 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java @@ -69,7 +69,7 @@ public class CleanFolders extends AbstractExternalFileCleaner { } @Override - protected boolean clean(Path path, int tryIndex) throws IOException { + protected boolean clean(final Path path, final int tryIndex) throws IOException { cleanFolder(path); return true; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/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 9434f25..cc0b343 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 @@ -44,7 +44,7 @@ import static org.junit.Assert.*; */ public class LoggerContextRule implements TestRule { - public static LoggerContextRule createShutdownTimeoutLoggerContextRule(String config) { + public static LoggerContextRule createShutdownTimeoutLoggerContextRule(final String config) { return new LoggerContextRule(config, 10, TimeUnit.SECONDS); } @@ -95,7 +95,7 @@ public class LoggerContextRule implements TestRule { this.shutdownTimeUnit = shutdownTimeUnit; } - public LoggerContextRule(String config, int shutdownTimeout, TimeUnit shutdownTimeUnit) { + public LoggerContextRule(final String config, final int shutdownTimeout, final TimeUnit shutdownTimeUnit) { this(config, null, shutdownTimeout, shutdownTimeUnit); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java index ac08bb3..e3ba5ff 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/URLStreamHandlerFactoryRule.java @@ -40,7 +40,7 @@ public class URLStreamHandlerFactoryRule implements TestRule { this(null); } - public URLStreamHandlerFactoryRule(URLStreamHandlerFactory newURLStreamHandlerFactory) { + public URLStreamHandlerFactoryRule(final URLStreamHandlerFactory newURLStreamHandlerFactory) { this.newURLStreamHandlerFactory = newURLStreamHandlerFactory; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java ---------------------------------------------------------------------- diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java index bdad7e4..ffb405d 100644 --- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java +++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java @@ -165,7 +165,7 @@ public final class FlumeAppender extends AbstractAppender implements FlumeEventF * @return A Flume Avro Appender. */ @PluginFactory - public static FlumeAppender createAppender(@PluginElement("Agents") Agent[] agents, + public static FlumeAppender createAppender(@PluginElement("Agents") final Agent[] agents, @PluginElement("Properties") final Property[] properties, @PluginAttribute("hosts") final String hosts, @PluginAttribute("embedded") final String embedded, http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java ---------------------------------------------------------------------- diff --git a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java index 11815cb..6e3bddb 100644 --- a/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java +++ b/log4j-samples/configuration/src/main/java/org/apache/logging/log4j/configuration/CustomConfiguration.java @@ -51,14 +51,14 @@ public class CustomConfiguration extends AbstractConfiguration { */ public static final String DEFAULT_PATTERN = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"; - public CustomConfiguration(LoggerContext loggerContext) { + public CustomConfiguration(final LoggerContext loggerContext) { this(loggerContext, ConfigurationSource.NULL_SOURCE); } /** * Constructor to create the default configuration. */ - public CustomConfiguration(LoggerContext loggerContext, final ConfigurationSource source) { + public CustomConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) { super(loggerContext, source); setName(CONFIG_NAME); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/19c92876/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java ---------------------------------------------------------------------- diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java index d621e76..8934f29 100644 --- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java +++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; public class Log4j2_1482_Slf4jTest extends Log4j2_1482_Test { @Override - protected void log(int runNumber) { + protected void log(final int runNumber) { if (runNumber == 2) { // System.out.println("Set a breakpoint here."); }