Use try/multi-catch for some reflection-related exceptions
There are more places in the code that could benefit from this but these are particularly egregious and easy to spot. Change-Id: Iccef1e03e6c36bb83bf6dc1397f54817dd05af33
This commit is contained in:
parent
a76877cfb0
commit
2cc91e481d
@ -156,10 +156,7 @@ public final class GerritLauncher {
|
||||
final Method main;
|
||||
try {
|
||||
main = clazz.getMethod("main", argv.getClass());
|
||||
} catch (SecurityException e) {
|
||||
System.err.println("fatal: unknown command " + name);
|
||||
return 1;
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (SecurityException | NoSuchMethodException e) {
|
||||
System.err.println("fatal: unknown command " + name);
|
||||
return 1;
|
||||
}
|
||||
|
@ -85,21 +85,10 @@ public class ContactStoreProvider implements Provider<ContactStore> {
|
||||
Class.forName(PGPPublicKey.class.getName());
|
||||
addBouncyCastleProvider();
|
||||
return true;
|
||||
} catch (NoClassDefFoundError noBouncyCastle) {
|
||||
return false;
|
||||
} catch (ClassNotFoundException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (SecurityException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (NoSuchMethodException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (InstantiationException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (IllegalAccessException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (InvocationTargetException noBouncyCastle) {
|
||||
return false;
|
||||
} catch (ClassCastException noBouncyCastle) {
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException | SecurityException
|
||||
| NoSuchMethodException | InstantiationException
|
||||
| IllegalAccessException | InvocationTargetException
|
||||
| ClassCastException noBouncyCastle) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -191,26 +191,12 @@ public class InMemoryModule extends FactoryModule {
|
||||
Constructor<?> c =
|
||||
clazz.getConstructor(Integer.class, int.class, String.class);
|
||||
return (Module) c.newInstance(version, 0, null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (SecurityException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw newProvisionException(e);
|
||||
} catch (ClassNotFoundException | SecurityException | NoSuchMethodException
|
||||
| IllegalArgumentException | InstantiationException
|
||||
| IllegalAccessException | InvocationTargetException e) {
|
||||
ProvisionException pe = new ProvisionException(e.getMessage());
|
||||
pe.initCause(e);
|
||||
throw pe;
|
||||
}
|
||||
}
|
||||
|
||||
private static ProvisionException newProvisionException(Throwable cause) {
|
||||
ProvisionException pe = new ProvisionException(cause.getMessage());
|
||||
pe.initCause(cause);
|
||||
return pe;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user