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

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1653697 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-01-21 23:26:25 +00:00
parent 0961e4179d
commit ad298b70cf
2 changed files with 7 additions and 25 deletions

View File

@ -85,35 +85,27 @@ public final class LoadSolrBuilder implements CommandBuilder {
if (event == Notifications.LifecycleEvent.BEGIN_TRANSACTION) { if (event == Notifications.LifecycleEvent.BEGIN_TRANSACTION) {
try { try {
loader.beginTransaction(); loader.beginTransaction();
} catch (SolrServerException e) { } catch (SolrServerException | IOException e) {
throw new MorphlineRuntimeException(e);
} catch (IOException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} }
} else if (event == Notifications.LifecycleEvent.COMMIT_TRANSACTION) { } else if (event == Notifications.LifecycleEvent.COMMIT_TRANSACTION) {
try { try {
loader.commitTransaction(); loader.commitTransaction();
} catch (SolrServerException e) { } catch (SolrServerException | IOException e) {
throw new MorphlineRuntimeException(e);
} catch (IOException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} }
} }
else if (event == Notifications.LifecycleEvent.ROLLBACK_TRANSACTION) { else if (event == Notifications.LifecycleEvent.ROLLBACK_TRANSACTION) {
try { try {
loader.rollbackTransaction(); loader.rollbackTransaction();
} catch (SolrServerException e) { } catch (SolrServerException | IOException e) {
throw new MorphlineRuntimeException(e);
} catch (IOException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} }
} }
else if (event == Notifications.LifecycleEvent.SHUTDOWN) { else if (event == Notifications.LifecycleEvent.SHUTDOWN) {
try { try {
loader.shutdown(); loader.shutdown();
} catch (SolrServerException e) { } catch (SolrServerException | IOException e) {
throw new MorphlineRuntimeException(e);
} catch (IOException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} }
} }
@ -127,9 +119,7 @@ public final class LoadSolrBuilder implements CommandBuilder {
SolrInputDocument doc = convert(record); SolrInputDocument doc = convert(record);
try { try {
loader.load(doc); loader.load(doc);
} catch (IOException e) { } catch (IOException | SolrServerException e) {
throw new MorphlineRuntimeException(e);
} catch (SolrServerException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} finally { } finally {
timerContext.stop(); timerContext.stop();

View File

@ -140,11 +140,7 @@ public class SolrLocator {
downloadedSolrHomeDir = Files.createTempDir(); downloadedSolrHomeDir = Files.createTempDir();
downloadedSolrHomeDir = zki.downloadConfigDir(zkClient, configName, downloadedSolrHomeDir); downloadedSolrHomeDir = zki.downloadConfigDir(zkClient, configName, downloadedSolrHomeDir);
mySolrHomeDir = downloadedSolrHomeDir.getAbsolutePath(); mySolrHomeDir = downloadedSolrHomeDir.getAbsolutePath();
} catch (KeeperException e) { } catch (KeeperException | InterruptedException | IOException e) {
throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
} catch (InterruptedException e) {
throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
} catch (IOException e) {
throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e); throw new MorphlineCompilationException("Cannot download schema.xml from ZooKeeper", config, e);
} finally { } finally {
zkClient.close(); zkClient.close();
@ -161,11 +157,7 @@ public class SolrLocator {
IndexSchema schema = new IndexSchema(solrConfig, "schema.xml", is); IndexSchema schema = new IndexSchema(solrConfig, "schema.xml", is);
validateSchema(schema); validateSchema(schema);
return schema; return schema;
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException | IOException | SAXException e) {
throw new MorphlineRuntimeException(e);
} catch (IOException e) {
throw new MorphlineRuntimeException(e);
} catch (SAXException e) {
throw new MorphlineRuntimeException(e); throw new MorphlineRuntimeException(e);
} }
} finally { } finally {