You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stormcrawler.apache.org by rz...@apache.org on 2024/10/31 10:51:13 UTC

(incubator-stormcrawler) branch main updated: bugfix - check for null before the for-each loop

This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-stormcrawler.git


The following commit(s) were added to refs/heads/main by this push:
     new 928c308a bugfix - check for null before the for-each loop
928c308a is described below

commit 928c308a6b7760dd65889b91f94f4ea028b769af
Author: Julien Nioche <ju...@digitalpebble.com>
AuthorDate: Thu Oct 31 07:54:57 2024 +0000

    bugfix - check for null before the for-each loop
    
    Signed-off-by: Julien Nioche <ju...@digitalpebble.com>
---
 .../main/java/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 ab1dca92..8a1a878d 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 class MetadataRecordFormat extends WARCRecordFormat {
 
         // 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);
             }