Collapse catch clauses

Use multi-catch for exceptions whenever possible.

See gh-9781
This commit is contained in:
Emanuel Campolo
2017-07-18 11:52:47 -03:00
committed by Phillip Webb
parent 4a189bdee7
commit 798fe5ed53
17 changed files with 19 additions and 76 deletions

View File

@@ -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();
}
}

View File

@@ -240,10 +240,7 @@ public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>>
try {
list.add(Class.forName(className));
}
catch (ClassNotFoundException ex) {
// Ignore
}
catch (NoClassDefFoundError ex) {
catch (ClassNotFoundException | NoClassDefFoundError ex) {
// Ignore
}
}

View File

@@ -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
}