Collapse multiple identical catch clauses into one.
diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
index b02bb38..a284637 100644
--- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
@@ -362,13 +362,10 @@
}
try {
value = method.invoke(bean);
- } catch (final InvocationTargetException e) {
- throw new RuntimeException("Couldn't invoke method: " + method,
- e);
} catch (final IllegalArgumentException e) {
throw new RuntimeException(
"Couldn't invoke method with 0 arguments: " + method, e);
- } catch (final IllegalAccessException e) {
+ } catch (final InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException("Couldn't invoke method: " + method,
e);
}
diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
index 3f32dfd..7f76690 100644
--- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
@@ -315,15 +315,7 @@
// value cannot be null here because isCompatibleType allows null
}
- } catch (final IllegalArgumentException e) {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": " + e.getMessage());
-
- } catch (final IllegalAccessException e) {
- throw new SQLException(
- "Cannot set " + prop.getName() + ": " + e.getMessage());
-
- } catch (final InvocationTargetException e) {
+ } catch (final IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
throw new SQLException(
"Cannot set " + prop.getName() + ": " + e.getMessage());
}
@@ -370,10 +362,7 @@
if (targetType == primitiveValueType) {
return true;
}
- } catch (final NoSuchFieldException e) {
- // lacking the TYPE field is a good sign that we're not working with a primitive wrapper.
- // we can't match for compatibility
- } catch (final IllegalAccessException e) {
+ } catch (final NoSuchFieldException | IllegalAccessException e) {
// an inaccessible TYPE field is a good sign that we're not working with a primitive wrapper.
// nothing to do. we can't match for compatibility
}
@@ -408,9 +397,9 @@
try {
return c.getDeclaredConstructor().newInstance();
- } catch (final IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
- throw new SQLException(
- "Cannot create " + c.getName() + ": " + e.getMessage());
+ } catch (final IllegalAccessException | InstantiationException | InvocationTargetException |
+ NoSuchMethodException e) {
+ throw new SQLException("Cannot create " + c.getName() + ": " + e.getMessage());
}
}
diff --git a/src/main/java/org/apache/commons/dbutils/DbUtils.java b/src/main/java/org/apache/commons/dbutils/DbUtils.java
index 8d716f9..fa290dd 100644
--- a/src/main/java/org/apache/commons/dbutils/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils/DbUtils.java
@@ -231,8 +231,6 @@
}
return true;
- } catch (final RuntimeException e) {
- return false;
} catch (final Exception e) {
return false;
}
@@ -415,13 +413,7 @@
try {
final Method method = adapted.getClass().getMethod("getParentLogger");
return (Logger)method.invoke(adapted);
- } catch (final NoSuchMethodException e) {
- parentLoggerSupported = false;
- throw new SQLFeatureNotSupportedException(e);
- } catch (final IllegalAccessException e) {
- parentLoggerSupported = false;
- throw new SQLFeatureNotSupportedException(e);
- } catch (final InvocationTargetException e) {
+ } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
parentLoggerSupported = false;
throw new SQLFeatureNotSupportedException(e);
}
diff --git a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
index b7da012..eb01b23 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
@@ -46,7 +46,6 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
index bbaed9b..b9e65fa 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
@@ -482,9 +482,7 @@
try {
getUrlInt = ResultSet.class.getMethod("getURL", Integer.TYPE);
getUrlString = ResultSet.class.getMethod("getURL", String.class);
- } catch(final NoSuchMethodException e) {
- // ignore
- } catch(final SecurityException e) {
+ } catch(final NoSuchMethodException | SecurityException e) {
// ignore
}
if (getUrlInt != null && getUrlString != null) {