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

(incubator-stormcrawler) branch 1385 created (now 9dcc357e)

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

jnioche pushed a change to branch 1385
in repository https://gitbox.apache.org/repos/asf/incubator-stormcrawler.git


      at 9dcc357e bugfix - check for null before the for-each loop

This branch includes the following new commits:

     new 9dcc357e bugfix - check for null before the for-each loop

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-stormcrawler) 01/01: bugfix - check for null before the for-each loop

Posted by jn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9dcc357ed30eec4eeb74723826a06eaf967da5b3
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);
             }