diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java index 0c830a7554..f91f6a4472 100644 --- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java +++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java @@ -1786,11 +1786,9 @@ public class PersistentProvenanceRepository implements ProvenanceEventRepository private Map truncateAttributes(final Map original) { final Map truncatedAttrs = new HashMap<>(); for (final Map.Entry entry : original.entrySet()) { - if (entry.getValue().length() > maxAttributeChars) { - truncatedAttrs.put(entry.getKey(), entry.getValue().substring(0, maxAttributeChars)); - } else { - truncatedAttrs.put(entry.getKey(), entry.getValue()); - } + String value = entry.getValue() != null && entry.getValue().length() > this.maxAttributeChars + ? entry.getValue().substring(0, this.maxAttributeChars) : entry.getValue(); + truncatedAttrs.put(entry.getKey(), value); } return truncatedAttrs; } diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/test/java/org/apache/nifi/provenance/TestPersistentProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/test/java/org/apache/nifi/provenance/TestPersistentProvenanceRepository.java index 4a5c08c4a6..3238d972c7 100644 --- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/test/java/org/apache/nifi/provenance/TestPersistentProvenanceRepository.java +++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/test/java/org/apache/nifi/provenance/TestPersistentProvenanceRepository.java @@ -1225,6 +1225,7 @@ public class TestPersistentProvenanceRepository { final Map attributes = new HashMap<>(); attributes.put("75chars", "123456789012345678901234567890123456789012345678901234567890123456789012345"); + attributes.put("nullChar", null); final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder(); builder.setEventTime(System.currentTimeMillis());