NIFI-753: when truncating value, take null values into account

This commit is contained in:
Mark Payne 2015-07-07 20:44:03 -04:00
parent 208402472d
commit c0f1104679
1 changed files with 9 additions and 1 deletions

View File

@ -369,7 +369,15 @@ public class StandardRecordReader implements RecordReader {
for (int i = 0; i < numAttributes; i++) {
final String key = readLongString(dis);
final String value = valueNullable ? readLongNullableString(dis) : readLongString(dis);
final String truncatedValue = value.length() > maxAttributeChars ? value.substring(0, maxAttributeChars) : value;
final String truncatedValue;
if (value == null) {
truncatedValue = null;
} else if (value.length() > maxAttributeChars) {
truncatedValue = value.substring(0, maxAttributeChars);
} else {
truncatedValue = value;
}
attrs.put(key, truncatedValue);
}