You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/20 23:09:55 UTC

[commons-jcs] branch master updated: Initialize Map on instantiation.

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/commons-jcs.git


The following commit(s) were added to refs/heads/master by this push:
     new 125abd8  Initialize Map on instantiation.
125abd8 is described below

commit 125abd89f22ae5b77a482b2a2011da89339d5702
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 18:09:51 2020 -0500

    Initialize Map on instantiation.
---
 .../commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java     | 4 +---
 .../jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java | 8 ++------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
index 57f4657..f588ec5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
@@ -439,9 +439,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
 
             keyFile.reset();
 
-            HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<>();
-            keys.putAll(keyHash);
-
+            HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<>(keyHash);
             if (keys.size() > 0)
             {
                 keyFile.writeObject(keys, 0);
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
index 280278b..20bff1c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
@@ -231,9 +231,7 @@ public class RemoteHttpCacheServlet
                             remoteCacheService.getMultiple( request.getCacheName(), request.getKeySet(), request.getRequesterId() );
                         if ( elementMap != null )
                         {
-                            Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<>();
-                            map.putAll(elementMap);
-                            response.setPayload(map);
+                            response.setPayload(new HashMap<>(elementMap));
                         }
                         break;
                     case GET_MATCHING:
@@ -241,9 +239,7 @@ public class RemoteHttpCacheServlet
                             remoteCacheService.getMatching( request.getCacheName(), request.getPattern(), request.getRequesterId() );
                         if ( elementMapMatching != null )
                         {
-                            Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<>();
-                            map.putAll(elementMapMatching);
-                            response.setPayload(map);
+                            response.setPayload(new HashMap<>(elementMapMatching));
                         }
                         break;
                     case REMOVE: