mirror of https://github.com/apache/nifi.git
NIFI-2006 fixed NPE in PersistentProvenanceRepository
Fixed NPE in PersistentProvenanceRepository caused by attribute value being null added test This closes #528
This commit is contained in:
parent
8b0c5a4911
commit
a8b42c26b6
|
@ -1786,11 +1786,9 @@ public class PersistentProvenanceRepository implements ProvenanceEventRepository
|
||||||
private Map<String, String> truncateAttributes(final Map<String, String> original) {
|
private Map<String, String> truncateAttributes(final Map<String, String> original) {
|
||||||
final Map<String, String> truncatedAttrs = new HashMap<>();
|
final Map<String, String> truncatedAttrs = new HashMap<>();
|
||||||
for (final Map.Entry<String, String> entry : original.entrySet()) {
|
for (final Map.Entry<String, String> entry : original.entrySet()) {
|
||||||
if (entry.getValue().length() > maxAttributeChars) {
|
String value = entry.getValue() != null && entry.getValue().length() > this.maxAttributeChars
|
||||||
truncatedAttrs.put(entry.getKey(), entry.getValue().substring(0, maxAttributeChars));
|
? entry.getValue().substring(0, this.maxAttributeChars) : entry.getValue();
|
||||||
} else {
|
truncatedAttrs.put(entry.getKey(), value);
|
||||||
truncatedAttrs.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return truncatedAttrs;
|
return truncatedAttrs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1225,6 +1225,7 @@ public class TestPersistentProvenanceRepository {
|
||||||
|
|
||||||
final Map<String, String> attributes = new HashMap<>();
|
final Map<String, String> attributes = new HashMap<>();
|
||||||
attributes.put("75chars", "123456789012345678901234567890123456789012345678901234567890123456789012345");
|
attributes.put("75chars", "123456789012345678901234567890123456789012345678901234567890123456789012345");
|
||||||
|
attributes.put("nullChar", null);
|
||||||
|
|
||||||
final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder();
|
final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder();
|
||||||
builder.setEventTime(System.currentTimeMillis());
|
builder.setEventTime(System.currentTimeMillis());
|
||||||
|
|
Loading…
Reference in New Issue