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
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user