Skip to content

Commit

Permalink
refactor: returns new collection for index entry
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing committed Jan 9, 2024
1 parent 715e8be commit 032f705
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.collect.MultimapBuilder;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void remove(String objectName) {
public Set<String> indexedKeys() {
readLock.lock();
try {
return indexKeyObjectNamesMap.keySet();
return new LinkedHashSet<>(indexKeyObjectNamesMap.keySet());
} finally {
readLock.unlock();
}
Expand All @@ -110,7 +111,7 @@ public Collection<Map.Entry<String, String>> entries() {
public List<String> getByIndexKey(String indexKey) {
readLock.lock();
try {
return indexKeyObjectNamesMap.get(indexKey);
return List.copyOf(indexKeyObjectNamesMap.get(indexKey));
} finally {
readLock.unlock();
}
Expand Down

0 comments on commit 032f705

Please sign in to comment.