mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-27 08:05:46 +00:00
Close recorders on failure to avoid exception from retry cycle within httpclient- now all the FetchHTTPTests pass
This commit is contained in:
@@ -648,10 +648,10 @@ public class FetchHTTP extends Processor implements Lifecycle {
|
||||
response = req.execute();
|
||||
addResponseContent(response, curi);
|
||||
} catch (ClientProtocolException e) {
|
||||
failedExecuteCleanup(req.request, curi, e);
|
||||
failedExecuteCleanup(curi, e);
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
failedExecuteCleanup(req.request, curi, e);
|
||||
failedExecuteCleanup(curi, e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -684,9 +684,6 @@ public class FetchHTTP extends Processor implements Lifecycle {
|
||||
rec.close();
|
||||
// ensure recording has stopped
|
||||
rec.closeRecorders();
|
||||
if (!req.request.isAborted()) {
|
||||
req.request.reset();
|
||||
}
|
||||
// Note completion time
|
||||
curi.setFetchCompletedTime(System.currentTimeMillis());
|
||||
|
||||
@@ -991,17 +988,14 @@ public class FetchHTTP extends Processor implements Lifecycle {
|
||||
*
|
||||
* @param curi
|
||||
* CrawlURI we failed on.
|
||||
* @param request
|
||||
* Method we failed on.
|
||||
* @param exception
|
||||
* Exception we failed with.
|
||||
*/
|
||||
protected void failedExecuteCleanup(final AbortableHttpRequestBase request,
|
||||
final CrawlURI curi, final Exception exception) {
|
||||
protected void failedExecuteCleanup(final CrawlURI curi,
|
||||
final Exception exception) {
|
||||
cleanup(curi, exception, "executeMethod", S_CONNECT_FAILED);
|
||||
request.reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup after a failed method execute.
|
||||
*
|
||||
|
||||
@@ -134,6 +134,22 @@ public class FetchHTTPRequest {
|
||||
super.receiveResponseEntity(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() throws IOException {
|
||||
super.shutdown();
|
||||
|
||||
/*
|
||||
* Need to do this to avoid "java.io.IOException: RIS already open"
|
||||
* on urls that are retried within httpcomponents. Exercised by
|
||||
* FetchHTTPTests.testNoResponse()
|
||||
*/
|
||||
Recorder recorder = Recorder.getHttpRecorder();
|
||||
if (recorder != null) {
|
||||
recorder.close();
|
||||
recorder.closeRecorders();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -787,6 +787,7 @@ public class FetchHTTPTests extends ProcessorTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
// Implicitly tests the retry cycle within httpcomponents
|
||||
public void testNoResponse() throws Exception {
|
||||
NoResponseServer noResponseServer = new NoResponseServer("localhost", 7780);
|
||||
noResponseServer.start();
|
||||
|
||||
Reference in New Issue
Block a user