diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java index 418ce193ff8..d922a8ef112 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java @@ -107,16 +107,13 @@ public abstract class AbstractJmxCacheStatisticsProvider Object attribute = getMBeanServer().getAttribute(objectName, attributeName); return type.cast(attribute); } - catch (MBeanException ex) { + catch (MBeanException | ReflectionException ex) { throw new IllegalStateException(ex); } catch (AttributeNotFoundException ex) { throw new IllegalStateException("Unexpected: MBean with name '" + objectName + "' " + "does not expose attribute with name " + attributeName, ex); } - catch (ReflectionException ex) { - throw new IllegalStateException(ex); - } catch (InstanceNotFoundException ex) { logger.warn("Cache statistics are no longer available", ex); return null; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index b03dd47d062..6e307d66827 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -255,10 +255,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ClassUtils.forName(type, classLoader), considerHierarchy); return result; } - catch (ClassNotFoundException ex) { - return Collections.emptySet(); - } - catch (NoClassDefFoundError ex) { + catch (ClassNotFoundException | NoClassDefFoundError ex) { return Collections.emptySet(); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java index 69815b553ea..44cef8b7136 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java @@ -240,10 +240,7 @@ public class HttpMessageConverters implements Iterable> try { list.add(Class.forName(className)); } - catch (ClassNotFoundException ex) { - // Ignore - } - catch (NoClassDefFoundError ex) { + catch (ClassNotFoundException | NoClassDefFoundError ex) { // Ignore } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java index 264aa0d326a..3e133911dc4 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.UnsatisfiedDependencyException; import org.springframework.boot.autoconfigure.AutoConfigurationPackages; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.city.City; @@ -135,9 +134,6 @@ public class MongoDataAutoConfigurationTests { fail("Create FieldNamingStrategy interface should fail"); } // We seem to have an inconsistent exception, accept either - catch (UnsatisfiedDependencyException ex) { - // Expected - } catch (BeanCreationException ex) { // Expected } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index 976473a4507..248c1b6fa9a 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -131,10 +131,7 @@ public class AetherGrapeEngine implements GrapeEngine { classLoader.addURL(file.toURI().toURL()); } } - catch (ArtifactResolutionException ex) { - throw new DependencyResolutionFailedException(ex); - } - catch (MalformedURLException ex) { + catch (ArtifactResolutionException | MalformedURLException ex) { throw new DependencyResolutionFailedException(ex); } return null; diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java index 6c1bf790967..5bf05c841c7 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java @@ -80,10 +80,7 @@ public class ClassPathChangeUploader try { this.uri = new URL(url).toURI(); } - catch (URISyntaxException ex) { - throw new IllegalArgumentException("Malformed URL '" + url + "'"); - } - catch (MalformedURLException ex) { + catch (URISyntaxException | MalformedURLException ex) { throw new IllegalArgumentException("Malformed URL '" + url + "'"); } this.requestFactory = requestFactory; diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java index 086530f232d..ad9bb502ec0 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java @@ -84,10 +84,7 @@ public class HttpTunnelConnection implements TunnelConnection { try { this.uri = new URL(url).toURI(); } - catch (URISyntaxException ex) { - throw new IllegalArgumentException("Malformed URL '" + url + "'"); - } - catch (MalformedURLException ex) { + catch (URISyntaxException | MalformedURLException ex) { throw new IllegalArgumentException("Malformed URL '" + url + "'"); } this.requestFactory = requestFactory; diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index c5d00d30d38..f098542ac2f 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -371,9 +371,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { addDependencies(urls); return urls.toArray(new URL[urls.size()]); } - catch (MalformedURLException ex) { - throw new MojoExecutionException("Unable to build classpath", ex); - } catch (IOException ex) { throw new MojoExecutionException("Unable to build classpath", ex); } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java index 066423e676e..e7d892d3cd4 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,10 +73,7 @@ class SpringApplicationAdminClient { throw new MojoExecutionException("Failed to retrieve Ready attribute", ex.getCause()); } - catch (MBeanException ex) { - throw new MojoExecutionException(ex.getMessage(), ex); - } - catch (IOException ex) { + catch (MBeanException | IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java index 7661cbaf2f4..549ca05c3b5 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java @@ -94,11 +94,7 @@ public class StartMojo extends AbstractRunMojo { try { waitForSpringApplication(); } - catch (MojoExecutionException ex) { - runProcess.kill(); - throw ex; - } - catch (MojoFailureException ex) { + catch (MojoExecutionException | MojoFailureException ex) { runProcess.kill(); throw ex; } diff --git a/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java b/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java index edf7db91598..6453c60b9ad 100644 --- a/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java @@ -191,10 +191,7 @@ class BeanDefinitionLoader { try { return load(ClassUtils.forName(resolvedSource, null)); } - catch (IllegalArgumentException ex) { - // swallow exception and continue - } - catch (ClassNotFoundException ex) { + catch (IllegalArgumentException | ClassNotFoundException ex) { // swallow exception and continue } // Attempt as resources diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java index 22dd96db3fe..c3b9cbdde5c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java @@ -91,10 +91,7 @@ public class AtomikosDependsOnBeanFactoryPostProcessor try { return beanFactory.getBeanNamesForType(Class.forName(type), true, false); } - catch (ClassNotFoundException ex) { - // Ignore - } - catch (NoClassDefFoundError ex) { + catch (ClassNotFoundException | NoClassDefFoundError ex) { // Ignore } return NO_BEANS; diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixDependentBeanFactoryPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixDependentBeanFactoryPostProcessor.java index d2b097e3246..100aa5a33ff 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixDependentBeanFactoryPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixDependentBeanFactoryPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,10 +67,7 @@ public class BitronixDependentBeanFactoryPostProcessor try { return beanFactory.getBeanNamesForType(Class.forName(type), true, false); } - catch (ClassNotFoundException ex) { - // Ignore - } - catch (NoClassDefFoundError ex) { + catch (ClassNotFoundException | NoClassDefFoundError ex) { // Ignore } return NO_BEANS; diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaBeanFactoryPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaBeanFactoryPostProcessor.java index 7ca2ca5b538..7ea2b997bbf 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaBeanFactoryPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaBeanFactoryPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,10 +70,7 @@ public class NarayanaBeanFactoryPostProcessor try { return beanFactory.getBeanNamesForType(Class.forName(type), true, false); } - catch (ClassNotFoundException ex) { - // Ignore - } - catch (NoClassDefFoundError ex) { + catch (ClassNotFoundException | NoClassDefFoundError ex) { // Ignore } return NO_BEANS; diff --git a/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java b/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java index c19e6bb1554..90ac46584b9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java +++ b/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,11 +78,7 @@ public class SpringPackageScanClassResolver extends DefaultPackageScanClassResol MetadataReader reader = readerFactory.getMetadataReader(resource); return ClassUtils.forName(reader.getClassMetadata().getClassName(), loader); } - catch (ClassNotFoundException ex) { - handleFailure(resource, ex); - return null; - } - catch (LinkageError ex) { + catch (ClassNotFoundException | LinkageError ex) { handleFailure(resource, ex); return null; } diff --git a/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java b/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java index 89415986941..93d25fb2a05 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java @@ -58,10 +58,7 @@ class TomcatErrorPage { .instantiateClass(ClassUtils.forName(ERROR_PAGE_CLASS, null)); } } - catch (ClassNotFoundException ex) { - // Swallow and continue - } - catch (LinkageError ex) { + catch (ClassNotFoundException | LinkageError ex) { // Swallow and continue } return null; diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java index aaab1164893..d24099ebc9e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java @@ -273,13 +273,7 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon + elapsedTime + " ms"); } } - catch (RuntimeException ex) { - logger.error("Context initialization failed", ex); - servletContext.setAttribute( - WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); - throw ex; - } - catch (Error ex) { + catch (RuntimeException | Error ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);