From e7e6cfaecfa44729bc7eae75a80493ec3e11944b Mon Sep 17 00:00:00 2001 From: Koen De Groote Date: Mon, 14 Oct 2019 18:45:47 +0200 Subject: [PATCH] LUCENE-8994: Code Cleanup - Pass values to list constructor instead of empty constructor followed by addAll(). (#919) --- lucene/CHANGES.txt | 3 +++ .../blocktreeords/OrdsBlockTreeTermsReader.java | 3 +-- .../codecs/bloom/BloomFilteringPostingsFormat.java | 3 +-- .../lucene/codecs/memory/FSTOrdTermsReader.java | 3 +-- .../apache/lucene/codecs/memory/FSTTermsReader.java | 3 +-- .../lucene/codecs/blocktree/BlockTreeTermsReader.java | 3 +-- .../lucene/replicator/IndexReplicationHandler.java | 3 +-- .../codecs/idversion/VersionBlockTreeTermsReader.java | 3 +-- .../lucene/dependencies/GetMavenDependenciesTask.java | 3 +-- .../solr/handler/dataimport/RegexTransformer.java | 3 +-- .../src/java/org/apache/solr/cloud/ZkController.java | 3 +-- .../cloud/api/collections/ReindexCollectionCmd.java | 3 +-- .../cloud/autoscaling/sim/SimNodeStateProvider.java | 3 +-- .../core/src/java/org/apache/solr/core/SolrCores.java | 11 +++++------ .../handler/admin/SegmentsInfoRequestHandler.java | 3 +-- .../apache/solr/handler/component/SearchHandler.java | 3 +-- .../schema/analysis/ManagedSynonymFilterFactory.java | 8 +++----- .../analysis/ManagedSynonymGraphFilterFactory.java | 6 ++---- .../java/org/apache/solr/servlet/HttpSolrCall.java | 3 +-- solr/core/src/java/org/apache/solr/util/SolrCLI.java | 3 +-- .../solr/client/solrj/impl/BaseCloudSolrClient.java | 3 +-- .../java/org/apache/solr/client/solrj/io/Tuple.java | 3 +-- .../solr/client/solrj/io/eval/SetValueEvaluator.java | 3 +-- .../client/solrj/io/eval/TermVectorsEvaluator.java | 3 +-- .../client/solrj/io/graph/ShortestPathStream.java | 3 +-- .../solr/client/solrj/io/ops/GroupOperation.java | 6 ++---- .../client/solrj/response/schema/SchemaResponse.java | 9 +++------ .../solr/cloud/AbstractFullDistribZkTestBase.java | 3 +-- 28 files changed, 40 insertions(+), 69 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 084ac420167..b87852fb04c 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -225,6 +225,9 @@ Other * LUCENE-8999: LuceneTestCase.expectThrows now propogates assert/assumption failures up to the test w/o wrapping in a new assertion failure unless the caller has explicitly expected them (hossman) +* LUCENE-8994: Code Cleanup - Pass values to list constructor instead of empty constructor followed by addAll(). (Koen De Groote) + + ======================= Lucene 8.2.0 ======================= API Changes diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsBlockTreeTermsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsBlockTreeTermsReader.java index e07cee099de..3350e46caa0 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsBlockTreeTermsReader.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsBlockTreeTermsReader.java @@ -237,8 +237,7 @@ public final class OrdsBlockTreeTermsReader extends FieldsProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", fields)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", fields)); resources.add(Accountables.namedAccountable("delegate", postingsReader)); return Collections.unmodifiableList(resources); } diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java index b9a23992281..0bb09f35ca5 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java @@ -392,8 +392,7 @@ public final class BloomFilteringPostingsFormat extends PostingsFormat { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", bloomsByFieldName)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", bloomsByFieldName)); if (delegateFieldsProducer != null) { resources.add(Accountables.namedAccountable("delegate", delegateFieldsProducer)); } diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java index 0fa8ebe0524..7ecf19cc9f6 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java @@ -867,8 +867,7 @@ public class FSTOrdTermsReader extends FieldsProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", fields)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", fields)); resources.add(Accountables.namedAccountable("delegate", postingsReader)); return Collections.unmodifiableList(resources); } diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java index a5abfff355a..33084766424 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java @@ -768,8 +768,7 @@ public class FSTTermsReader extends FieldsProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", fields)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", fields)); resources.add(Accountables.namedAccountable("delegate", postingsReader)); return Collections.unmodifiableCollection(resources); } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java index 0e9fe6bc48f..3713452d2d8 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java @@ -336,8 +336,7 @@ public final class BlockTreeTermsReader extends FieldsProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", fields)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", fields)); resources.add(Accountables.namedAccountable("delegate", postingsReader)); return Collections.unmodifiableList(resources); } diff --git a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java index 71165c425a0..69840747a87 100644 --- a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java +++ b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java @@ -144,8 +144,7 @@ public class IndexReplicationHandler implements ReplicationHandler { // if there were any IO errors reading the expected commit point (i.e. // segments files mismatch), then ignore that commit either. if (commit != null && commit.getSegmentsFileName().equals(segmentsFile)) { - Set commitFiles = new HashSet<>(); - commitFiles.addAll(commit.getFileNames()); + Set commitFiles = new HashSet<>(commit.getFileNames()); Matcher matcher = IndexFileNames.CODEC_FILE_PATTERN.matcher(""); for (String file : dir.listAll()) { if (!commitFiles.contains(file) diff --git a/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/VersionBlockTreeTermsReader.java b/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/VersionBlockTreeTermsReader.java index b33b258f562..8001a22d9ff 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/VersionBlockTreeTermsReader.java +++ b/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/VersionBlockTreeTermsReader.java @@ -233,8 +233,7 @@ public final class VersionBlockTreeTermsReader extends FieldsProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); - resources.addAll(Accountables.namedAccountables("field", fields)); + List resources = new ArrayList<>(Accountables.namedAccountables("field", fields)); resources.add(Accountables.namedAccountable("delegate", postingsReader)); return Collections.unmodifiableList(resources); } diff --git a/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java b/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java index df3668dcdf4..570016cfeb1 100644 --- a/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java +++ b/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java @@ -443,8 +443,7 @@ public class GetMavenDependenciesTask extends Task { private void appendAllInternalDependencies(StringBuilder builder) { for (Map.Entry> entry : internalCompileScopeDependencies.entrySet()) { String artifactId = entry.getKey(); - List exclusions = new ArrayList<>(); - exclusions.addAll(entry.getValue()); + List exclusions = new ArrayList<>(entry.getValue()); SortedSet extDeps = allExternalDependencies.get(artifactId); if (null != extDeps) { for (ExternalDependency externalDependency : extDeps) { diff --git a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/RegexTransformer.java b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/RegexTransformer.java index 7a919de0dfc..719decae906 100644 --- a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/RegexTransformer.java +++ b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/RegexTransformer.java @@ -131,8 +131,7 @@ public class RegexTransformer extends Transformer { @SuppressWarnings("unchecked") private List readBySplit(String splitBy, String value) { String[] vals = value.split(splitBy); - List l = new ArrayList<>(); - l.addAll(Arrays.asList(vals)); + List l = new ArrayList<>(Arrays.asList(vals)); return l; } diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 403f2822d41..4f6218f1239 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -2012,8 +2012,7 @@ public class ZkController implements Closeable { ZkNodeProps props = null; if (data != null) { props = ZkNodeProps.load(data); - Map newProps = new HashMap<>(); - newProps.putAll(props.getProperties()); + Map newProps = new HashMap<>(props.getProperties()); newProps.put(CONFIGNAME_PROP, confSetName); props = new ZkNodeProps(newProps); } else { diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReindexCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReindexCollectionCmd.java index da9bacb0c7c..6059d3b1628 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReindexCollectionCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReindexCollectionCmd.java @@ -521,11 +521,10 @@ public class ReindexCollectionCmd implements OverseerCollectionMessageHandler.Cm private Map setReindexingState(String collection, State state, Map props) throws Exception { String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection + REINDEXING_STATE_PATH; DistribStateManager stateManager = ocmh.cloudManager.getDistribStateManager(); - Map copyProps = new HashMap<>(); if (props == null) { // retrieve existing props, if any props = Utils.getJson(stateManager, path); } - copyProps.putAll(props); + Map copyProps = new HashMap<>(props); copyProps.put("state", state.toLower()); if (stateManager.hasData(path)) { stateManager.setData(path, Utils.toJSON(copyProps), -1); diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimNodeStateProvider.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimNodeStateProvider.java index e1df6fd2158..3a9d77508e4 100644 --- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimNodeStateProvider.java +++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimNodeStateProvider.java @@ -313,9 +313,8 @@ public class SimNodeStateProvider implements NodeStateProvider { if (tags.isEmpty()) { return new HashMap<>(); } - Map result = new HashMap<>(); Map metrics = getReplicaMetricsValues(node, tags.stream().filter(s -> s.startsWith("metrics:solr.core.")).collect(Collectors.toList())); - result.putAll(metrics); + Map result = new HashMap<>(metrics); Map values = nodeValues.get(node); if (values == null) { return result; diff --git a/solr/core/src/java/org/apache/solr/core/SolrCores.java b/solr/core/src/java/org/apache/solr/core/SolrCores.java index ad295f23af5..5a94f25bbb0 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCores.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCores.java @@ -182,10 +182,9 @@ class SolrCores { */ List getCores() { - List lst = new ArrayList<>(); synchronized (modifyLock) { - lst.addAll(cores.values()); + List lst = new ArrayList<>(cores.values()); return lst; } } @@ -201,10 +200,10 @@ class SolrCores { * @return List of currently loaded cores. */ Set getLoadedCoreNames() { - Set set = new TreeSet<>(); + Set set; synchronized (modifyLock) { - set.addAll(cores.keySet()); + set = new TreeSet<>(cores.keySet()); if (getTransientCacheHandler() != null) { set.addAll(getTransientCacheHandler().getLoadedCoreNames()); } @@ -239,9 +238,9 @@ class SolrCores { * @return all cores names, whether loaded or unloaded, transient or permanent. */ public Collection getAllCoreNames() { - Set set = new TreeSet<>(); + Set set; synchronized (modifyLock) { - set.addAll(cores.keySet()); + set = new TreeSet<>(cores.keySet()); if (getTransientCacheHandler() != null) { set.addAll(getTransientCacheHandler().getAllCoreNames()); } diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java index a7b044e3f4c..90ac7ce3550 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/SegmentsInfoRequestHandler.java @@ -170,8 +170,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase { } } SimpleOrderedMap segmentInfo = null; - List sortable = new ArrayList<>(); - sortable.addAll(infos.asList()); + List sortable = new ArrayList<>(infos.asList()); // Order by the number of live docs. The display is logarithmic so it is a little jumbled visually sortable.sort((s1, s2) -> (s2.info.maxDoc() - s2.getDelCount()) - (s1.info.maxDoc() - s1.getDelCount()) diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java index ecdc0ec1c38..64b8c9a441d 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java @@ -116,9 +116,8 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware , public void inform(SolrCore core) { this.core = core; - Set missing = new HashSet<>(); List c = (List) initArgs.get(INIT_COMPONENTS); - missing.addAll(core.getSearchComponents().checkContains(c)); + Set missing = new HashSet<>(core.getSearchComponents().checkContains(c)); List first = (List) initArgs.get(INIT_FIRST_COMPONENTS); missing.addAll(core.getSearchComponents().checkContains(first)); List last = (List) initArgs.get(INIT_LAST_COMPONENTS); diff --git a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymFilterFactory.java b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymFilterFactory.java index 87878ce87c7..fb4cc0471a1 100644 --- a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymFilterFactory.java +++ b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymFilterFactory.java @@ -160,9 +160,8 @@ public class ManagedSynonymFilterFactory extends BaseManagedTokenFilterFactory { "Invalid synonym file format! Expected a list of synonyms for "+key+ " but got "+mapping.getClass().getName()); } - - Set sortedVals = new TreeSet<>(); - sortedVals.addAll((List) entry.getValue()); + + Set sortedVals = new TreeSet<>((List) entry.getValue()); cpsm.mappings.put(key, sortedVals); } } @@ -195,8 +194,7 @@ public class ManagedSynonymFilterFactory extends BaseManagedTokenFilterFactory { if (cpsm == null) cpsm = new CasePreservedSynonymMappings(); - Set treeTerms = new TreeSet<>(); - treeTerms.addAll(jsonList); + Set treeTerms = new TreeSet<>(jsonList); cpsm.mappings.put(origTerm, treeTerms); madeChanges = true; // only add the cpsm to the synonymMappings if it has valid data diff --git a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java index 6d7c1f57085..b6472fe324b 100644 --- a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java +++ b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java @@ -156,8 +156,7 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact " but got "+mapping.getClass().getName()); } - Set sortedVals = new TreeSet<>(); - sortedVals.addAll((List) entry.getValue()); + Set sortedVals = new TreeSet<>((List) entry.getValue()); cpsm.mappings.put(key, sortedVals); } } @@ -190,8 +189,7 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact if (cpsm == null) cpsm = new CasePreservedSynonymMappings(); - Set treeTerms = new TreeSet<>(); - treeTerms.addAll(jsonList); + Set treeTerms = new TreeSet<>(jsonList); cpsm.mappings.put(origTerm, treeTerms); madeChanges = true; // only add the cpsm to the synonymMappings if it has valid data diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java index 546a195e00e..042c392eb36 100644 --- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java +++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java @@ -1012,8 +1012,7 @@ public class HttpSolrCall { Collections.shuffle(slices, random); for (Slice slice : slices) { - List randomizedReplicas = new ArrayList<>(); - randomizedReplicas.addAll(slice.getReplicas()); + List randomizedReplicas = new ArrayList<>(slice.getReplicas()); Collections.shuffle(randomizedReplicas, random); for (Replica replica : randomizedReplicas) { diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java index bcaa9b806ed..6374b838626 100755 --- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java +++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java @@ -990,8 +990,7 @@ public class SolrCLI implements CLIO { cloudManager.saveSnapshot(targetDir, true, redact); CLIO.err("- saved autoscaling snapshot to " + targetDir.getAbsolutePath()); } - HashSet liveNodes = new HashSet<>(); - liveNodes.addAll(cloudManager.getClusterStateProvider().getLiveNodes()); + HashSet liveNodes = new HashSet<>(cloudManager.getClusterStateProvider().getLiveNodes()); boolean withSuggestions = cli.hasOption("s"); boolean withDiagnostics = cli.hasOption("d") || cli.hasOption("n"); boolean withSortedNodes = cli.hasOption("n"); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java index f00e20d1530..0461e67f4fa 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java @@ -587,8 +587,7 @@ public abstract class BaseCloudSolrClient extends SolrClient { } nonRoutableRequest.setParams(nonRoutableParams); nonRoutableRequest.setBasicAuthCredentials(request.getBasicAuthUser(), request.getBasicAuthPassword()); - List urlList = new ArrayList<>(); - urlList.addAll(routes.keySet()); + List urlList = new ArrayList<>(routes.keySet()); Collections.shuffle(urlList, rand); LBSolrClient.Req req = new LBSolrClient.Req(nonRoutableRequest, urlList); try { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java index 1af5f08e9e7..56d86fe260d 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java @@ -194,8 +194,7 @@ public class Tuple implements Cloneable, MapWriter { } public Tuple clone() { - HashMap m = new HashMap(); - m.putAll(fields); + HashMap m = new HashMap(fields); Tuple clone = new Tuple(m); return clone; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetValueEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetValueEvaluator.java index 9ffc32f3342..8ded259e20f 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetValueEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetValueEvaluator.java @@ -47,8 +47,7 @@ public class SetValueEvaluator extends RecursiveObjectEvaluator implements ManyV value = ((String)value).replace("\"", ""); } key = key.replace("\"", ""); - Map map = new HashMap(); - map.putAll(tuple.fields); + Map map = new HashMap(tuple.fields); map.put(key, value); return new Tuple(map); } else { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/TermVectorsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/TermVectorsEvaluator.java index 7c097124054..5d6dba96def 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/TermVectorsEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/TermVectorsEvaluator.java @@ -87,7 +87,6 @@ public class TermVectorsEvaluator extends RecursiveObjectEvaluator implements Ma List tuples = (List) objects[0]; TreeMap docFreqs = new TreeMap(); - List features = new ArrayList(); List rowLabels = new ArrayList(); for (Tuple tuple : tuples) { @@ -148,7 +147,7 @@ public class TermVectorsEvaluator extends RecursiveObjectEvaluator implements Ma } int totalTerms = docFreqs.size(); Set keys = docFreqs.keySet(); - features.addAll(keys); + List features = new ArrayList(keys); double[][] docVec = new double[tuples.size()][]; for (int t = 0; t < tuples.size(); t++) { Tuple tuple = tuples.get(t); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java index c1dcceb1962..611417c519e 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java @@ -391,8 +391,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { List parents = v.get(p.peekFirst()); if (parents != null) { for(String parent : parents) { - LinkedList newPath = new LinkedList(); - newPath.addAll(p); + LinkedList newPath = new LinkedList(p); newPath.addFirst(parent); newPaths.add(newPath); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java index a2bd8c999c9..3db76ec2047 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java @@ -106,17 +106,15 @@ public class GroupOperation implements ReduceOperation { } public Tuple reduce() { - Map map = new HashMap(); - List list = new ArrayList(); LinkedList ll = new LinkedList(); while(priorityQueue.size() > 0) { ll.addFirst(priorityQueue.poll().getMap()); //This will clear priority queue and so it will be ready for the next group. } - list.addAll(ll); + List list = new ArrayList(ll); Map groupHead = list.get(0); - map.putAll(groupHead); + Map map = new HashMap(groupHead); map.put("group", list); return new Tuple(map); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/schema/SchemaResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/schema/SchemaResponse.java index 50a715ce0a1..eb9fdd542b1 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/schema/SchemaResponse.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/schema/SchemaResponse.java @@ -169,8 +169,7 @@ public class SchemaResponse extends SolrResponseBase { List> fieldsAttributes = new LinkedList<>(); List> fieldsResponse = (List>) schemaNamedList.get("fields"); for (NamedList fieldNamedList : fieldsResponse) { - Map fieldAttributes = new LinkedHashMap<>(); - fieldAttributes.putAll(extractAttributeMap(fieldNamedList)); + Map fieldAttributes = new LinkedHashMap<>(extractAttributeMap(fieldNamedList)); fieldsAttributes.add(fieldAttributes); } @@ -182,8 +181,7 @@ public class SchemaResponse extends SolrResponseBase { List> dynamicFieldsAttributes = new LinkedList<>(); List> dynamicFieldsResponse = (List>) schemaNamedList.get("dynamicFields"); for (NamedList fieldNamedList : dynamicFieldsResponse) { - Map dynamicFieldAttributes = new LinkedHashMap<>(); - dynamicFieldAttributes.putAll(extractAttributeMap(fieldNamedList)); + Map dynamicFieldAttributes = new LinkedHashMap<>(extractAttributeMap(fieldNamedList)); dynamicFieldsAttributes.add(dynamicFieldAttributes); } @@ -195,8 +193,7 @@ public class SchemaResponse extends SolrResponseBase { List> copyFieldsAttributes = new LinkedList<>(); List> copyFieldsResponse = (List>) schemaNamedList.get("copyFields"); for (NamedList copyFieldNamedList : copyFieldsResponse) { - Map copyFieldAttributes = new LinkedHashMap<>(); - copyFieldAttributes.putAll(extractAttributeMap(copyFieldNamedList)); + Map copyFieldAttributes = new LinkedHashMap<>(extractAttributeMap(copyFieldNamedList)); copyFieldsAttributes.add(copyFieldAttributes); } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index d9de129a031..f2bd4102a7b 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -2158,8 +2158,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes log.info("Took {} ms to see all replicas become active.", timer.getTime()); - List replicas = new ArrayList<>(); - replicas.addAll(notLeaders.values()); + List replicas = new ArrayList<>(notLeaders.values()); return replicas; }