Browse Source

Properties loading with ignoreResourceNotFound covers SocketException as well

Closes gh-25717

(cherry picked from commit 613b05d814)
pull/23967/head
Juergen Hoeller 5 years ago
parent
commit
337d5874b1
  1. 3
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
  2. 5
      spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

3
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

@ -19,6 +19,7 @@ package org.springframework.context.annotation; @@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayDeque;
import java.util.ArrayList;
@ -451,7 +452,7 @@ class ConfigurationClassParser { @@ -451,7 +452,7 @@ class ConfigurationClassParser {
Resource resource = this.resourceLoader.getResource(resolvedLocation);
addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
}
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException ex) {
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException | SocketException ex) {
// Placeholders not resolvable or resource not found when trying to open it
if (ignoreResourceNotFound) {
if (logger.isInfoEnabled()) {

5
spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -18,6 +18,7 @@ package org.springframework.core.io.support; @@ -18,6 +18,7 @@ package org.springframework.core.io.support;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Properties;
@ -181,7 +182,7 @@ public abstract class PropertiesLoaderSupport { @@ -181,7 +182,7 @@ public abstract class PropertiesLoaderSupport {
PropertiesLoaderUtils.fillProperties(
props, new EncodedResource(location, this.fileEncoding), this.propertiesPersister);
}
catch (FileNotFoundException | UnknownHostException ex) {
catch (FileNotFoundException | UnknownHostException | SocketException ex) {
if (this.ignoreResourceNotFound) {
if (logger.isDebugEnabled()) {
logger.debug("Properties resource not found: " + ex.getMessage());

Loading…
Cancel
Save