This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 2546cc1c684ef29350d34a94da6172a5d3e2dbb9
Author: Gary Gregory <[email protected]>
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 3897040..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[Level.LEVELS.values().size()]);
+        return Level.LEVELS.values().toArray(EMPTY_ARRAY);
     }
 
     /**

Reply via email to