Skip to content

Commit

Permalink
Merge pull request #782 from rhusar/MODCLUSTER-818
Browse files Browse the repository at this point in the history
MODCLUSTER-818 Remove usage of deprecated Class.newInstance() and avo…
  • Loading branch information
rhusar authored Mar 5, 2024
2 parents d8d3344 + 1768d5c commit 04f57d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
Expand Down Expand Up @@ -77,8 +78,8 @@ public LoadBalanceFactorProvider createLoadBalanceFactorProvider() {
@Override
public LoadMetric run() {
try {
return ModClusterListener.this.loadMetricClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return ModClusterListener.this.loadMetricClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down Expand Up @@ -140,8 +141,8 @@ public void setJvmRouteFactoryClass(final Class<? extends JvmRouteFactory> facto
@Override
public JvmRouteFactory run() {
try {
return factoryClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return factoryClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
Expand Down Expand Up @@ -77,8 +78,8 @@ public LoadBalanceFactorProvider createLoadBalanceFactorProvider() {
@Override
public LoadMetric run() {
try {
return ModClusterListener.this.loadMetricClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return ModClusterListener.this.loadMetricClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down Expand Up @@ -140,8 +141,8 @@ public void setJvmRouteFactoryClass(final Class<? extends JvmRouteFactory> facto
@Override
public JvmRouteFactory run() {
try {
return factoryClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return factoryClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
Expand Down Expand Up @@ -77,8 +78,8 @@ public LoadBalanceFactorProvider createLoadBalanceFactorProvider() {
@Override
public LoadMetric run() {
try {
return ModClusterListener.this.loadMetricClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return ModClusterListener.this.loadMetricClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down Expand Up @@ -140,8 +141,8 @@ public void setJvmRouteFactoryClass(final Class<? extends JvmRouteFactory> facto
@Override
public JvmRouteFactory run() {
try {
return factoryClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return factoryClass.getConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}
Expand Down

0 comments on commit 04f57d7

Please sign in to comment.