From 928c308a6b7760dd65889b91f94f4ea028b769af Mon Sep 17 00:00:00 2001 From: Julien Nioche Date: Thu, 31 Oct 2024 07:54:57 +0000 Subject: [PATCH] bugfix - check for null before the for-each loop Signed-off-by: Julien Nioche --- .../org/apache/stormcrawler/warc/MetadataRecordFormat.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/external/warc/src/main/java/org/apache/stormcrawler/warc/MetadataRecordFormat.java b/external/warc/src/main/java/org/apache/stormcrawler/warc/MetadataRecordFormat.java index ab1dca92d..8a1a878dd 100644 --- a/external/warc/src/main/java/org/apache/stormcrawler/warc/MetadataRecordFormat.java +++ b/external/warc/src/main/java/org/apache/stormcrawler/warc/MetadataRecordFormat.java @@ -68,7 +68,9 @@ public byte[] format(Tuple tuple) { // get the metadata key / values to save in the WARCs for (String key : metadataKeys) { - for (String value : metadata.getValues(key)) { + final String[] values = metadata.getValues(key); + if (values == null || values.length == 0) continue; + for (String value : values) { if (StringUtils.isBlank(value)) continue; payload.append(key).append(": ").append(value).append(CRLF); }