This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git


The following commit(s) were added to refs/heads/master by this push:
     new e79a494  Collapse multiple identical catch clauses into one.
e79a494 is described below

commit e79a494a3c1e8e2e50ff7ae88cb69647f13a22a7
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Jan 8 10:01:20 2021 -0500

    Collapse multiple identical catch clauses into one.
---
 .../apache/commons/dbutils/AbstractQueryRunner.java |  5 +----
 .../org/apache/commons/dbutils/BeanProcessor.java   | 21 +++++----------------
 .../java/org/apache/commons/dbutils/DbUtils.java    | 10 +---------
 .../org/apache/commons/dbutils/QueryRunnerTest.java |  1 -
 .../wrappers/SqlNullCheckedResultSetTest.java       |  4 +---
 5 files changed, 8 insertions(+), 33 deletions(-)

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 @@ public abstract class AbstractQueryRunner {
             }
             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 @@ public class BeanProcessor {
                   // 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 @@ public class BeanProcessor {
             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 @@ public class BeanProcessor {
         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 @@ public final class DbUtils {
             }
 
             return true;
-        } catch (final RuntimeException e) {
-            return false;
         } catch (final Exception e) {
             return false;
         }
@@ -415,13 +413,7 @@ public final class DbUtils {
                 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.Assert;
 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 @@ public class SqlNullCheckedResultSetTest extends 
BaseTestCase {
         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) {

Reply via email to