Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2AFBA200D61 for ; Mon, 4 Dec 2017 16:00:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 298F7160BF9; Mon, 4 Dec 2017 15:00:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 70307160C05 for ; Mon, 4 Dec 2017 16:00:28 +0100 (CET) Received: (qmail 95538 invoked by uid 500); 4 Dec 2017 15:00:27 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 95510 invoked by uid 99); 4 Dec 2017 15:00:27 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2017 15:00:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C4565E9453; Mon, 4 Dec 2017 15:00:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: markt@apache.org To: commits@commons.apache.org Date: Mon, 04 Dec 2017 15:00:27 -0000 Message-Id: In-Reply-To: <6f73ed27400f48959259ec826f3bfb60@git.apache.org> References: <6f73ed27400f48959259ec826f3bfb60@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/6] commons-pool git commit: Fix a Java 9 IDE nag. Ensure possible exceptions are handled. archived-at: Mon, 04 Dec 2017 15:00:29 -0000 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 Authored: Mon Dec 4 14:56:10 2017 +0000 Committer: mark 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 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 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); } }