Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 63FCC18199 for ; Fri, 23 Oct 2015 19:25:53 +0000 (UTC) Received: (qmail 89850 invoked by uid 500); 23 Oct 2015 19:25:53 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 89803 invoked by uid 500); 23 Oct 2015 19:25:53 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 89793 invoked by uid 99); 23 Oct 2015 19:25:53 -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; Fri, 23 Oct 2015 19:25:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21A22E01F5; Fri, 23 Oct 2015 19:25:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: apurtell@apache.org To: commits@hbase.apache.org Date: Fri, 23 Oct 2015 19:25:53 -0000 Message-Id: <46ec3ce394114f639af348e3853bf996@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] hbase git commit: HBASE-14658 Addendum; Allow loading a MonkeyFactory by class name Repository: hbase Updated Branches: refs/heads/0.98 ba02635a4 -> 5950b81fb HBASE-14658 Addendum; Allow loading a MonkeyFactory by class name Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5950b81f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5950b81f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5950b81f Branch: refs/heads/0.98 Commit: 5950b81fb9a39556ddbdfb9d607e498fd2f7321d Parents: b5a5548 Author: Elliott Clark Authored: Thu Oct 22 11:22:53 2015 -0700 Committer: Andrew Purtell Committed: Fri Oct 23 12:23:45 2015 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hbase/chaos/factories/MonkeyFactory.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/5950b81f/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java ---------------------------------------------------------------------- diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java index 9ea34fd..bf00eab 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java @@ -88,13 +88,16 @@ public abstract class MonkeyFactory { public static MonkeyFactory getFactory(String factoryName) { MonkeyFactory fact = FACTORIES.get(factoryName); - if (fact == null) { + if (fact == null && factoryName != null && !factoryName.isEmpty()) { Class klass = null; try { klass = Class.forName(factoryName); - fact = (MonkeyFactory) ReflectionUtils.newInstance(klass); - } catch (ClassNotFoundException e) { + if (klass != null) { + fact = (MonkeyFactory) ReflectionUtils.newInstance(klass); + } + } catch (Exception e) { LOG.error("Error trying to create " + factoryName + " could not load it by class name"); + return null; } } return fact;