taking care of closing inputstreams, HTTPClient

pull/278/head
sgaebel 6 years ago
parent 8d2e7262d9
commit 811d40a6c4

@ -41,7 +41,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
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 class sitemapParser extends AbstractParser implements Parser {
}
} catch (final Throwable e) {
ConcurrentLog.logException(e);
} finally {
try {
this.source.close();
} catch (IOException e) {
ConcurrentLog.logException(e);
}
}
try {

@ -147,14 +147,19 @@ public class opensearchdescriptionReader extends DefaultHandler {
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 class opensearchdescriptionReader extends DefaultHandler {
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);
}
}
}

Loading…
Cancel
Save