diff options
author | Andreas Sewe | 2016-09-08 11:46:32 +0000 |
---|---|---|
committer | Andreas Sewe | 2016-09-08 12:35:39 +0000 |
commit | 1f2340995fb730cf776b47ee4b84a45469c5e392 (patch) | |
tree | 1c2f11929a88dd3cc316f720791244c96097b7e3 | |
parent | fef33690b9c5b85c608f5466aeede64a8c18b9b7 (diff) | |
download | rt.equinox.framework-1f2340995fb730cf776b47ee4b84a45469c5e392.tar.gz rt.equinox.framework-1f2340995fb730cf776b47ee4b84a45469c5e392.tar.xz rt.equinox.framework-1f2340995fb730cf776b47ee4b84a45469c5e392.zip |
Bug 501063 - Use constructor in favor of Throwable.initCause(...)Y20160908-1000I20160913-0800I20160912-2000I20160912-1005I20160912-0800I20160912-0430I20160912-0225I20160912-0140I20160911-2015
Change-Id: I8e8dde9b777054ea62c5e6d0ce38191d50bf8c92
Signed-off-by: Andreas Sewe <andreas.sewe@codetrails.com>
11 files changed, 22 insertions, 24 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java index ea10b4af3..3561689e6 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java @@ -99,7 +99,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { bundle.setArbitraryDirectives(StateBuilder.getDirectives(bsnElement, StateBuilder.DEFINED_BSN_DIRECTIVES)); } } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Illegal symbolic name: " + symbolicName).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Illegal symbolic name: " + symbolicName, e); //$NON-NLS-1$ } bundle.setVersion(version); @@ -514,7 +514,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { result.add(StateBuilder.createRequiredBundle(element)); return result; } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } @@ -528,7 +528,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { result.add(StateBuilder.createHostSpecification(element, null)); return result; } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } @@ -542,7 +542,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { StateBuilder.addImportPackages(element, result, 2, false); return result; } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } @@ -553,7 +553,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { return Collections.<GenericDescription> emptyList(); return StateBuilder.createOSGiCapabilities(elements, new ArrayList<GenericDescription>(elements.length), (Integer) null); } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } @@ -564,7 +564,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { return Collections.<GenericSpecification> emptyList(); return StateBuilder.createOSGiRequires(elements, new ArrayList<GenericSpecification>(elements.length)); } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } @@ -578,7 +578,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { StateBuilder.addExportPackages(element, result, false); return result; } catch (BundleException e) { - throw (IllegalArgumentException) new IllegalArgumentException("Declaration is invalid: " + declaration).initCause(e); //$NON-NLS-1$ + throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java index 7ea943a64..46083640d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java @@ -36,10 +36,10 @@ public class DefaultStartupMonitor implements StartupMonitor { try { updateMethod = splashHandler.getClass().getMethod("updateSplash", (Class[]) null); //$NON-NLS-1$ } catch (SecurityException e) { - throw (IllegalStateException) new IllegalStateException(e.getMessage()).initCause(e); + throw new IllegalStateException(e.getMessage(), e); } catch (NoSuchMethodException e) { //TODO maybe we could do something else in the update method in this case, like print something to the console? - throw (IllegalStateException) new IllegalStateException(e.getMessage()).initCause(e); + throw new IllegalStateException(e.getMessage(), e); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java index 081d81b50..bb12a4c4a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java @@ -318,9 +318,7 @@ public class SecureAction { zipNameException.initCause(e); throw zipNameException; } catch (IOException e) { - IOException fileNameException = new IOException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$ - fileNameException.initCause(e); - throw fileNameException; + throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java index 15cbe5641..35846321c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java @@ -1460,7 +1460,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { try { filter = parse_filter(); } catch (ArrayIndexOutOfBoundsException e) { - throw new InvalidSyntaxException(Msg.FILTER_TERMINATED_ABRUBTLY, filterstring); + throw new InvalidSyntaxException(Msg.FILTER_TERMINATED_ABRUBTLY, filterstring, e); } if (pos != filterChars.length) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java index 1be00ba06..e00277735 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java @@ -65,7 +65,7 @@ public final class PermissionInfoCollection extends PermissionCollection { try { addPermissions(collection, permClass); } catch (Exception e) { - throw (SecurityException) new SecurityException("Exception creating permissions: " + permClass + ": " + e.getMessage()).initCause(e); //$NON-NLS-1$ //$NON-NLS-2$ + throw new SecurityException("Exception creating permissions: " + permClass + ": " + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ } synchronized (cachedPermissionCollections) { // check to see if another thread beat this thread at adding the collection diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java index ef63417b3..26436f8d8 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java @@ -148,7 +148,7 @@ public class KeyStoreTrustEngine extends TrustEngine { } } } catch (KeyStoreException e) { - throw (IOException) new IOException(e.getMessage()).initCause(e); + throw new IOException(e.getMessage(), e); } catch (GeneralSecurityException e) { if (signedBundleHook != null) { signedBundleHook.log(e.getMessage(), FrameworkLogEntry.WARNING, e); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java index eed079e5e..177aad357 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java @@ -223,7 +223,7 @@ public class PKCS7Processor implements SignedContentConstants { dateFormt.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ signingTime = dateFormt.parse(dateString); } catch (ParseException e) { - throw (SignatureException) new SignatureException(SignedContentMessages.PKCS7_Parse_Signing_Time).initCause(e); + throw new SignatureException(SignedContentMessages.PKCS7_Parse_Signing_Time, e); } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java index c29391094..0d4de3be6 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java @@ -217,13 +217,13 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper try { result.initializeSignedContent(); } catch (InvalidKeyException e) { - throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); + throw new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (SignatureException e) { - throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); + throw new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (CertificateException e) { - throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); + throw new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchAlgorithmException e) { - throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); + throw new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java index 15243f33a..4d369ad36 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java @@ -104,7 +104,7 @@ public class SignedStorageHook extends StorageHookFactory<List<SignerInfo>, List try { certs[i] = PKCS7Processor.certFact.generateCertificate(new ByteArrayInputStream(certBytes)); } catch (CertificateException e) { - throw (IOException) new IOException(e.getMessage()).initCause(e); + throw new IOException(e.getMessage(), e); } } int anchorIdx = is.readInt(); @@ -168,7 +168,7 @@ public class SignedStorageHook extends StorageHookFactory<List<SignerInfo>, List try { certBytes = certs[i].getEncoded(); } catch (CertificateEncodingException e) { - throw (IOException) new IOException(e.getMessage()).initCause(e); + throw new IOException(e.getMessage(), e); } os.writeInt(certBytes.length); os.write(certBytes); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java index d6351e1a3..c4295534c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java @@ -231,7 +231,7 @@ public class URLStreamHandlerProxy extends URLStreamHandler implements ServiceTr throw (RuntimeException) e.getTargetException(); } catch (Exception e) { // expected on JRE < 1.5 - throw (UnsupportedOperationException) new UnsupportedOperationException().initCause(e); + throw new UnsupportedOperationException(e); } } } diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java index 9caef08f5..3a454094a 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java @@ -189,7 +189,7 @@ public abstract class NLS { try { number = Integer.parseInt(message.substring(i, index)); } catch (NumberFormatException e) { - throw (IllegalArgumentException) new IllegalArgumentException().initCause(e); + throw new IllegalArgumentException(e); } if (number == 0 && argZero != null) buffer.append(argZero); |