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 2022/01/19 17:39:25 UTC
[logging-log4j2] 04/10: Use classic toArray() trick.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 64914e9bff89941a7aaaa6c148d4abcb2b6d2378
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 19 07:53:49 2022 -0500
Use classic toArray() trick.
---
log4j-api/src/main/java/org/apache/logging/log4j/Level.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 b5bf0de..48d36d1 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
@@ -74,6 +74,8 @@ import org.apache.logging.log4j.util.Strings;
*/
public final class Level implements Comparable<Level>, Serializable {
+ private static final Level[] EMPTY_ARRAY = {};
+
private static final ConcurrentMap<String, Level> LEVELS = new ConcurrentHashMap<>(); // SUPPRESS CHECKSTYLE
/**
@@ -316,7 +318,7 @@ public final class Level implements Comparable<Level>, Serializable {
* @return An array of Levels.
*/
public static Level[] values() {
- return Level.LEVELS.values().toArray(new Level[0]);
+ return Level.LEVELS.values().toArray(EMPTY_ARRAY);
}
/**