8274079: Cleanup unnecessary calls to Throwable.initCause() in java.base module

Reviewed-by: weijun
This commit is contained in:
Andrey Turbanov 2021-10-05 13:36:37 +00:00 committed by Weijun Wang
parent 8609ea55ac
commit 1459180f35
22 changed files with 55 additions and 132 deletions

View file

@ -372,12 +372,9 @@ public class SSLContext {
try {
return contextSpi.engineCreateSSLEngine();
} catch (AbstractMethodError e) {
UnsupportedOperationException unsup =
new UnsupportedOperationException(
"Provider: " + getProvider() +
" doesn't support this operation");
unsup.initCause(e);
throw unsup;
throw new UnsupportedOperationException(
"Provider: " + getProvider() +
" doesn't support this operation", e);
}
}
@ -412,12 +409,9 @@ public class SSLContext {
try {
return contextSpi.engineCreateSSLEngine(peerHost, peerPort);
} catch (AbstractMethodError e) {
UnsupportedOperationException unsup =
new UnsupportedOperationException(
"Provider: " + getProvider() +
" does not support this operation");
unsup.initCause(e);
throw unsup;
throw new UnsupportedOperationException(
"Provider: " + getProvider() +
" does not support this operation", e);
}
}

View file

@ -270,17 +270,15 @@ public abstract class Configuration {
} catch (PrivilegedActionException e) {
Exception ee = e.getException();
if (ee instanceof InstantiationException) {
throw (SecurityException) new
SecurityException
throw new SecurityException
("Configuration error:" +
ee.getCause().getMessage() +
"\n").initCause(ee.getCause());
"\n", ee.getCause());
} else {
throw (SecurityException) new
SecurityException
throw new SecurityException
("Configuration error: " +
ee.toString() +
"\n").initCause(ee);
"\n", ee);
}
}
}

View file

@ -181,10 +181,8 @@ public final class X500Principal implements Principal, java.io.Serializable {
try {
thisX500Name = new X500Name(name, keywordMap);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("improperly specified input name: " + name);
iae.initCause(e);
throw iae;
throw new IllegalArgumentException
("improperly specified input name: " + name, e);
}
}
@ -226,10 +224,8 @@ public final class X500Principal implements Principal, java.io.Serializable {
try {
thisX500Name = new X500Name(name);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("improperly specified input name");
iae.initCause(e);
throw iae;
throw new IllegalArgumentException
("improperly specified input name", e);
}
}
@ -266,17 +262,13 @@ public final class X500Principal implements Principal, java.io.Serializable {
try {
is.reset();
} catch (IOException ioe) {
IllegalArgumentException iae = new IllegalArgumentException
throw new IllegalArgumentException
("improperly specified input stream " +
("and unable to reset input stream"));
iae.initCause(e);
throw iae;
("and unable to reset input stream"), e);
}
}
IllegalArgumentException iae = new IllegalArgumentException
("improperly specified input stream");
iae.initCause(e);
throw iae;
throw new IllegalArgumentException
("improperly specified input stream", e);
}
}