Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertiesLoaderSupport should ignore socket/connect exceptions as well #25717

Closed
vinov opened this issue Sep 7, 2020 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@vinov
Copy link

vinov commented Sep 7, 2020

Affects: 5.2.3-RELEASE
I am running on windows, trying to load properties from a shared network folder like \\remotehost\sharedfolder\common.properties, with ignoreResourceNotFound is set to true. If the property file is there, everything works, but in case the file is missing, loading fails with this somehow misleading exception:

java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_151]
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_151]
at sun.net.ftp.impl.FtpClient.doConnect(Unknown Source) ~[na:1.8.0_151]
at sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source) ~[na:1.8.0_151]
at sun.net.ftp.impl.FtpClient.connect(Unknown Source) ~[na:1.8.0_151]
at sun.net.ftp.impl.FtpClient.connect(Unknown Source) ~[na:1.8.0_151]
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source) ~[na:1.8.0_151]
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source) ~[na:1.8.0_151]
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:173) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:99) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]

This error is very similar for example to this one in bitbucket issue. My simplistic view is, that ConnectException could be ignored, but I am not sure, what this change could break.

If adding ConnectException to the ignore list is not possible, PropertiesLoaderSupport could be made more flexible so we could override its behaviour. Now, all the important fields like locations are not accessible to an ancestor class as well as PropertiesLoaderUtils.fillProperties() is not visible. If the loader would like to be super user friendly, it would also allow somehow to set timeout on URLConnection through UrlResource.getInputStream().

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 7, 2020
@jhoeller jhoeller self-assigned this Sep 7, 2020
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 7, 2020
@jhoeller jhoeller added this to the 5.2.9 milestone Sep 7, 2020
@jhoeller
Copy link
Contributor

jhoeller commented Sep 7, 2020

Good point, and I would go as far as ignoring any SocketException (the superclass of ConnectException) in such a scenario since we only really want to let parsing exceptions through. I'll refine this for 5.2.9 (to be released next week).

@jhoeller jhoeller changed the title PropertiesLoaderSupport may need to ignore also ConnectException in loadProperties() PropertiesLoaderSupport should ignore socket/connect exceptions as well Sep 7, 2020
@jhoeller jhoeller added the for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x label Sep 7, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x labels Sep 7, 2020
jhoeller added a commit that referenced this issue Sep 7, 2020
jhoeller added a commit that referenced this issue Sep 7, 2020
engimatic pushed a commit to engimatic/spring-framework that referenced this issue Sep 29, 2020
zx20110729 pushed a commit to zx20110729/spring-framework that referenced this issue Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants