NIFI-7224 Protecting against possible NPE in ImportFlowVersion command in CLI

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #4121.
This commit is contained in:
Bryan Bende 2020-03-06 16:08:09 -05:00 committed by Pierre Villard
parent 578430c9d9
commit ac4d52b6ca
No known key found for this signature in database
GPG Key ID: BEE1599F0726E9CD
1 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,11 @@ public class ImportFlowVersion extends AbstractNiFiRegistryCommand<StringResult>
metadata.setBucketIdentifier(versionedFlow.getBucketIdentifier());
metadata.setFlowIdentifier(flowId);
metadata.setVersion(version);
metadata.setComments(deserializedSnapshot.getSnapshotMetadata().getComments());
final VersionedFlowSnapshotMetadata deserializedSnapshotMetadata = deserializedSnapshot.getSnapshotMetadata();
if (deserializedSnapshotMetadata != null) {
metadata.setComments(deserializedSnapshotMetadata.getComments());
}
// create a new snapshot using the new metadata and the contents from the deserialized snapshot
final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot();