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 2020/12/07 16:43:50 UTC

[logging-log4j2] branch release-2.x updated: Use the singleton set instead of a new object for empty sets.

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


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 1589369  Use the singleton set instead of a new object for empty sets.
1589369 is described below

commit 158936920207915d824de1295fddc143ba84ad96
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 7 11:43:45 2020 -0500

    Use the singleton set instead of a new object for empty sets.
---
 .../org/apache/logging/log4j/util/FilteredObjectInputStream.java     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/FilteredObjectInputStream.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/FilteredObjectInputStream.java
index 8fcc7b4..6b7eea5 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/FilteredObjectInputStream.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/FilteredObjectInputStream.java
@@ -23,6 +23,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 
@@ -52,12 +53,12 @@ public class FilteredObjectInputStream extends ObjectInputStream {
     private final Collection<String> allowedExtraClasses;
 
     public FilteredObjectInputStream() throws IOException, SecurityException {
-        this.allowedExtraClasses = new HashSet<>();
+        this.allowedExtraClasses = Collections.emptySet();
     }
 
     public FilteredObjectInputStream(final InputStream inputStream) throws IOException {
         super(inputStream);
-        this.allowedExtraClasses = new HashSet<>();
+        this.allowedExtraClasses = Collections.emptySet();
     }
 
     public FilteredObjectInputStream(final Collection<String> allowedClasses) throws IOException, SecurityException {