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

JavaPropsMapper doesn't close the .properties file properly after reading #179

Closed
fcolmenarez opened this issue Mar 12, 2020 · 4 comments
Closed
Labels
Properties Issue related to (Java) Properties format backend
Milestone

Comments

@fcolmenarez
Copy link

When I read an object from a .properties file I can't delete the file, access is held by the JVM. The input stream isn't closed properly unlike the regular JSON parser which does close.

This came up in a scenario when we read a properties file to create the object and later needed to delete the file.

Only seems to happen under Windows 10 (Linux is NOT impacted). Java version is 8 using Open JDK 8 u242 b08.

Attached a zip file with a small maven project created in IntelliJ demonstrating the issue. Run "compile" to ensure the resources (.json, .properties files) are copied to the target folder before each run.

jackson-testing.zip

@cowtowncoder
Copy link
Member

Thank you for reporting this, providing unit test. Will have a look.

@cowtowncoder cowtowncoder added 2.10 Properties Issue related to (Java) Properties format backend labels Mar 12, 2020
@cowtowncoder
Copy link
Member

Ah. Yes, I can see where this occurs. Just need to figure out best way to handle closing within JavaPropsParser, in appropriate cases (since there is special case of InputStream being passed, caller requesting stream not to be closed).
Ideally also need to see how to add an automated test case.

@fcolmenarez
Copy link
Author

Glad to be of help. For now we are working around it by loading the properties file separately into a byte array in memory and pass that to the mapper (the files is small enough size is not a concern)

@fcolmenarez fcolmenarez changed the title The JsonPropMapper doesn't close the .properties file properly after reading The JavaPropsMapper doesn't close the .properties file properly after reading Mar 12, 2020
@cowtowncoder cowtowncoder changed the title The JavaPropsMapper doesn't close the .properties file properly after reading JavaPropsMapper doesn't close the .properties file properly after reading Mar 12, 2020
@cowtowncoder cowtowncoder added this to the 2.10.4 milestone Mar 12, 2020
@cowtowncoder
Copy link
Member

Fixed (with test reproduction), to be included in 2.10.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Properties Issue related to (Java) Properties format backend
Projects
None yet
Development

No branches or pull requests

2 participants