Details
Description
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:
Buggy Code:
try { File file = new File(directory, WORKSPACE_XML); InputSource xml = new InputSource(new FileInputStream(file)); // ... } catch (FileNotFoundException e) { return null; }
Fixed Code:
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); }
The attached patch file has been created from the 2.17.2 source.