提交 345b9649 编写于 作者: J Josh Soref

Java 7: identical multi-catch sections

上级 385cfb08
......@@ -95,9 +95,7 @@ public class ExtensionComponent<T> implements Comparable<ExtensionComponent<T>>
if (this.instance instanceof Descriptor && that.instance instanceof Descriptor) {
try {
return Util.fixNull(((Descriptor)this.instance).getDisplayName()).compareTo(Util.fixNull(((Descriptor)that.instance).getDisplayName()));
} catch (RuntimeException x) {
LOG.log(Level.WARNING, null, x);
} catch (LinkageError x) {
} catch (RuntimeException | LinkageError x) {
LOG.log(Level.WARNING, null, x);
}
}
......
......@@ -56,11 +56,8 @@ public class UnixLifecycle extends Lifecycle {
// if we are running as daemon, don't fork into background one more time during restart
args.remove("--daemon");
} catch (UnsupportedOperationException e) {
// can't restart
failedToObtainArgs = e;
} catch (LinkageError e) {
// see HUDSON-3875
} catch (UnsupportedOperationException | LinkageError e) {
// can't restart / see HUDSON-3875
failedToObtainArgs = e;
}
}
......
......@@ -215,9 +215,7 @@ public class WindowsInstallerLink extends ManagementLink {
int r = runElevated(
new File(installationDir, "jenkins.exe"), "start", task, installationDir);
task.getLogger().println(r==0?"Successfully started":"start service failed. Exit code="+r);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
......
......@@ -694,10 +694,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
setResult(Result.FAILURE);
}
}
} catch (Exception e) {
reportError(bs, e, listener, phase);
r = false;
} catch (LinkageError e) {
} catch (Exception | LinkageError e) {
reportError(bs, e, listener, phase);
r = false;
}
......@@ -742,10 +739,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
canContinue = mon.perform(bs, AbstractBuild.this, launcher, listener);
} catch (RequestAbortedException ex) {
// Channel is closed, do not continue
reportBrokenChannel(listener);
} catch (ChannelClosedException ex) {
} catch (RequestAbortedException | ChannelClosedException ex) {
// Channel is closed, do not continue
reportBrokenChannel(listener);
} catch (RuntimeException ex) {
......@@ -859,9 +853,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
return scm.parse(this,changelogFile);
} catch (IOException e) {
LOGGER.log(WARNING, "Failed to parse "+changelogFile,e);
} catch (SAXException e) {
} catch (IOException | SAXException e) {
LOGGER.log(WARNING, "Failed to parse "+changelogFile,e);
}
return ChangeLogSet.createEmpty(this);
......
......@@ -290,16 +290,10 @@ public abstract class ItemGroupMixIn {
Jenkins.getInstance().rebuildDependencyGraphAsync();
return result;
} catch (TransformerException e) {
} catch (TransformerException | SAXException e) {
success = false;
throw new IOException("Failed to persist config.xml", e);
} catch (SAXException e) {
success = false;
throw new IOException("Failed to persist config.xml", e);
} catch (IOException e) {
success = false;
throw e;
} catch (RuntimeException e) {
} catch (IOException | RuntimeException e) {
success = false;
throw e;
} finally {
......
......@@ -163,9 +163,7 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
TaskListener listener = new StreamTaskListener(new NullStream());
Launcher launcher = n.createLauncher(listener);
return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0;
} catch (IOException e) {
return false;
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
return false;
}
}
......
......@@ -2335,9 +2335,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
LOGGER.log(WARNING, "deprecated call to Run.getEnvVars\n\tat {0}", new Throwable().getStackTrace()[1]);
try {
return getEnvironment(new LogTaskListener(LOGGER, Level.INFO));
} catch (IOException e) {
return new EnvVars();
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
return new EnvVars();
}
}
......
......@@ -227,11 +227,7 @@ public final class RunMap<R extends Run<?,R>> extends AbstractLazyLoadRunMap<R>
LOGGER.log(FINEST, "Loaded " + b.getFullDisplayName() + " in " + Thread.currentThread().getName(), new ThisIsHowItsLoaded());
}
return b;
} catch (IOException e) {
LOGGER.log(Level.WARNING, "could not load " + d, e);
} catch (InstantiationError e) {
LOGGER.log(Level.WARNING, "could not load " + d, e);
} catch (Exception e) {
} catch (Exception | InstantiationError e) {
LOGGER.log(Level.WARNING, "could not load " + d, e);
}
}
......
......@@ -335,11 +335,7 @@ public class UpdateSite {
if(df.exists()) {
try {
return JSONObject.fromObject(df.read());
} catch (JSONException e) {
LOGGER.log(Level.SEVERE,"Failed to parse "+df,e);
df.delete(); // if we keep this file, it will cause repeated failures
return null;
} catch (IOException e) {
} catch (JSONException | IOException e) {
LOGGER.log(Level.SEVERE,"Failed to parse "+df,e);
df.delete(); // if we keep this file, it will cause repeated failures
return null;
......
......@@ -82,10 +82,7 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork {
boolean check;
try {
check = shouldBeDeleted(item, ws, node);
} catch (IOException x) {
Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName()));
continue;
} catch (InterruptedException x) {
} catch (IOException | InterruptedException x) {
Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName()));
continue;
}
......@@ -94,9 +91,7 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork {
try {
ws.deleteRecursive();
WorkspaceList.tempDir(ws).deleteRecursive();
} catch (IOException x) {
Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
} catch (InterruptedException x) {
} catch (IOException | InterruptedException x) {
Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
}
}
......
......@@ -75,10 +75,7 @@ class Latch {
try {
onCriteriaMet();
} catch (Error e) {
abort(e);
throw e;
} catch (RuntimeException e) {
} catch (Error | RuntimeException e) {
abort(e);
throw e;
}
......
......@@ -92,9 +92,7 @@ public abstract class AbstractAsyncNodeMonitorDescriptor<T> extends AbstractNode
if (cc!=null)
futures.put(c,ch.callAsync(cc));
}
} catch (RuntimeException e) {
LOGGER.log(WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e);
} catch (IOException e) {
} catch (RuntimeException | IOException e) {
LOGGER.log(WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e);
}
}
......@@ -112,11 +110,7 @@ public abstract class AbstractAsyncNodeMonitorDescriptor<T> extends AbstractNode
if (f!=null) {
try {
data.put(c,f.get(Math.max(0,end-System.currentTimeMillis()), MILLISECONDS));
} catch (RuntimeException x) {
LOGGER.log(WARNING, "Failed to monitor " + c.getDisplayName() + " for " + getDisplayName(), x);
} catch (ExecutionException x) {
LOGGER.log(WARNING, "Failed to monitor " + c.getDisplayName() + " for " + getDisplayName(), x);
} catch (TimeoutException x) {
} catch (RuntimeException | TimeoutException | ExecutionException x) {
LOGGER.log(WARNING, "Failed to monitor " + c.getDisplayName() + " for " + getDisplayName(), x);
}
} else {
......
......@@ -149,9 +149,7 @@ public abstract class AbstractNodeMonitorDescriptor<T> extends Descriptor<NodeMo
data.put(c,null);
else
data.put(c,monitor(c));
} catch (RuntimeException e) {
LOGGER.log(Level.WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e);
} catch (IOException e) {
} catch (RuntimeException | IOException e) {
LOGGER.log(Level.WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e);
} catch (InterruptedException e) {
throw (InterruptedException)new InterruptedException("Node monitoring "+c.getDisplayName()+" for "+getDisplayName()+" aborted.").initCause(e);
......
......@@ -86,9 +86,7 @@ public abstract class SCMDescriptor<T extends SCM> extends Descriptor<SCM> {
Field f = SCMDescriptor.class.getDeclaredField("repositoryBrowser");
f.setAccessible(true);
f.set(this,rb);
} catch (NoSuchFieldException e) {
LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field",e);
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
LOGGER.log(WARNING, "Failed to overwrite the repositoryBrowser field",e);
}
}
......
......@@ -311,9 +311,7 @@ public class TokenBasedRememberMeServices2 extends TokenBasedRememberMeServices
if (SET_HTTP_ONLY!=null) {
try {
SET_HTTP_ONLY.invoke(cookie,true);
} catch (IllegalAccessException e) {
// ignore
} catch (InvocationTargetException e) {
} catch (IllegalAccessException | InvocationTargetException e) {
// ignore
}
}
......
......@@ -165,9 +165,7 @@ public class Shell extends CommandInterpreter {
String interpreter = null;
try {
interpreter = channel.call(new Shellinterpreter());
} catch (IOException e) {
LOGGER.log(Level.WARNING, null, e);
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
LOGGER.log(Level.WARNING, null, e);
}
if (interpreter == null) {
......
......@@ -95,9 +95,7 @@ public final class ClockDifference {
try {
if(d==null) return FAILED_HTML;
return d.getClockDifference().toHtml();
} catch (IOException e) {
return FAILED_HTML;
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
return FAILED_HTML;
}
}
......
......@@ -198,9 +198,7 @@ public class CopyOnWriteList<E> implements Iterable<E> {
items.add(item);
} catch (CriticalXStreamException e) {
throw e;
} catch (XStreamException e) {
RobustReflectionConverter.addErrorInContext(context, e);
} catch (LinkageError e) {
} catch (XStreamException | LinkageError e) {
RobustReflectionConverter.addErrorInContext(context, e);
}
reader.moveUp();
......
......@@ -86,9 +86,7 @@ public class RobustCollectionConverter extends CollectionConverter {
collection.add(item);
} catch (CriticalXStreamException e) {
throw e;
} catch (XStreamException e) {
RobustReflectionConverter.addErrorInContext(context, e);
} catch (LinkageError e) {
} catch (XStreamException | LinkageError e) {
RobustReflectionConverter.addErrorInContext(context, e);
}
reader.moveUp();
......
......@@ -58,10 +58,7 @@ final class RobustMapConverter extends MapConverter {
return readItem(reader, context, map);
} catch (CriticalXStreamException x) {
throw x;
} catch (XStreamException x) {
RobustReflectionConverter.addErrorInContext(context, x);
return ERROR;
} catch (LinkageError x) {
} catch (XStreamException | LinkageError x) {
RobustReflectionConverter.addErrorInContext(context, x);
return ERROR;
} finally {
......
......@@ -210,11 +210,9 @@ public final class Secret implements Serializable {
} else {
try {
return HistoricalSecrets.decrypt(data, KEY);
} catch (GeneralSecurityException e) {
return null;
} catch (UnsupportedEncodingException e) {
throw new Error(e); // impossible
} catch (IOException e) {
} catch (GeneralSecurityException | IOException e) {
return null;
}
}
......
......@@ -62,11 +62,7 @@ public class Service {
if (!type.isAssignableFrom(t)) continue; // invalid type
result.add(type.cast(t.newInstance()));
} catch (ClassNotFoundException x) {
LOGGER.log(WARNING, "Failed to load " + line, x);
} catch (InstantiationException x) {
LOGGER.log(WARNING, "Failed to load " + line, x);
} catch (IllegalAccessException x) {
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException x) {
LOGGER.log(WARNING, "Failed to load " + line, x);
}
}
......
......@@ -445,11 +445,7 @@ public class XStream2 extends XStream {
IllegalAccessError x = new IllegalAccessError();
x.initCause(e);
throw x;
} catch (InstantiationException e) {
InstantiationError x = new InstantiationError();
x.initCause(e);
throw x;
} catch (InvocationTargetException e) {
} catch (InstantiationException | InvocationTargetException e) {
InstantiationError x = new InstantiationError();
x.initCause(e);
throw x;
......
......@@ -80,12 +80,10 @@ public class ImmutableListConverter extends CollectionConverter {
items.add(item);
} catch (CriticalXStreamException e) {
throw e;
} catch (XStreamException e) {
RobustReflectionConverter.addErrorInContext(context, e);
} catch (LinkageError e) {
} catch (XStreamException | LinkageError e) {
RobustReflectionConverter.addErrorInContext(context, e);
}
reader.moveUp();
reader.moveUp();
}
// move back up past the elements element.
......
......@@ -106,9 +106,7 @@ public class RenderOnDemandClosure {
}
try {
AdjunctsInPage.get().assumeIncluded(adjuncts);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to resurrect adjunct context",e);
} catch (SAXException e) {
} catch (IOException | SAXException e) {
LOGGER.log(Level.WARNING, "Failed to resurrect adjunct context",e);
}
return context;
......
......@@ -91,13 +91,10 @@ public class PluginSubtypeMarker extends AbstractProcessor {
}
return false;
} catch (RuntimeException e) {
} catch (RuntimeException | Error e) {
// javac sucks at reporting errors in annotation processors
e.printStackTrace();
throw e;
} catch (Error e) {
e.printStackTrace();
throw e;
}
}
......
......@@ -3403,9 +3403,6 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
LOGGER.log(lv, s);
}
});
} catch (InterruptedException | ReactorException | IOException e) {
LOGGER.log(SEVERE, "Failed to execute termination",e);
errors.add(e);
} catch (OutOfMemoryError e) {
// we should just propagate this, no point trying to log
throw e;
......
......@@ -148,10 +148,7 @@ public abstract class PeepholePermalink extends Permalink implements Predicate<R
Util.createSymlink(job.getBuildDir(),b.getId(),target,TaskListener.NULL);
}
writeSymlink(cache, target);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
cache.delete();
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
cache.delete();
}
......
......@@ -164,14 +164,10 @@ public abstract class LazyBuildMixIn<JobT extends Job<JobT,RunT> & Queue.Task &
public RunT loadBuild(File dir) throws IOException {
try {
return getBuildClass().getConstructor(asJob().getClass(), File.class).newInstance(asJob(), dir);
} catch (InstantiationException e) {
throw new Error(e);
} catch (IllegalAccessException e) {
} catch (InstantiationException | NoSuchMethodException | IllegalAccessException e) {
throw new Error(e);
} catch (InvocationTargetException e) {
throw handleInvocationTargetException(e);
} catch (NoSuchMethodException e) {
throw new Error(e);
}
}
......
......@@ -118,13 +118,9 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean {
LOGGER.finer("Chain processed normally");
}
catch (AuthenticationException ex) {
catch (AuthenticationException | AccessDeniedException ex) {
handleException(request, response, chain, ex);
}
catch (AccessDeniedException ex) {
handleException(request, response, chain, ex);
}
catch (ServletException ex) {
} catch (ServletException ex) {
if (ex.getRootCause() instanceof AuthenticationException
|| ex.getRootCause() instanceof AccessDeniedException) {
handleException(request, response, chain, (AcegiSecurityException) ex.getRootCause());
......
......@@ -129,9 +129,7 @@ public class HMACConfidentialKey extends ConfidentialKey {
store(encoded=key.getEncoded());
}
key = new SecretKeySpec(encoded,ALGORITHM);
} catch (IOException e) {
throw new Error("Failed to load the key: "+getId(),e);
} catch (NoSuchAlgorithmException e) {
} catch (IOException | NoSuchAlgorithmException e) {
throw new Error("Failed to load the key: "+getId(),e);
}
}
......
......@@ -28,9 +28,7 @@ public class ImpersonatingUserDetailsService implements UserDetailsService {
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
try {
return base.loadUserByUsername(username);
} catch (UserMayOrMayNotExistException e) {
return attemptToImpersonate(username, e);
} catch (DataAccessException e) {
} catch (UserMayOrMayNotExistException | DataAccessException e) {
return attemptToImpersonate(username, e);
}
}
......
......@@ -90,9 +90,7 @@ public abstract class RSAConfidentialKey extends ConfidentialKey {
}
}
return priv;
} catch (IOException e) {
throw new Error("Failed to load the key: " + getId(), e);
} catch (GeneralSecurityException e) {
} catch (IOException | GeneralSecurityException e) {
throw new Error("Failed to load the key: " + getId(), e);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册