[
https://issues.apache.org/jira/browse/DERBY-2162?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-2162:
--------------------------------------
Attachment: d2162-1a.diff
The attached patch (d2162-1a.diff) makes ClasspathSetup.tearDown() call close()
on the URLClassLoader to free the resources held by it. It rewrites
DatabaseClassLoadingTest.testDatabaseInClasspath() so that it uses
ClasspathSetup, and enables it on Java 7 and higher (not on Java 6 because it's
missing URLClassLoader.close()).
The patch also enables some previously disabled test cases in
NativeAuthenticationServiceTest on Windows (except on Java 6).
These test cases now run cleanly for me on Windows. Without the fix in
ClasspathSetup.tearDown(), they fail because they cannot delete the jar files
at the end of the test.
URLClassLoader.close() is protected by a RuntimePermission. The patch grants
that permission to derbyTesting.jar.
> Shutting down a database loaded from a jar file via the classpath and
> URLClassLoader leaves an open file reference to the jar file containing the
> database.
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2162
> URL: https://issues.apache.org/jira/browse/DERBY-2162
> Project: Derby
> Issue Type: Bug
> Components: Services
> Affects Versions: 10.2.1.6, 10.3.1.4
> Reporter: Daniel John Debrunner
> Assignee: Knut Anders Hatlen
> Priority: Minor
> Labels: derby_triage10_5_2
> Attachments: d2162-1a.diff
>
>
> A bug in java.net.URLClassLoader causes the underlying jar file to be held
> open once a resource has been fetched and opened.
> Loading a class or just accessing the URL for the resource does not keep the
> jar open. Reported the bug to Sun, it is similar to the existing bug Java bug
> 4950148 but in this case no amount of garbage collection will close the jar.
> Derby exposes this as all containers/files are opened using as resources when
> loading the database from the classpath.
> On windows this is seen as the inability to delete the jar file, seen by the
> fixture testDatabaseInClasspath in DatabaseClassLoadingTest.
> Similar to DERBY-2083 but due to a different cause.
--
This message was sent by Atlassian JIRA
(v6.2#6252)