Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Make StreamResponse usable in Java try-with-resources statements
luccioman17c7a85f189c
diff --git a/source/net/yacy/crawler/retrieval/StreamResponse.java b/source/net/yacy/crawler/retrieval/StreamResponse.javaindex d52614e4f..d8a1e9267 100644--- a/source/net/yacy/crawler/retrieval/StreamResponse.java+++ b/source/net/yacy/crawler/retrieval/StreamResponse.java@@ -22,6 +22,7 @@package net.yacy.crawler.retrieval;+import java.io.Closeable;import java.io.IOException;import java.io.InputStream;import java.nio.charset.StandardCharsets;@@ -34,7 +35,7 @@ import net.yacy.document.TextParser;/*** A crawler load response, holding content as a stream.*/-public class StreamResponse {+public class StreamResponse implements Closeable {/** Logger */private final static ConcurrentLog log = new ConcurrentLog(StreamResponse.class.getSimpleName());@@ -79,6 +80,13 @@ public class StreamResponse {public Response getResponse() {return this.response;}++ @Override+ public void close() throws IOException {+ if(this.contentStream != null) {+ this.contentStream.close();+ }+ }/*** Parse and close the content stream and return the parsed documents when