mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-20 20:55:49 +00:00
Reset Recorder state when uri processing is finished (had been seeing cases where a url's entry in crawl.log would sometimes have nonzero size value if the url was erroring out and RecordingOutputStream.open() was never called)
This commit is contained in:
@@ -348,4 +348,8 @@ public class RecordingInputStream
|
||||
public int getRecordedBufferLength() {
|
||||
return recordingOutputStream.getBufferLength();
|
||||
}
|
||||
|
||||
public void clearForReuse() throws IOException {
|
||||
recordingOutputStream.clearForReuse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,19 +181,8 @@ public class RecordingOutputStream extends OutputStream {
|
||||
throw new IOException("ROS already open for "
|
||||
+Thread.currentThread().getName());
|
||||
}
|
||||
clearForReuse();
|
||||
this.out = wrappedStream;
|
||||
this.position = 0;
|
||||
this.markPosition = 0;
|
||||
this.maxPosition = 0;
|
||||
this.size = 0;
|
||||
this.messageBodyBeginMark = -1;
|
||||
// ensure recording turned on
|
||||
this.recording = true;
|
||||
// Always begins false; must use startDigest() to begin
|
||||
this.shouldDigest = false;
|
||||
if (this.diskStream != null) {
|
||||
closeDiskStream();
|
||||
}
|
||||
if (this.diskStream == null) {
|
||||
// TODO: Fix so we only make file when its actually needed.
|
||||
FileOutputStream fis = new FileOutputStream(this.backingFilename);
|
||||
@@ -567,5 +556,21 @@ public class RecordingOutputStream extends OutputStream {
|
||||
public long getRemainingLength() {
|
||||
return maxLength - position;
|
||||
}
|
||||
|
||||
public void clearForReuse() throws IOException {
|
||||
this.out = null;
|
||||
this.position = 0;
|
||||
this.markPosition = 0;
|
||||
this.maxPosition = 0;
|
||||
this.size = 0;
|
||||
this.messageBodyBeginMark = -1;
|
||||
// ensure recording turned on
|
||||
this.recording = true;
|
||||
// Always begins false; must use startDigest() to begin
|
||||
this.shouldDigest = false;
|
||||
if (this.diskStream != null) {
|
||||
closeDiskStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -577,5 +577,17 @@ public class Recorder {
|
||||
public void endReplays() {
|
||||
ArchiveUtils.closeQuietly(replayCharSequence);
|
||||
replayCharSequence = null;
|
||||
|
||||
// like closeQuietly
|
||||
try {
|
||||
ris.clearForReuse();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
|
||||
// like closeQuietly
|
||||
try {
|
||||
ros.clearForReuse();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user