(warc) Fix NPE in WarcRecorder
This commit is contained in:
parent
85f906ea53
commit
1755b646b8
@ -203,7 +203,14 @@ public class WarcRecorder implements AutoCloseable {
|
||||
WarcDigestBuilder responseDigestBuilder = new WarcDigestBuilder();
|
||||
WarcDigestBuilder payloadDigestBuilder = new WarcDigestBuilder();
|
||||
|
||||
byte[] bytes = documentBody.getBytes();
|
||||
byte[] bytes;
|
||||
|
||||
if (documentBody == null) {
|
||||
bytes = new byte[0];
|
||||
}
|
||||
else {
|
||||
bytes = documentBody.getBytes();
|
||||
}
|
||||
|
||||
String fakeHeaders = STR."""
|
||||
Content-Type: \{contentType}
|
||||
|
@ -91,6 +91,18 @@ class WarcRecorderTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flagAsSkippedNullBody() throws IOException, URISyntaxException {
|
||||
|
||||
try (var recorder = new WarcRecorder(fileNameWarc)) {
|
||||
recorder.flagAsSkipped(new EdgeUrl("https://www.marginalia.nu/"),
|
||||
"text/html",
|
||||
200,
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveImport() throws URISyntaxException, IOException {
|
||||
try (var recorder = new WarcRecorder(fileNameWarc)) {
|
||||
|
Loading…
Reference in New Issue
Block a user