Permalink
Browse files

Ensure system resource release by closing document stream.

  • Loading branch information...
luccioman committed Jun 8, 2017
1 parent 8399275 commit ce8949231999551d1f28db6abcc0630ecfbaf7db
Showing with 10 additions and 1 deletion.
  1. +10 −1 source/net/yacy/document/TextParser.java
@@ -343,7 +343,16 @@ private static void initParser(final Parser parser) {
throw new Parser.Failure("All parser failed: " + failedParsers, location);
}
for (final Document d: docs) {
assert d.getTextStream() != null : "mimeType = " + mimeType;
InputStream textStream = d.getTextStream();
assert textStream != null : "mimeType = " + mimeType;
try {
if(textStream != null) {
/* this textStream can wrap a FileInputStream : as it won't be used anymore, we must close it to ensure the system resource is released */
textStream.close();
}
} catch (IOException e) {
AbstractParser.log.warn("Could not close text input stream");
}
d.setDepth(depth);
} // verify docs

0 comments on commit ce89492

Please sign in to comment.