From 2ea114828627ea1723f1f2224f632ec9d96cb481 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Fri, 10 Dec 2021 09:51:30 -0800 Subject: [PATCH] Fix `CatchingUnchecked` Error Prone violations (#5950) Co-authored-by: James Nord --- core/src/main/java/hudson/ExtensionFinder.java | 2 +- core/src/main/java/hudson/ExtensionList.java | 2 +- core/src/main/java/hudson/PluginManager.java | 4 ++-- core/src/main/java/hudson/Util.java | 4 ++-- core/src/main/java/hudson/WebAppMain.java | 2 +- core/src/main/java/hudson/lifecycle/ExitLifecycle.java | 2 +- .../java/hudson/lifecycle/SolarisSMFLifecycle.java | 2 +- core/src/main/java/hudson/lifecycle/UnixLifecycle.java | 2 +- .../java/hudson/lifecycle/WindowsServiceLifecycle.java | 2 +- core/src/main/java/hudson/model/AbstractProject.java | 2 +- core/src/main/java/hudson/model/Actionable.java | 2 +- core/src/main/java/hudson/model/Executor.java | 2 +- core/src/main/java/hudson/model/Project.java | 8 ++++---- core/src/main/java/hudson/model/UpdateCenter.java | 4 ++-- core/src/main/java/hudson/model/UpdateSite.java | 2 +- core/src/main/java/hudson/scm/ChangeLogSet.java | 2 +- core/src/main/java/hudson/slaves/SlaveComputer.java | 2 +- core/src/main/java/hudson/util/FormValidation.java | 2 +- core/src/main/java/jenkins/I18n.java | 2 +- .../main/java/jenkins/JenkinsHttpSessionListener.java | 4 ++-- .../java/jenkins/MetaLocaleDrivenResourceProvider.java | 2 +- core/src/main/java/jenkins/cli/StopBuildsCommand.java | 2 +- core/src/main/java/jenkins/install/InstallUtil.java | 10 ++-------- core/src/main/java/jenkins/install/SetupWizard.java | 6 +++--- core/src/main/java/jenkins/model/Jenkins.java | 2 +- core/src/main/java/jenkins/model/RunIdMigrator.java | 2 +- .../jenkins/security/ResourceDomainRootAction.java | 4 ++-- .../java/jenkins/security/s2m/FilePathRuleConfig.java | 2 +- core/src/main/java/jenkins/telemetry/Telemetry.java | 2 +- core/src/test/java/jenkins/util/TimerTest.java | 8 ++------ test/src/test/java/lib/form/ValidateButtonTest.java | 2 +- 31 files changed, 43 insertions(+), 53 deletions(-) diff --git a/core/src/main/java/hudson/ExtensionFinder.java b/core/src/main/java/hudson/ExtensionFinder.java index 0af3b4f17d..10ca19bef5 100644 --- a/core/src/main/java/hudson/ExtensionFinder.java +++ b/core/src/main/java/hudson/ExtensionFinder.java @@ -502,7 +502,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { } } LOGGER.log(Level.FINER, "{0} looks OK", c); - } catch (Exception x) { + } catch (RuntimeException x) { throw new LinkageError("Failed to resolve "+c, x); } } diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java index e5dd86b2c1..c453a46b3d 100644 --- a/core/src/main/java/hudson/ExtensionList.java +++ b/core/src/main/java/hudson/ExtensionList.java @@ -357,7 +357,7 @@ public class ExtensionList extends AbstractList implements OnMaster { for (ExtensionListListener listener : listeners) { try { listener.onChange(); - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Error firing ExtensionListListener.onChange().", e); } } diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 4d2e1e63f3..87a637b8c7 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -204,7 +204,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas // Secure initialization CHECK_UPDATE_SLEEP_TIME_MILLIS = SystemProperties.getInteger(PluginManager.class.getName() + ".checkUpdateSleepTimeMillis", 1000); CHECK_UPDATE_ATTEMPTS = SystemProperties.getInteger(PluginManager.class.getName() + ".checkUpdateAttempts", 1); - } catch(Exception e) { + } catch(RuntimeException e) { LOGGER.warning(String.format("There was an error initializing the PluginManager. Exception: %s", e)); } finally { CHECK_UPDATE_ATTEMPTS = CHECK_UPDATE_ATTEMPTS > 0 ? CHECK_UPDATE_ATTEMPTS : 1; @@ -1584,7 +1584,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas responseData.put("correlationId", correlationId.toString()); return hudson.util.HttpResponses.okJSON(responseData); - } catch (Exception e) { + } catch (RuntimeException e) { return hudson.util.HttpResponses.errorJSON(e.getMessage()); } } diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index d0f004f868..1d6dd3aac1 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -460,7 +460,7 @@ public class Util { try { ResourceBundle rb = ResourceBundle.getBundle("/hudson/win32errors"); return rb.getString("error"+m.group(1)); - } catch (Exception ignored) { + } catch (RuntimeException ignored) { // silently recover from resource related failures } } @@ -1429,7 +1429,7 @@ public class Util { return null; } catch (IOException x) { throw x; - } catch (Exception x) { + } catch (RuntimeException x) { throw new IOException(x); } } diff --git a/core/src/main/java/hudson/WebAppMain.java b/core/src/main/java/hudson/WebAppMain.java index f21167ff88..1ff977a4ce 100644 --- a/core/src/main/java/hudson/WebAppMain.java +++ b/core/src/main/java/hudson/WebAppMain.java @@ -415,7 +415,7 @@ public class WebAppMain implements ServletContextListener { if (instance != null) { instance.cleanUp(); } - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } diff --git a/core/src/main/java/hudson/lifecycle/ExitLifecycle.java b/core/src/main/java/hudson/lifecycle/ExitLifecycle.java index 47b093d43f..01855e1e22 100644 --- a/core/src/main/java/hudson/lifecycle/ExitLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/ExitLifecycle.java @@ -65,7 +65,7 @@ public class ExitLifecycle extends Lifecycle { if (jenkins != null) { jenkins.cleanUp(); } - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } diff --git a/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java b/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java index 8a10858b0e..eecc28ea26 100644 --- a/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java @@ -46,7 +46,7 @@ public class SolarisSMFLifecycle extends Lifecycle { if (jenkins != null) { jenkins.cleanUp(); } - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } System.exit(0); diff --git a/core/src/main/java/hudson/lifecycle/UnixLifecycle.java b/core/src/main/java/hudson/lifecycle/UnixLifecycle.java index 391998cdff..498db2c0e9 100644 --- a/core/src/main/java/hudson/lifecycle/UnixLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/UnixLifecycle.java @@ -68,7 +68,7 @@ public class UnixLifecycle extends Lifecycle { if (jenkins != null) { jenkins.cleanUp(); } - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } diff --git a/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java b/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java index 01d840f9dd..8612f2cf0d 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java @@ -121,7 +121,7 @@ public class WindowsServiceLifecycle extends Lifecycle { if (jenkins != null) { jenkins.cleanUp(); } - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 1e080cb8e6..48666d0bad 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -738,7 +738,7 @@ public abstract class AbstractProject

,R extends A for (TransientProjectActionFactory tpaf : TransientProjectActionFactory.all()) { try { ta.addAll(Util.fixNull(tpaf.createFor(this))); // be defensive against null - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Could not load actions from " + tpaf + " for " + this, e); } } diff --git a/core/src/main/java/hudson/model/Actionable.java b/core/src/main/java/hudson/model/Actionable.java index 90be28c893..ff1456c9c7 100644 --- a/core/src/main/java/hudson/model/Actionable.java +++ b/core/src/main/java/hudson/model/Actionable.java @@ -118,7 +118,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj } } return result; - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.WARNING, "Could not load actions from " + taf + " for " + this, e); return Collections.emptySet(); } diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index f3e971f990..cf00f7be56 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -913,7 +913,7 @@ public class Executor extends Thread implements ModelObject { lock.readLock().lock(); try { return executable != null && getParentOf(executable).getOwnerTask().hasAbortPermission(); - } catch(Exception ex) { + } catch(RuntimeException ex) { if (!(ex instanceof AccessDeniedException)) { // Prevents UI from exploding in the case of unexpected runtime exceptions LOGGER.log(WARNING, "Unhandled exception", ex); diff --git a/core/src/main/java/hudson/model/Project.java b/core/src/main/java/hudson/model/Project.java index 26232f9423..3ed33d9bcd 100644 --- a/core/src/main/java/hudson/model/Project.java +++ b/core/src/main/java/hudson/model/Project.java @@ -240,28 +240,28 @@ public abstract class Project

,B extends Build> for (BuildStep step : getBuildersList()) { try { r.addAll(step.getProjectActions(this)); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error loading build step.", e); } } for (BuildStep step : getPublishersList()) { try { r.addAll(step.getProjectActions(this)); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error loading publisher.", e); } } for (BuildWrapper step : getBuildWrappers().values()) { try { r.addAll(step.getProjectActions(this)); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error loading build wrapper.", e); } } for (Trigger trigger : triggers()) { try { r.addAll(trigger.getProjectActions()); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error loading trigger.", e); } } diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index b1794ee2e8..e4bbc33bbb 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -443,7 +443,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas jobs = Collections.emptyMap(); } return HttpResponses.okJSON(jobs); - } catch (Exception e) { + } catch (RuntimeException e) { return HttpResponses.errorJSON(String.format("ERROR: %s", e.getMessage())); } } @@ -513,7 +513,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas } } return HttpResponses.okJSON(JSONObject.fromObject(response)); - } catch (Exception e) { + } catch (RuntimeException e) { return HttpResponses.errorJSON(String.format("ERROR: %s", e.getMessage())); } } diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 2e17014f1b..290938cf1c 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -1151,7 +1151,7 @@ public class UpdateSite { if (releaseTimestamp != null) { try { date = Date.from(Instant.parse(releaseTimestamp)); - } catch (Exception ex) { + } catch (RuntimeException ex) { LOGGER.log(Level.FINE, "Failed to parse releaseTimestamp for " + title + " from " + sourceId, ex); } } diff --git a/core/src/main/java/hudson/scm/ChangeLogSet.java b/core/src/main/java/hudson/scm/ChangeLogSet.java index a20e9f493d..0b0d9c1d0e 100644 --- a/core/src/main/java/hudson/scm/ChangeLogSet.java +++ b/core/src/main/java/hudson/scm/ChangeLogSet.java @@ -249,7 +249,7 @@ public abstract class ChangeLogSet implements Iter for (ChangeLogAnnotator a : ChangeLogAnnotator.all()) try { a.annotate(parent.run, this, markup); - } catch(Exception e) { + } catch(RuntimeException e) { LOGGER.info("ChangeLogAnnotator " + a.toString() + " failed to annotate message '" + getMsg() + "'; " + e.getMessage()); } catch(Error e) { LOGGER.severe("ChangeLogAnnotator " + a + " failed to annotate message '" + getMsg() + "'; " + e.getMessage()); diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 5f48dd3862..a55400aa1a 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -306,7 +306,7 @@ public class SlaveComputer extends Computer { e.addSuppressed(threadInfo); Functions.printStackTrace(e, taskListener.error(Messages.ComputerLauncher_abortedLaunch())); throw e; - } catch (Exception e) { + } catch (RuntimeException e) { e.addSuppressed(threadInfo); Functions.printStackTrace(e, taskListener.error(Messages.ComputerLauncher_unexpectedError())); throw e; diff --git a/core/src/main/java/hudson/util/FormValidation.java b/core/src/main/java/hudson/util/FormValidation.java index e4cd886bb2..98ad8b7f37 100644 --- a/core/src/main/java/hudson/util/FormValidation.java +++ b/core/src/main/java/hudson/util/FormValidation.java @@ -359,7 +359,7 @@ public abstract class FormValidation extends IOException implements HttpResponse } }); return result[0]; - } catch (Exception e) { + } catch (RuntimeException e) { return FormValidation.error(e, "Unexpected error"); } } diff --git a/core/src/main/java/jenkins/I18n.java b/core/src/main/java/jenkins/I18n.java index 0fb435484a..89dfb6e91c 100644 --- a/core/src/main/java/jenkins/I18n.java +++ b/core/src/main/java/jenkins/I18n.java @@ -107,7 +107,7 @@ public class I18n implements RootAction { } return HttpResponses.okJSON(ResourceBundleUtil.getBundle(baseName, locale)); - } catch (Exception e) { + } catch (RuntimeException e) { return HttpResponses.errorJSON(e.getMessage()); } } diff --git a/core/src/main/java/jenkins/JenkinsHttpSessionListener.java b/core/src/main/java/jenkins/JenkinsHttpSessionListener.java index 95a61834a4..3b9e531072 100644 --- a/core/src/main/java/jenkins/JenkinsHttpSessionListener.java +++ b/core/src/main/java/jenkins/JenkinsHttpSessionListener.java @@ -49,7 +49,7 @@ public final class JenkinsHttpSessionListener implements javax.servlet.http.Http for (HttpSessionListener listener : HttpSessionListener.all()) { try { listener.sessionCreated(httpSessionEvent); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error calling HttpSessionListener ExtensionPoint sessionCreated().", e); } } @@ -60,7 +60,7 @@ public final class JenkinsHttpSessionListener implements javax.servlet.http.Http for (HttpSessionListener listener : HttpSessionListener.all()) { try { listener.sessionDestroyed(httpSessionEvent); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Error calling HttpSessionListener ExtensionPoint sessionDestroyed().", e); } } diff --git a/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java b/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java index 26dac5e172..7026fd926f 100644 --- a/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java +++ b/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java @@ -51,7 +51,7 @@ public final class MetaLocaleDrivenResourceProvider extends LocaleDrivenResource if (url != null) { return url; } - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.warn("Failed to lookup URL for '" + s + "' from '" + provider.toString(), e); } } diff --git a/core/src/main/java/jenkins/cli/StopBuildsCommand.java b/core/src/main/java/jenkins/cli/StopBuildsCommand.java index d010628df3..edb9c2916b 100644 --- a/core/src/main/java/jenkins/cli/StopBuildsCommand.java +++ b/core/src/main/java/jenkins/cli/StopBuildsCommand.java @@ -95,7 +95,7 @@ public class StopBuildsCommand extends CLICommand { executor.doStop(); isAnyBuildStopped = true; stdout.printf("Build '%s' stopped for job '%s'%n", buildName, jobName); - } catch (final Exception e) { + } catch (final RuntimeException e) { stdout.printf("Exception occurred while trying to stop build '%s' for job '%s'. ", buildName, jobName); stdout.printf("Exception class: %s, message: %s%n", e.getClass().getSimpleName(), e.getMessage()); } diff --git a/core/src/main/java/jenkins/install/InstallUtil.java b/core/src/main/java/jenkins/install/InstallUtil.java index 49cf460f3d..00c6664edf 100644 --- a/core/src/main/java/jenkins/install/InstallUtil.java +++ b/core/src/main/java/jenkins/install/InstallUtil.java @@ -162,14 +162,8 @@ public class InstallUtil { // Allow for skipping if(shouldNotRun) { - try { - InstallState.INITIAL_SETUP_COMPLETED.initializeState(); - return j.getInstallState(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException(e); - } + InstallState.INITIAL_SETUP_COMPLETED.initializeState(); + return j.getInstallState(); } return InstallState.INITIAL_SECURITY_SETUP; diff --git a/core/src/main/java/jenkins/install/SetupWizard.java b/core/src/main/java/jenkins/install/SetupWizard.java index 7ff266c525..caac5b9873 100644 --- a/core/src/main/java/jenkins/install/SetupWizard.java +++ b/core/src/main/java/jenkins/install/SetupWizard.java @@ -209,7 +209,7 @@ public class SetupWizard extends PageDecorator { try { // Make sure plugin metadata is up to date UpdateCenter.updateDefaultSite(); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } } @@ -290,7 +290,7 @@ public class SetupWizard extends PageDecorator { try { return !Jenkins.get().getInstallState().isSetupComplete() && isUsingSecurityDefaults(); - } catch (Exception e) { + } catch (RuntimeException e) { // ignore } return false; @@ -589,7 +589,7 @@ public class SetupWizard extends PageDecorator { } else { try { initialPluginList = JSONArray.fromObject(initialPluginJson); - } catch (Exception ex) { + } catch (RuntimeException ex) { /* Second attempt: It's not a remote file, but still wrapped */ initialPluginList = JSONObject.fromObject(initialPluginJson).getJSONArray("categories"); } diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index e95eab1fad..30089dbcf3 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -4592,7 +4592,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve cleanUp(); System.exit(0); - } catch (Exception e) { + } catch (Throwable e) { LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e); } } diff --git a/core/src/main/java/jenkins/model/RunIdMigrator.java b/core/src/main/java/jenkins/model/RunIdMigrator.java index fea5fbffb6..774cc17c74 100644 --- a/core/src/main/java/jenkins/model/RunIdMigrator.java +++ b/core/src/main/java/jenkins/model/RunIdMigrator.java @@ -283,7 +283,7 @@ public final class RunIdMigrator { Files.move(src.toPath(), dest.toPath()); } catch (IOException x) { throw x; - } catch (Exception x) { + } catch (RuntimeException x) { throw new IOException(x); } } diff --git a/core/src/main/java/jenkins/security/ResourceDomainRootAction.java b/core/src/main/java/jenkins/security/ResourceDomainRootAction.java index de36469041..e5e83e4271 100644 --- a/core/src/main/java/jenkins/security/ResourceDomainRootAction.java +++ b/core/src/main/java/jenkins/security/ResourceDomainRootAction.java @@ -185,7 +185,7 @@ public class ResourceDomainRootAction implements UnprotectedRootAction { try { return new Token(dbsUrl, authenticationName, Instant.now()); - } catch (Exception ex) { + } catch (RuntimeException ex) { LOGGER.log(Level.WARNING, "Failed to encode token for URL: " + dbsUrl + " user: " + authenticationName, ex); } return null; @@ -301,7 +301,7 @@ public class ResourceDomainRootAction implements UnprotectedRootAction { String authenticationName = authenticationNameAndBrowserUrl.substring(0, authenticationNameLength); String browserUrl = authenticationNameAndBrowserUrl.substring(authenticationNameLength + 1); return new Token(browserUrl, authenticationName, ofEpochMilli(Long.parseLong(epoch))); - } catch (Exception ex) { + } catch (RuntimeException ex) { // Choose log level that hides people messing with the URLs LOGGER.log(Level.FINE, "Failure decoding", ex); return null; diff --git a/core/src/main/java/jenkins/security/s2m/FilePathRuleConfig.java b/core/src/main/java/jenkins/security/s2m/FilePathRuleConfig.java index c4b111f2bd..ab0a463d2c 100644 --- a/core/src/main/java/jenkins/security/s2m/FilePathRuleConfig.java +++ b/core/src/main/java/jenkins/security/s2m/FilePathRuleConfig.java @@ -74,7 +74,7 @@ class FilePathRuleConfig extends ConfigDirectory Pattern.compile(m.group(3)), createOpMatcher(m.group(2)), m.group(1).equals("allow")); - } catch (Exception e) { + } catch (RuntimeException e) { throw new Failure("Invalid filter rule line: "+line+"\n"+ Functions.printThrowable(e)); } } diff --git a/core/src/main/java/jenkins/telemetry/Telemetry.java b/core/src/main/java/jenkins/telemetry/Telemetry.java index ab4cd23efa..989733f397 100644 --- a/core/src/main/java/jenkins/telemetry/Telemetry.java +++ b/core/src/main/java/jenkins/telemetry/Telemetry.java @@ -204,7 +204,7 @@ public abstract class Telemetry implements ExtensionPoint { JSONObject data = new JSONObject(); try { data = telemetry.createContent(); - } catch (Exception e) { + } catch (RuntimeException e) { LOGGER.log(Level.WARNING, "Failed to build telemetry content for: '" + telemetry.getId() + "'", e); } diff --git a/core/src/test/java/jenkins/util/TimerTest.java b/core/src/test/java/jenkins/util/TimerTest.java index 42a1c9c92b..a37dc7fa1c 100644 --- a/core/src/test/java/jenkins/util/TimerTest.java +++ b/core/src/test/java/jenkins/util/TimerTest.java @@ -73,12 +73,8 @@ public class TimerTest { futures[j] = exec.schedule(new Runnable() { @Override public void run() { - try { - startLatch.countDown(); - contextClassloaders[j] = Thread.currentThread().getContextClassLoader(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } + startLatch.countDown(); + contextClassloaders[j] = Thread.currentThread().getContextClassLoader(); } }, 0, TimeUnit.SECONDS); } diff --git a/test/src/test/java/lib/form/ValidateButtonTest.java b/test/src/test/java/lib/form/ValidateButtonTest.java index 916af500d9..92f77e2039 100644 --- a/test/src/test/java/lib/form/ValidateButtonTest.java +++ b/test/src/test/java/lib/form/ValidateButtonTest.java @@ -116,7 +116,7 @@ public class ValidateButtonTest { assertEquals("dvalue",d); assertEquals("e2",e); test1Outcome = null; - } catch (Exception t) { + } catch (RuntimeException t) { test1Outcome = t; } }