Refactor common code into a private method. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6c2492f7 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6c2492f7 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6c2492f7
Branch: refs/heads/LOG4J2-1431 Commit: 6c2492f775f9c8c83d3103904d3c3c5e16be7768 Parents: b8f6a1c Author: Gary Gregory <[email protected]> Authored: Tue Aug 22 13:50:13 2017 -0600 Committer: Gary Gregory <[email protected]> Committed: Tue Aug 22 13:50:13 2017 -0600 ---------------------------------------------------------------------- log4j-api/src/main/java/org/apache/logging/log4j/Level.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6c2492f7/log4j-api/src/main/java/org/apache/logging/log4j/Level.java ---------------------------------------------------------------------- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/Level.java b/log4j-api/src/main/java/org/apache/logging/log4j/Level.java index 05d0655..cbb4dc7 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/Level.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/Level.java @@ -284,10 +284,14 @@ public final class Level implements Comparable<Level>, Serializable { if (name == null) { return defaultLevel; } - final Level level = LEVELS.get(name.toUpperCase(Locale.ENGLISH)); + final Level level = LEVELS.get(toUpperCase(name)); return level == null ? defaultLevel : level; } + private static String toUpperCase(final String name) { + return name.toUpperCase(Locale.ENGLISH); + } + /** * Return an array of all the Levels that have been registered. * @@ -308,7 +312,7 @@ public final class Level implements Comparable<Level>, Serializable { */ public static Level valueOf(final String name) { Objects.requireNonNull(name, "No level name given."); - final String levelName = name.toUpperCase(Locale.ENGLISH); + final String levelName = toUpperCase(name); final Level level = LEVELS.get(levelName); if (level != null) { return level;
