Skip to content

Apache Lucene open-source search software

SOLR-7014: Collapse identical catch branches in try-catch statements

Shalin Shekhar Mangar0961e4179d50
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 19b7dfd0987..170ac4310a2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -76,6 +76,10 @@ New Features
* SOLR-6909: Extract atomic update handling logic into AtomicUpdateDocumentMerger class
and enable subclassing. (Steve Davids, yonik)
+Other Changes
+----------------------
+* SOLR-7014: Collapse identical catch branches in try-catch statements. (shalin)
+
================== 5.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
diff --git a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java
index 234dc16d539..b460849f03c 100644
--- a/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java
+++ b/solr/contrib/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java
@@ -94,9 +94,7 @@ public class ExtractingRequestHandler extends ContentStreamHandlerBase implement
if (config == null) {
try {
config = getDefaultConfig(core.getResourceLoader().getClassLoader());
- } catch (MimeTypeException e) {
- throw new SolrException(ErrorCode.SERVER_ERROR, e);
- } catch (IOException e) {
+ } catch (MimeTypeException | IOException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
}
diff --git a/solr/contrib/morphlines-cell/src/java/org/apache/solr/morphlines/cell/SolrCellBuilder.java b/solr/contrib/morphlines-cell/src/java/org/apache/solr/morphlines/cell/SolrCellBuilder.java
index 23e9bf615ec..188b379a47b 100644
--- a/solr/contrib/morphlines-cell/src/java/org/apache/solr/morphlines/cell/SolrCellBuilder.java
+++ b/solr/contrib/morphlines-cell/src/java/org/apache/solr/morphlines/cell/SolrCellBuilder.java
@@ -245,11 +245,7 @@ public final class SolrCellBuilder implements CommandBuilder {
try {
parser.parse(inputStream, parsingHandler, metadata, parseContext);
- } catch (IOException e) {
- throw new MorphlineRuntimeException("Cannot parse", e);
- } catch (SAXException e) {
- throw new MorphlineRuntimeException("Cannot parse", e);
- } catch (TikaException e) {
+ } catch (IOException | TikaException | SAXException e) {
throw new MorphlineRuntimeException("Cannot parse", e);
}
} finally {
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
index 1c5051d08b4..e43a57954cd 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
@@ -197,14 +197,9 @@ public class EmbeddedSolrServer extends SolrClient
// Now write it out
NamedList<Object> normalized = BinaryResponseWriter.getParsedResponse(req, rsp);
return normalized;
- }
- catch( IOException iox ) {
+ } catch( IOException | SolrException iox ) {
throw iox;
- }
- catch( SolrException sx ) {
- throw sx;
- }
- catch( Exception ex ) {
+ } catch( Exception ex ) {
throw new SolrServerException( ex );
}
finally {
diff --git a/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java b/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
index 8a00887bce7..18965463195 100644
--- a/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
+++ b/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
@@ -91,12 +91,9 @@ public class SolrZkServer {
if (zkProps.getClientPortAddress() == null) {
zkProps.setClientPort(Integer.parseInt(solrPort)+1000);
}
- } catch (QuorumPeerConfig.ConfigException e) {
+ } catch (QuorumPeerConfig.ConfigException | IOException e) {
if (zkRun != null)
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
- } catch (IOException e) {
- if (zkRun != null)
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
}
@@ -186,9 +183,7 @@ class SolrZkServerProps extends QuorumPeerConfig {
return cfg;
- } catch (IOException e) {
- throw new ConfigException("Error processing " + path, e);
- } catch (IllegalArgumentException e) {
+ } catch (IOException | IllegalArgumentException e) {
throw new ConfigException("Error processing " + path, e);
}
}
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 f7068f75202..48215272bca 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -853,12 +853,10 @@ public final class ZkController {
// Restore the interrupted status
Thread.currentThread().interrupt();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
- } catch (KeeperException e) {
- throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
- } catch (IOException e) {
+ } catch (KeeperException | IOException e) {
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
}
-
+
// in this case, we want to wait for the leader as long as the leader might
// wait for a vote, at least - but also long enough that a large cluster has
@@ -2021,14 +2019,10 @@ public final class ZkController {
stateData = zkClient.getData(znodePath, null, new Stat(), false);
} catch (NoNodeException ignoreMe) {
// safe to ignore as this znode will only exist if the leader initiated recovery
- } catch (ConnectionLossException cle) {
+ } catch (ConnectionLossException | SessionExpiredException cle) {
// sort of safe to ignore ??? Usually these are seen when the core is going down
// or there are bigger issues to deal with than reading this znode
log.warn("Unable to read "+znodePath+" due to: "+cle);
- } catch (SessionExpiredException see) {
- // sort of safe to ignore ??? Usually these are seen when the core is going down
- // or there are bigger issues to deal with than reading this znode
- log.warn("Unable to read "+znodePath+" due to: "+see);
} catch (Exception exc) {
log.error("Failed to read data from znode "+znodePath+" due to: "+exc);
if (exc instanceof SolrException) {
diff --git a/solr/core/src/java/org/apache/solr/core/Config.java b/solr/core/src/java/org/apache/solr/core/Config.java
index e77e95a6b8d..7bd2126914c 100644
--- a/solr/core/src/java/org/apache/solr/core/Config.java
+++ b/solr/core/src/java/org/apache/solr/core/Config.java
@@ -151,13 +151,7 @@ public class Config {
if (substituteProps) {
DOMUtil.substituteProperties(doc, getSubstituteProperties());
}
- } catch (ParserConfigurationException e) {
- SolrException.log(log, "Exception during parsing file: " + name, e);
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
- } catch (SAXException e) {
- SolrException.log(log, "Exception during parsing file: " + name, e);
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
- } catch (TransformerException e) {
+ } catch (ParserConfigurationException | SAXException | TransformerException e) {
SolrException.log(log, "Exception during parsing file: " + name, e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
diff --git a/solr/core/src/java/org/apache/solr/core/ZkContainer.java b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
index 5f17910de64..692a3c2c458 100644
--- a/solr/core/src/java/org/apache/solr/core/ZkContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
@@ -180,16 +180,12 @@ public class ZkContainer {
log.error("Could not connect to ZooKeeper", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
- } catch (IOException e) {
- log.error("", e);
- throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
- "", e);
- } catch (KeeperException e) {
+ } catch (IOException | KeeperException e) {
log.error("", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
}
-
+
}
this.zkController = zkController;
diff --git a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
index 815c96c602f..a2bae01697a 100644
--- a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
+++ b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
@@ -726,9 +726,7 @@ public class SnapPuller {
if (waitSearcher[0] != null) {
try {
waitSearcher[0].get();
- } catch (InterruptedException e) {
- SolrException.log(LOG, e);
- } catch (ExecutionException e) {
+ } catch (InterruptedException | ExecutionException e) {
SolrException.log(LOG, e);
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 0710f6c9bfa..3fd3be39648 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -598,9 +598,7 @@ public class RealTimeGetComponent extends SearchComponent
// TODO: do any kind of validation here?
updates.add(o);
- } catch (SolrException e) {
- log.warn("Exception reading log for updates", e);
- } catch (ClassCastException e) {
+ } catch (SolrException | ClassCastException e) {
log.warn("Exception reading log for updates", e);
}
}
diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
index 3b421ce37ad..abe1bb0b6a9 100644
--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
@@ -150,13 +150,9 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
Query res = TopLevelQuery(null); // pass null so we can tell later if an explicit field was provided or not
return res!=null ? res : newBooleanQuery(false);
}
- catch (ParseException tme) {
+ catch (ParseException | TokenMgrError tme) {
throw new SyntaxError("Cannot parse '" +query+ "': " + tme.getMessage(), tme);
- }
- catch (TokenMgrError tme) {
- throw new SyntaxError("Cannot parse '" +query+ "': " + tme.getMessage(), tme);
- }
- catch (BooleanQuery.TooManyClauses tmc) {
+ } catch (BooleanQuery.TooManyClauses tmc) {
throw new SyntaxError("Cannot parse '" +query+ "': too many boolean clauses", tmc);
}
}
diff --git a/solr/core/src/java/org/apache/solr/schema/CollationField.java b/solr/core/src/java/org/apache/solr/schema/CollationField.java
index 568fc980621..aa25481aae2 100644
--- a/solr/core/src/java/org/apache/solr/schema/CollationField.java
+++ b/solr/core/src/java/org/apache/solr/schema/CollationField.java
@@ -180,11 +180,8 @@ public class CollationField extends FieldType {
input = loader.openResource(fileName);
String rules = IOUtils.toString(input, "UTF-8");
return new RuleBasedCollator(rules);
- } catch (IOException e) {
- // io error
- throw new RuntimeException(e);
- } catch (ParseException e) {
- // invalid rules
+ } catch (IOException | ParseException e) {
+ // io error or invalid rules
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(input);
diff --git a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
index c0bee75f0a7..2170607d932 100644
--- a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
+++ b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
@@ -836,13 +836,7 @@ class FileExchangeRateProvider implements ExchangeRateProvider {
addRate(tmpRates, fromCurrency, toCurrency, exchangeRate);
}
- } catch (SAXException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error parsing currency config.", e);
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error parsing currency config.", e);
- } catch (ParserConfigurationException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error parsing currency config.", e);
- } catch (XPathExpressionException e) {
+ } catch (SAXException | XPathExpressionException | ParserConfigurationException | IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error parsing currency config.", e);
}
} catch (IOException e) {
diff --git a/solr/core/src/java/org/apache/solr/schema/EnumField.java b/solr/core/src/java/org/apache/solr/schema/EnumField.java
index ec3a365020b..24b43122ec5 100644
--- a/solr/core/src/java/org/apache/solr/schema/EnumField.java
+++ b/solr/core/src/java/org/apache/solr/schema/EnumField.java
@@ -126,13 +126,7 @@ public class EnumField extends PrimitiveFieldType {
enumStringToIntMap.put(valueStr, i);
}
}
- catch (ParserConfigurationException e) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing enums config.", e);
- }
- catch (SAXException e) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing enums config.", e);
- }
- catch (XPathExpressionException e) {
+ catch (ParserConfigurationException | XPathExpressionException | SAXException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing enums config.", e);
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java
index 971f86619b4..8b8b87f5636 100644
--- a/solr/core/src/java/org/apache/solr/search/Grouping.java
+++ b/solr/core/src/java/org/apache/solr/search/Grouping.java
@@ -450,12 +450,9 @@ public class Grouping {
}
try {
searcher.search(query, luceneFilter, collector);
- } catch (TimeLimitingCollector.TimeExceededException x) {
+ } catch (TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x) {
logger.warn( "Query: " + query + "; " + x.getMessage() );
qr.setPartialResults(true);
- } catch (ExitableDirectoryReader.ExitingReaderException e) {
- logger.warn( "Query: " + query + "; " + e.getMessage() );
- qr.setPartialResults(true);
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 838fccf92d5..479a33ea83b 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -234,12 +234,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
((DelegatingCollector)collector).finish();
}
}
- catch( TimeLimitingCollector.TimeExceededException x ) {
+ catch( TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x ) {
log.warn( "Query: " + query + "; " + x.getMessage() );
qr.setPartialResults(true);
- } catch ( ExitableDirectoryReader.ExitingReaderException e) {
- log.warn("Query: " + query + "; " + e.getMessage());
- qr.setPartialResults(true);
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java b/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
index e82170b1d38..8bc96d3260d 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
@@ -228,12 +228,9 @@ public class CommandHandler {
try {
searcher.search(query, luceneFilter, collector);
- } catch (TimeLimitingCollector.TimeExceededException x) {
+ } catch (TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x) {
partialResults = true;
logger.warn( "Query: " + query + "; " + x.getMessage() );
- } catch (ExitableDirectoryReader.ExitingReaderException e) {
- partialResults = true;
- logger.warn( "Query: " + query + "; " + e.getMessage() );
}
if (includeHitCount) {
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 212e10669df..8ea28c8db21 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -658,9 +658,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
if (waitSearcher!=null && waitSearcher[0] != null) {
try {
waitSearcher[0].get();
- } catch (InterruptedException e) {
- SolrException.log(log,e);
- } catch (ExecutionException e) {
+ } catch (InterruptedException | ExecutionException e) {
SolrException.log(log,e);
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
index b8c36ce8ef8..567fbd0ec49 100644
--- a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
@@ -66,9 +66,7 @@ public class HdfsUpdateLog extends UpdateLog {
if (future != null) {
try {
future.get();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- } catch (ExecutionException e) {
+ } catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
@@ -264,8 +262,6 @@ public class HdfsUpdateLog extends UpdateLog {
return path.getName().startsWith(prefix);
}
});
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 8e066c55340..16bbf329f77 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1302,10 +1302,6 @@ public class UpdateLog implements PluginInfoInitialized {
// versionInfo.unblockUpdates();
}
}
- } catch (InterruptedException e) {
- SolrException.log(log,e);
- } catch (IOException e) {
- SolrException.log(log,e);
} catch (Exception e) {
SolrException.log(log,e);
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java
index c634ec47ea1..d1c38351337 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java
@@ -429,13 +429,7 @@ public class StatelessScriptUpdateProcessorFactory extends UpdateRequestProcesso
}
}
- } catch (ScriptException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Unable to invoke function " + name +
- " in script: " +
- engine.getScriptFile().getFileName() +
- ": " + e.getMessage(), e);
- } catch (NoSuchMethodException e) {
+ } catch (ScriptException | NoSuchMethodException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to invoke function " + name +
" in script: " +
diff --git a/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
index 62b8a6e5a2c..f216487b807 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
@@ -125,9 +125,7 @@ public class URLClassifyProcessor extends UpdateRequestProcessor {
document.setField(canonicalUrlFieldname, getCanonicalUrl(normalizedURL));
}
log.debug(document.toString());
- } catch (MalformedURLException e) {
- log.warn("cannot get the normalized url for \"" + url + "\" due to " + e.getMessage());
- } catch (URISyntaxException e) {
+ } catch (MalformedURLException | URISyntaxException e) {
log.warn("cannot get the normalized url for \"" + url + "\" due to " + e.getMessage());
}
}
diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
index 564ad550956..d1812b2aa38 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
@@ -992,9 +992,7 @@ public class SolrPluginUtils {
Class pClazz = method.getParameterTypes()[0];
Object val = entry.getValue();
method.invoke(bean, val);
- } catch (InvocationTargetException e1) {
- throw new RuntimeException("Error invoking setter " + setterName + " on class : " + clazz.getName(), e1);
- } catch (IllegalAccessException e1) {
+ } catch (InvocationTargetException | IllegalAccessException e1) {
throw new RuntimeException("Error invoking setter " + setterName + " on class : " + clazz.getName(), e1);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
index 46dc0e45205..c3a25f2e6c9 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
@@ -559,9 +559,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
createCmd.setDataDir(getDataDir(core3dataDir));
client.request(createCmd);
- } catch (SolrServerException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
index 5fa42b7a701..f96c7c3df95 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
@@ -919,10 +919,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
delete.setCollectionName(collectionName);
client.request(delete);
- } catch (SolrServerException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
index 97da78daf48..ba6c553fa5e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
@@ -375,13 +375,11 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
try {
uReq.process(cloudClient);
uReq.process(controlClient);
- } catch (SolrServerException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
-
+
}
}
};
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
index e81f457f45d..db0ca46a5f7 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
@@ -170,10 +170,6 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
public void run() {
try {
setupOnConnect();
- } catch (InterruptedException e) {
- log.error("setup failed", e);
- es.close();
- return;
} catch (Throwable e) {
log.error("setup failed", e);
es.close();
@@ -251,9 +247,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
ZkCoreNodeProps leaderProps = new ZkCoreNodeProps(
ZkNodeProps.load(data));
return leaderProps.getCoreUrl();
- } catch (NoNodeException e) {
- Thread.sleep(500);
- } catch (SessionExpiredException e) {
+ } catch (NoNodeException | SessionExpiredException e) {
Thread.sleep(500);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java
index fe6d79f4c46..a852c2ccf8a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java
@@ -55,9 +55,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("async", "1000");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -74,9 +72,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -90,9 +86,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
r = sendRequest(params);
status = (NamedList) r.get("status");
message = (String) status.get("msg");
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -105,9 +99,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("async", "1001");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -117,9 +109,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set(OverseerCollectionProcessor.REQUESTID, "1001");
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -135,9 +125,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("async", "1002");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -149,9 +137,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -168,9 +154,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("async", "1002");
try {
r = sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
index f2c1291d723..095f9d4e139 100644
--- a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
@@ -416,9 +416,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
unloadCmd.setCoreName("multiunload" + freezeJ);
try {
adminClient.request(unloadCmd);
- } catch (SolrServerException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
index 283b7d1d751..267a6829221 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
@@ -176,9 +176,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
try {
zkClient.makePath("collections/collection4", true);
break;
- } catch (KeeperException.SessionExpiredException e) {
-
- } catch (KeeperException.ConnectionLossException e) {
+ } catch (KeeperException.SessionExpiredException | KeeperException.ConnectionLossException e) {
}
Thread.sleep(1000 * i);
@@ -289,9 +287,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
try {
zkClient.getChildren("/collections", this, true);
latch.countDown();
- } catch (KeeperException e) {
- throw new RuntimeException(e);
- } catch (InterruptedException e) {
+ } catch (KeeperException | InterruptedException e) {
throw new RuntimeException(e);
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
index 82d026d12e3..f2473866c01 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
@@ -21,7 +21,6 @@ import static java.util.Arrays.asList;
import static org.apache.solr.core.ConfigOverlay.getObjectByPath;
import static org.noggit.ObjectBuilder.getVal;
-import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
@@ -99,8 +98,6 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
ArrayList errs = new ArrayList();
collectErrors.add(errs);
invokeBulkCall((String)e.getKey() , errs, (Map) e.getValue());
- } catch (IOException e) {
- e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java b/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java
index 021bee9e27a..40c2ad6d01a 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java
@@ -22,7 +22,6 @@ import static java.text.MessageFormat.format;
import static org.apache.solr.rest.schema.TestBulkSchemaAPI.getCopyFields;
import static org.apache.solr.rest.schema.TestBulkSchemaAPI.getObj;
-import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -98,8 +97,6 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
ArrayList errs = new ArrayList();
collectErrors.add(errs);
invokeBulkCall(finalI,errs);
- } catch (IOException e) {
- e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
index 8f4c944bad6..a8033528a36 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java
@@ -82,12 +82,10 @@ public class TestRecoveryHdfs extends SolrTestCaseJ4 {
try {
URI uri = new URI(hdfsUri);
fs = FileSystem.newInstance(uri, new Configuration());
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (URISyntaxException e) {
+ } catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
-
+
System.setProperty("solr.ulog.dir", hdfsUri + "/solr/shard1");
initCore("solrconfig-tlog.xml","schema15.xml");
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index 9b8f8227f92..628f0973112 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -458,15 +458,7 @@ public class CloudSolrClient extends SolrClient {
Thread.currentThread().interrupt();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
- } catch (KeeperException e) {
- if (zk != null) zk.close();
- throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
- "", e);
- } catch (IOException e) {
- if (zk != null) zk.close();
- throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
- "", e);
- } catch (TimeoutException e) {
+ } catch (KeeperException | TimeoutException | IOException e) {
if (zk != null) zk.close();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java
index b8e42379e5c..33131b72d6f 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java
@@ -92,10 +92,8 @@ public class QueryRequest extends SolrRequest
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
- } catch (SolrServerException e){
+ } catch (SolrServerException | SolrException e){
throw e;
- } catch (SolrException s){
- throw s;
} catch (Exception e) {
throw new SolrServerException("Error executing query", e);
}