Remove use of Class.newInstance()
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / DefaultConfigParamsImpl.java
index 64502858a754b294c8f3b2d2aca31e056639f9f4..932069edda42fe005a408607940f2989ab46ca26 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 {