Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-4291

FileInputStream for workspace.xml not closed in RepositoryConfig.loadWorkspaceConfig(File)

    XMLWordPrintableJSON

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.

      Attachments

        1. RepositoryConfig.patch
          0.6 kB
          Jan Quadflieg

        Activity

          People

            reschke Julian Reschke
            jan.quadflieg Jan Quadflieg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: