#fixed code
                                @Override
    public List<BxDocument> getDocuments() throws TransformationException {
        String dirPath = directory.getPath();
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxDocument> documents = new ArrayList<BxDocument>();

        if (!dirPath.endsWith(File.separator)) {
            dirPath += File.separator;
        }
        for (String filename : directory.list()) {
            if (!new File(dirPath + filename).isFile()) {
                continue;
            }
            if (filename.endsWith("xml")) {
                InputStream is = null;
                try {
                    is = new FileInputStream(dirPath + filename);
                    List<BxPage> pages = tvReader.read(new InputStreamReader(is, "UTF-8"));
                    BxDocument newDoc = new BxDocument();
                    for (BxPage page : pages) {
                        page.setParent(newDoc);
                    }
                    newDoc.setFilename(filename);
                    newDoc.setPages(pages);
                    documents.add(newDoc);
                } catch (IllegalStateException ex) {
                    System.err.println(ex.getMessage());
                    System.err.println(dirPath + filename);
                    throw ex;
                } catch (FileNotFoundException ex) {
                    throw new TransformationException("File not found!", ex);
                } catch (UnsupportedEncodingException ex) {
                    throw new TransformationException("Unsupported encoding!", ex);
                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (IOException ex) {
                            throw new TransformationException("Cannot close stream!", ex);
                        }
                    }
                }
            }
        }
        return documents;
    }
#vulnerable code 
                                @Override
    public List<BxDocument> getDocuments() throws TransformationException {
        String dirPath = directory.getPath();
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxDocument> documents = new ArrayList<BxDocument>();

        if (!dirPath.endsWith(File.separator)) {
            dirPath += File.separator;
        }
        for (String filename : directory.list()) {
            if (!new File(dirPath + filename).isFile()) {
                continue;
            }
            if (filename.endsWith("xml")) {
                InputStream is = null;
                try {
                    is = new FileInputStream(dirPath + filename);
                    List<BxPage> pages = tvReader.read(new InputStreamReader(is));
                    BxDocument newDoc = new BxDocument();
                    for (BxPage page : pages) {
                        page.setParent(newDoc);
                    }
                    newDoc.setFilename(filename);
                    newDoc.setPages(pages);
                    documents.add(newDoc);
                } catch (IllegalStateException ex) {
                    System.err.println(ex.getMessage());
                    System.err.println(dirPath + filename);
                    throw ex;
                } catch (FileNotFoundException ex) {
                    throw new TransformationException("File not found!", ex);
                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (IOException ex) {
                            throw new TransformationException("Cannot close stream!", ex);
                        }
                    }
                }
            }
        }
        return documents;
    } 
                            #location 18 
                            #vulnerability type RESOURCE_LEAK