You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2017/12/04 15:00:27 UTC

[2/6] commons-pool git commit: Fix a Java 9 IDE nag. Ensure possible exceptions are handled.

Fix a Java 9 IDE nag. Ensure possible exceptions are handled.

Project: http://git-wip-us.apache.org/repos/asf/commons-pool/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-pool/commit/1c7e75e7
Tree: http://git-wip-us.apache.org/repos/asf/commons-pool/tree/1c7e75e7
Diff: http://git-wip-us.apache.org/repos/asf/commons-pool/diff/1c7e75e7

Branch: refs/heads/master
Commit: 1c7e75e7e01c7fc6934b4b2b07ce680d77081a7d
Parents: ea59bd1
Author: mark <ma...@study04.dev.local>
Authored: Mon Dec 4 14:56:10 2017 +0000
Committer: mark <ma...@study04.dev.local>
Committed: Mon Dec 4 14:56:10 2017 +0000

----------------------------------------------------------------------
 .../apache/commons/pool2/impl/BaseGenericObjectPool.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-pool/blob/1c7e75e7/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index 5686588..b523e83 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -21,6 +21,7 @@ import java.io.StringWriter;
 import java.io.Writer;
 import java.lang.management.ManagementFactory;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.Deque;
 import java.util.Iterator;
@@ -608,7 +609,7 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
             } catch (final ClassNotFoundException e) {
                 clazz = Class.forName(evictionPolicyClassName);
             }
-            final Object policy = clazz.newInstance();
+            final Object policy = clazz.getConstructor().newInstance();
             if (policy instanceof EvictionPolicy<?>) {
                 @SuppressWarnings("unchecked") // safe, because we just checked the class
                 final
@@ -630,6 +631,14 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
             throw new IllegalArgumentException(
                     "Unable to create EvictionPolicy instance of type " +
                     evictionPolicyClassName, e);
+        } catch (final InvocationTargetException e) {
+            throw new IllegalArgumentException(
+                    "Unable to create EvictionPolicy instance of type " +
+                    evictionPolicyClassName, e);
+        } catch (final NoSuchMethodException e) {
+            throw new IllegalArgumentException(
+                    "Unable to create EvictionPolicy instance of type " +
+                    evictionPolicyClassName, e);
         }
     }