Remove use of Class.newInstance()
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / DefaultConfigParamsImpl.java
index 6450285..932069e 100644 (file)
@@ -216,8 +216,8 @@ public class DefaultConfigParamsImpl implements ConfigParams {
         try {
             String className = DefaultConfigParamsImpl.this.customRaftPolicyImplementationClass;
             LOG.info("Trying to use custom RaftPolicy {}", className);
-            return (RaftPolicy)Class.forName(className).newInstance();
-        } catch (Exception e) {
+            return (RaftPolicy)Class.forName(className).getDeclaredConstructor().newInstance();
+        } catch (ClassCastException | ReflectiveOperationException e) {
             if (LOG.isDebugEnabled()) {
                 LOG.error("Could not create custom raft policy, will stick with default", e);
             } else {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.