Skip to content

Commit 3632b8b

Browse files
committed
Properties loading with ignoreResourceNotFound covers SocketException as well
Closes spring-projectsgh-25717 (cherry picked from commit 613b05d)
1 parent 8d743d9 commit 3632b8b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.FileNotFoundException;
2020
import java.io.IOException;
2121
import java.lang.annotation.Annotation;
22+
import java.net.SocketException;
2223
import java.net.UnknownHostException;
2324
import java.util.ArrayDeque;
2425
import java.util.ArrayList;
@@ -452,7 +453,7 @@ private void processPropertySource(AnnotationAttributes propertySource) throws I
452453
Resource resource = this.resourceLoader.getResource(resolvedLocation);
453454
addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
454455
}
455-
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException ex) {
456+
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException | SocketException ex) {
456457
// Placeholders not resolvable or resource not found when trying to open it
457458
if (ignoreResourceNotFound) {
458459
if (logger.isInfoEnabled()) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.io.FileNotFoundException;
2020
import java.io.IOException;
21+
import java.net.SocketException;
2122
import java.net.UnknownHostException;
2223
import java.util.Properties;
2324

@@ -181,7 +182,7 @@ protected void loadProperties(Properties props) throws IOException {
181182
PropertiesLoaderUtils.fillProperties(
182183
props, new EncodedResource(location, this.fileEncoding), this.propertiesPersister);
183184
}
184-
catch (FileNotFoundException | UnknownHostException ex) {
185+
catch (FileNotFoundException | UnknownHostException | SocketException ex) {
185186
if (this.ignoreResourceNotFound) {
186187
if (logger.isInfoEnabled()) {
187188
logger.info("Properties resource not found: " + ex.getMessage());

0 commit comments

Comments
 (0)