Skip to content
Permalink
Browse files

taking care of closing inputstreams, HTTPClient

  • Loading branch information...
sgaebel
sgaebel committed Jan 4, 2019
1 parent 8d2e726 commit 811d40a6c486e5cfffb7f9b20788d14d5ef38012
@@ -41,7 +41,6 @@
import net.yacy.cora.date.ISO8601Formatter;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.ResponseHeader;
import net.yacy.cora.protocol.http.HTTPClient;
import net.yacy.cora.util.ConcurrentLog;
@@ -187,6 +186,12 @@ public void run() {
}
} catch (final Throwable e) {
ConcurrentLog.logException(e);
} finally {
try {
this.source.close();
} catch (IOException e) {
ConcurrentLog.logException(e);
}
}

try {
@@ -147,14 +147,19 @@ public opensearchdescriptionReader(final InputStream stream) {
public opensearchdescriptionReader(final String path, final ClientIdentification.Agent agent) {
this();
this.agent = agent;
HTTPClient www = new HTTPClient(agent);
try {
HTTPClient www = new HTTPClient(agent);
www.GET(path, false);
final SAXParser saxParser = getParser();
saxParser.parse(www.getContentstream(), this);
www.finish();
} catch (final Exception e) {
ConcurrentLog.logException(e);
} finally {
try {
www.finish();
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
}

@@ -165,24 +170,27 @@ public boolean read(String path) {
this.parsingTextValue = false;
this.rssurl = null;
this.atomurl = null;
HTTPClient www = new HTTPClient(this.agent);
try {
HTTPClient www = new HTTPClient(this.agent);
www.GET(path, false);
final SAXParser saxParser = getParser();
try {
saxParser.parse(www.getContentstream(), this);
} catch (final SAXException se) {
www.finish();
return false;
} catch (final IOException ioe) {
www.finish();
return false;
}
www.finish();
return true;
} catch (final Exception e) {
ConcurrentLog.warn("opensearchdescriptionReader", "parse exception: " + e);
return false;
} finally {
try {
www.finish();
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
}

0 comments on commit 811d40a

Please sign in to comment.
You can’t perform that action at this time.