Jan Quadflieg created JCR-4291:
----------------------------------

             Summary: FileInputStream for workspace.xml not closed in 
RepositoryConfig.loadWorkspaceConfig(File)
                 Key: JCR-4291
                 URL: https://issues.apache.org/jira/browse/JCR-4291
             Project: Jackrabbit Content Repository
          Issue Type: Bug
          Components: config
    Affects Versions: 2.17.2
            Reporter: Jan Quadflieg
         Attachments: RepositoryConfig.patch

As already said in the summary: The FileInputStream inĀ 
RepositoryConfig.loadWorkspaceConfig(File) is not closed. This open file handle 
prevents the repository from being deleted (we use a simple TransientRepository 
in unit tests which gets deleted after each test). The obvious fix is simple:

{color:#d04437}Buggy Code:{color}
{code:java}
try {
  File file = new File(directory, WORKSPACE_XML);
  InputSource xml = new InputSource(new FileInputStream(file));
  // ...
} catch (FileNotFoundException e) {
  return null;
}
{code}
{color:#14892c}Fixed Code:{color}
{code:java}
FileInputStream fin = null;
try {
  File file = new File(directory, WORKSPACE_XML);
  fin = new FileInputStream(file);
  InputSource xml = new InputSource(fin);
  // ...
} catch (FileNotFoundException e) {
  return null;
} finally {
  IOUtils.closeQuietly(fin);
}
{code}
The attached patch file has been created from the 2.17.2 source.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to