UnknownHostException as resource-not-found for properties files

Plus first-class declaration of FileNotFoundException in Resource javadoc.

Issue: SPR-15433
(cherry picked from commit c4e0d6c)
This commit is contained in:
Juergen Hoeller
2017-04-11 11:45:30 +02:00
parent 865953f145
commit 54180f90e2
4 changed files with 19 additions and 11 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.context.annotation;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
@@ -444,9 +445,10 @@ class ConfigurationClassParser {
throw ex;
}
}
catch (FileNotFoundException ex) {
catch (IOException ex) {
// Resource not found when trying to open it
if (ignoreResourceNotFound) {
if (ignoreResourceNotFound &&
(ex instanceof FileNotFoundException || ex instanceof UnknownHostException)) {
if (logger.isInfoEnabled()) {
logger.info("Properties location [" + location + "] not resolvable: " + ex.getMessage());
}
@@ -491,6 +493,7 @@ class ConfigurationClassParser {
this.propertySourceNames.add(name);
}
/**
* Returns {@code @Import} class, considering all meta-annotations.
*/