Skip to content

Commit 613b05d

Browse files
committed
Properties loading with ignoreResourceNotFound covers SocketException as well
Closes gh-25717
1 parent 939c76c commit 613b05d

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;
@@ -461,7 +462,7 @@ private void processPropertySource(AnnotationAttributes propertySource) throws I
461462
Resource resource = this.resourceLoader.getResource(resolvedLocation);
462463
addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
463464
}
464-
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException ex) {
465+
catch (IllegalArgumentException | FileNotFoundException | UnknownHostException | SocketException ex) {
465466
// Placeholders not resolvable or resource not found when trying to open it
466467
if (ignoreResourceNotFound) {
467468
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-2018 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.isDebugEnabled()) {
187188
logger.debug("Properties resource not found: " + ex.getMessage());

0 commit comments

Comments
 (0)