Skip to content
Permalink
Browse files
8274946: Cleanup unnecessary calls to Throwable.initCause() in java.rmi
Reviewed-by: iris, rriggs
  • Loading branch information
turbanoff authored and Roger Riggs committed Nov 19, 2021
1 parent 36b59f3 commit f609b8fd74c55f3149d8e5a6a9a9bc3598c0b961
@@ -694,10 +694,8 @@ private static RMIClassLoaderSpi initializeProvider() {
} catch (InstantiationException e) {
throw new InstantiationError(e.getMessage());
} catch (ClassCastException e) {
Error error = new LinkageError(
"provider class not assignable to RMIClassLoaderSpi");
error.initCause(e);
throw error;
throw new LinkageError(
"provider class not assignable to RMIClassLoaderSpi", e);
}
}

@@ -711,10 +709,8 @@ private static RMIClassLoaderSpi initializeProvider() {
try {
return iter.next();
} catch (ClassCastException e) {
Error error = new LinkageError(
"provider class not assignable to RMIClassLoaderSpi");
error.initCause(e);
throw error;
throw new LinkageError(
"provider class not assignable to RMIClassLoaderSpi", e);
}
}

@@ -221,8 +221,7 @@ private Object invokeRemoteMethod(Object proxy,
method = cl.getMethod(method.getName(),
method.getParameterTypes());
} catch (NoSuchMethodException nsme) {
throw (IllegalArgumentException)
new IllegalArgumentException().initCause(nsme);
throw new IllegalArgumentException(nsme);
}
Class<?> thrownType = e.getClass();
for (Class<?> declaredType : method.getExceptionTypes()) {
@@ -133,8 +133,7 @@ public Socket createSocket(String host, int port) throws IOException {
try {
sslSocket.setEnabledCipherSuites(enabledCipherSuitesList);
} catch (IllegalArgumentException e) {
throw (IOException)
new IOException(e.getMessage()).initCause(e);
throw new IOException(e.getMessage(), e);
}
}
// Set the SSLSocket Enabled Protocols
@@ -151,8 +150,7 @@ public Socket createSocket(String host, int port) throws IOException {
try {
sslSocket.setEnabledProtocols(enabledProtocolsList);
} catch (IllegalArgumentException e) {
throw (IOException)
new IOException(e.getMessage()).initCause(e);
throw new IOException(e.getMessage(), e);
}
}
// Return the preconfigured SSLSocket
@@ -185,8 +185,7 @@ public SslRMIServerSocketFactory(
} catch (Exception e) {
final String msg = "Unable to check if the cipher suites " +
"and protocols to enable are supported";
throw (IllegalArgumentException)
new IllegalArgumentException(msg).initCause(e);
throw new IllegalArgumentException(msg, e);
}
}

@@ -285,8 +285,7 @@ public synchronized void update(Object value, boolean forceToDisk)
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw (IOException)
new IOException("write update failed").initCause(e);
throw new IOException("write update failed", e);
}
log.sync();

@@ -547,8 +546,7 @@ private void openLogFile(boolean truncate) throws IOException {
new LogFile(logName, "rw") :
logClassConstructor.newInstance(logName, "rw"));
} catch (Exception e) {
throw (IOException) new IOException(
"unable to construct LogFile instance").initCause(e);
throw new IOException("unable to construct LogFile instance", e);
}

if (truncate) {

1 comment on commit f609b8f

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on f609b8f Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.