Skip to content

Commit

Permalink
SOLR-15485: discourage Collections.singleton.forEach use (#179)
Browse files Browse the repository at this point in the history
Resolved Conflicts:
	gradle/validation/validate-source-patterns.gradle
	solr/core/src/java/org/apache/solr/core/CoreContainer.java
  • Loading branch information
cpoerschke committed Jun 25, 2021
1 parent 62d2753 commit 3822541
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 1 addition & 3 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1138,9 +1138,7 @@ public void shutdown() {
} finally {
try {
if (updateShardHandler != null) {
customThreadPool.submit(() -> Collections.singleton(shardHandlerFactory).parallelStream().forEach(c -> {
updateShardHandler.close();
}));
customThreadPool.submit(() -> updateShardHandler.close());
}
} finally {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ protected String getShardsString() {
protected void destroyServers() throws Exception {
ExecutorService customThreadPool = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("closeThreadPool"));

customThreadPool.submit(() -> Collections.singleton(controlClient).parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));
customThreadPool.submit(() -> IOUtils.closeQuietly(controlClient));

customThreadPool.submit(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1732,25 +1732,17 @@ public void distribTearDown() throws Exception {
protected void destroyServers() throws Exception {
ExecutorService customThreadPool = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("closeThreadPool"));

customThreadPool.submit(() -> Collections.singleton(commonCloudSolrClient).parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));
customThreadPool.submit(() -> IOUtils.closeQuietly(commonCloudSolrClient));

customThreadPool.submit(() -> Collections.singleton(controlClient).parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));
customThreadPool.submit(() -> IOUtils.closeQuietly(controlClient));

customThreadPool.submit(() -> coreClients.parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));

customThreadPool.submit(() -> Collections.singletonList(controlClientCloud).parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));
customThreadPool.submit(() -> IOUtils.closeQuietly(controlClientCloud));

customThreadPool.submit(() -> Collections.singletonList(cloudClient).parallelStream().forEach(c -> {
IOUtils.closeQuietly(c);
}));
customThreadPool.submit(() -> IOUtils.closeQuietly(cloudClient));

ExecutorUtil.shutdownAndAwaitTermination(customThreadPool);

Expand Down

0 comments on commit 3822541

Please sign in to comment.