From 613b05d814e14ed3f96b7d8ef64d5dc9c84a2e3e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 7 Sep 2020 17:51:14 +0200 Subject: [PATCH] Properties loading with ignoreResourceNotFound covers SocketException as well Closes gh-25717 --- .../context/annotation/ConfigurationClassParser.java | 3 ++- .../core/io/support/PropertiesLoaderSupport.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 492d6e343102..3adec23443c2 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -19,6 +19,7 @@ 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; @@ -461,7 +462,7 @@ private void processPropertySource(AnnotationAttributes propertySource) throws I 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()) { diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java index 9b68413d77fc..b2a05b8573e0 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java @@ -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 @@ import java.io.FileNotFoundException; import java.io.IOException; +import java.net.SocketException; import java.net.UnknownHostException; import java.util.Properties; @@ -181,7 +182,7 @@ protected void loadProperties(Properties props) throws IOException { 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());