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
CONFIGURATION-794: add test which demonstrates unclosed file handle #76
Conversation
Seems to be a Windows specific problem... |
URL jarResource = getClass().getClassLoader().getResource("test.jar"); | ||
assertNotNull(jarResource); | ||
final Path testJar = Paths.get(folder.getRoot().getAbsolutePath(), "test.jar"); | ||
Files.copy(jarResource.openStream(), testJar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stream needs to be managed in a try-with-resources block.
testFileBasedConfigurationBuilder.testGetConfigurationLoadFromJarFile based on #76 Fails on Windows: java.lang.AssertionError: Unable to clean up temporary folder C:\Users\ggregory\AppData\Local\Temp\junit4296513623415900710 at org.junit.Assert.fail(Assert.java:89) at org.junit.rules.TemporaryFolder.delete(TemporaryFolder.java:274) at org.junit.rules.TemporaryFolder.after(TemporaryFolder.java:138) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:59) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
I added tweaked test with:
|
testFileBasedConfigurationBuilder.testGetConfigurationLoadFromJarFile based on #76 Fails on Windows: java.lang.AssertionError: Unable to clean up temporary folder C:\Users\ggregory\AppData\Local\Temp\junit4296513623415900710 at org.junit.Assert.fail(Assert.java:89) at org.junit.rules.TemporaryFolder.delete(TemporaryFolder.java:274) at org.junit.rules.TemporaryFolder.after(TemporaryFolder.java:138) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:59) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Should I close this PR since you added a test case like this to the master already? Do you have any idea why it fails on Windows? |
You can close this PR or rebase it on master if you want to offer a fix or more tests. |
It fails on Windows because the OS locks the jar files that it opens. |
For future references: Fix was provided with commit e0888d8#diff-6dd674b6f0044cb5f3b6a7e2ffc1800cc85bea034c7a87617f87f2a4ab38cb08R142 available from version 2.8.0+. |
Actually it seems that it didn't make it into version 2.8.0... @garydgregory can you confirm this? Release notes indicate that it was added for 2.8.0 but I cannot find the specific class in the JAR file (neither Bintray nor Maven Central). |
Version 2.8.0 is not out yet. See previous comment with link to git commit. Let us know if that does not match up with what you are looking for. |
Well, someone already did upload a version 2.8.0 for commons-io on Maven Central and Bintray: |
The title of this ticket is about the CONFIGURATION component, not IO. What am I missing? |
Well, this is embarrassing. I mixed up the two components... Do you have an estimate when the new version 2.8.0 of commons-configuration will be released? |
As we have many components within Apache Commons, the confusion is
understandable :-) ! There is no release date set but it is on my to
do list after IO and LANG.
Gary
…On Fri, Jan 29, 2021, 05:28 jansohn ***@***.***> wrote:
Well, someone already did upload a version 2.8.0 for commons-io on Maven
Central and Bintray:
- https://repo1.maven.org/maven2/commons-io/commons-io/2.8.0/
- https://bintray.com/bintray/jcenter/commons-io%3Acommons-io/2.8.0
The title of this ticket is about the CONFIGURATION component, not IO.
What am I missing?
Well, this is embarrassing. I mixed up the two components...
Do you have an estimate when the new version 2.8.0 of
commons-configuration will be released?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#76 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJB6NZZ5IHKKWNF2EXGW63S4KEV7ANCNFSM4SILZICA>
.
|
Code which reproduces the unclosed file handle problem.