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

CONFIGURATION-794: add test which demonstrates unclosed file handle #76

Closed
wants to merge 1 commit into from
Closed

Conversation

jansohn
Copy link

@jansohn jansohn commented Oct 8, 2020

Code which reproduces the unclosed file handle problem.

@jansohn
Copy link
Author

jansohn commented Oct 8, 2020

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);
Copy link
Member

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.

asfgit pushed a commit that referenced this pull request Oct 8, 2020
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)
@garydgregory
Copy link
Member

garydgregory commented Oct 8, 2020

I added tweaked test with:

commit b84a0ef5ad561e64e98f13e8b912003fda9f5469
Author: Gary Gregory <garydgregory@gmail.com> 2020-10-08 14:42:08
Committer: Gary Gregory <garydgregory@gmail.com> 2020-10-08 14:42:08
Parent: b773e0c309c5fbbe0ab4d36cd47370759589571b (Javadoc: Replace <code></code> HTML tags with Javadoc {@code} notation.)
Branches: master, origin/master

Add and ignore
testFileBasedConfigurationBuilder.testGetConfigurationLoadFromJarFile
based on https://github.com/apache/commons-configuration/pull/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)

asfgit pushed a commit that referenced this pull request Oct 8, 2020
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)
@jansohn
Copy link
Author

jansohn commented Oct 9, 2020

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?

@garydgregory
Copy link
Member

You can close this PR or rebase it on master if you want to offer a fix or more tests.

@jansohn jansohn closed this Oct 9, 2020
@sebbASF
Copy link
Contributor

sebbASF commented Oct 11, 2020

It fails on Windows because the OS locks the jar files that it opens.

@jansohn
Copy link
Author

jansohn commented Oct 13, 2020

For future references: Fix was provided with commit e0888d8#diff-6dd674b6f0044cb5f3b6a7e2ffc1800cc85bea034c7a87617f87f2a4ab38cb08R142 available from version 2.8.0+.

@jansohn
Copy link
Author

jansohn commented Jan 27, 2021

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).

@garydgregory
Copy link
Member

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.

@jansohn
Copy link
Author

jansohn commented Jan 28, 2021

Well, someone already did upload a version 2.8.0 for commons-io on Maven Central and Bintray:

@garydgregory
Copy link
Member

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?

@jansohn
Copy link
Author

jansohn commented Jan 29, 2021

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?

@garydgregory
Copy link
Member

garydgregory commented Jan 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants