Collapse catch clauses
Use multi-catch for exceptions whenever possible. See gh-9781
This commit is contained in:
committed by
Phillip Webb
parent
4a189bdee7
commit
798fe5ed53
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user