Skip to content

Commit

Permalink
#239 close input streams
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Dec 6, 2023
1 parent a8d30ca commit 7c48d43
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws

logger.trace("Matches {}", matches);

// Graph g = GraphFactory.createDefaultGraph();
builder.addRoot(dataSourceId);

try {
Expand All @@ -67,6 +66,8 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws

}

debInputStream.close();

} catch (ArchiveException e) {
throw new IOException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws
i++;
}
}

zis.close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws

builder.addRoot(dataSourceId);

try (InputStream is = Triplifier.getInputStream(properties)){
try (InputStream is = Triplifier.getInputStream(properties); Reader reader = new InputStreamReader(is)){

BibTeXParser bibtexParser = new BibTeXParser();
Reader reader = new InputStreamReader(is);
BibTeXDatabase bibDB = bibtexParser.parse(reader);
AtomicInteger count = new AtomicInteger();
bibDB.getEntries().forEach((key, entry) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ private byte[] downloadUrl(URL toDownload) {
outputStream.write(chunk, 0, bytesRead);
}

stream.close();

byte[] result = outputStream.toByteArray();
outputStream.close();
return result;
} catch (IOException e) {
logger.error("",e);
return null;
}

return outputStream.toByteArray();
}

@Override
Expand Down

0 comments on commit 7c48d43

Please sign in to comment.