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 f4b44283801b5aadd7a55e10d088d784d06455d2 Author: Gary Gregory <[email protected]> AuthorDate: Wed Jan 19 07:59:05 2022 -0500 Use classic toArray() trick. --- log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java index 0e5e71a..37316c2 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java @@ -36,6 +36,8 @@ import java.util.Objects; */ public final class LoaderUtil { + private static final ClassLoader[] EMPTY_CLASS_LOADER_ARRAY = {}; + /** * System property to set to ignore the thread context ClassLoader. * @@ -115,7 +117,7 @@ public final class LoaderUtil { if (systemClassLoader != null) { classLoaders.add(systemClassLoader); } - return classLoaders.toArray(new ClassLoader[classLoaders.size()]); + return classLoaders.toArray(EMPTY_CLASS_LOADER_ARRAY); } /**
