mirror of
https://github.com/apache/nifi.git
synced 2025-02-16 15:06:00 +00:00
NIFI-259: Fixed NullPointerException
This commit is contained in:
parent
d6a21537c1
commit
6af2d4a342
@ -50,8 +50,15 @@ public class StateMapSerDe implements SerDe<StateMapUpdate> {
|
||||
final Map<String, String> map = stateMap.toMap();
|
||||
out.writeInt(map.size());
|
||||
for (final Map.Entry<String, String> entry : map.entrySet()) {
|
||||
out.writeUTF(entry.getKey());
|
||||
out.writeUTF(entry.getValue());
|
||||
final boolean hasKey = entry.getKey() != null;
|
||||
final boolean hasValue = entry.getValue() != null;
|
||||
if (hasKey) {
|
||||
out.writeUTF(entry.getKey());
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
out.writeUTF(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,8 +80,10 @@ public class StateMapSerDe implements SerDe<StateMapUpdate> {
|
||||
final int numEntries = in.readInt();
|
||||
final Map<String, String> stateValues = new HashMap<>(numEntries);
|
||||
for (int i = 0; i < numEntries; i++) {
|
||||
final String key = in.readUTF();
|
||||
final String value = in.readUTF();
|
||||
final boolean hasKey = in.readBoolean();
|
||||
final String key = hasKey ? in.readUTF() : null;
|
||||
final boolean hasValue = in.readBoolean();
|
||||
final String value = hasValue ? in.readUTF() : null;
|
||||
stateValues.put(key, value);
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,17 @@ public class ZooKeeperStateProvider extends AbstractStateProvider {
|
||||
dos.writeByte(ENCODING_VERSION);
|
||||
dos.writeInt(stateValues.size());
|
||||
for (final Map.Entry<String, String> entry : stateValues.entrySet()) {
|
||||
dos.writeUTF(entry.getKey());
|
||||
dos.writeUTF(entry.getValue());
|
||||
final boolean hasKey = entry.getKey() != null;
|
||||
final boolean hasValue = entry.getValue() != null;
|
||||
dos.writeBoolean(hasKey);
|
||||
if (hasKey) {
|
||||
dos.writeUTF(entry.getKey());
|
||||
}
|
||||
|
||||
dos.writeBoolean(hasValue);
|
||||
if (hasValue) {
|
||||
dos.writeUTF(entry.getValue());
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
@ -276,8 +285,11 @@ public class ZooKeeperStateProvider extends AbstractStateProvider {
|
||||
final int numEntries = dis.readInt();
|
||||
final Map<String, String> stateValues = new HashMap<>(numEntries);
|
||||
for (int i = 0; i < numEntries; i++) {
|
||||
final String key = dis.readUTF();
|
||||
final String value = dis.readUTF();
|
||||
final boolean hasKey = dis.readBoolean();
|
||||
final String key = hasKey ? dis.readUTF() : null;
|
||||
|
||||
final boolean hasValue = dis.readBoolean();
|
||||
final String value = hasValue ? dis.readUTF() : null;
|
||||
stateValues.put(key, value);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user