You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by kd...@apache.org on 2018/05/24 15:45:56 UTC
nifi-registry git commit: NIFIREG-160 Fixing issue where version
created event throws an exception when comments are not provided
Repository: nifi-registry
Updated Branches:
refs/heads/master 51b6c78b6 -> 3d765be3d
NIFIREG-160 Fixing issue where version created event throws an exception when comments are not provided
This closes #118.
Signed-off-by: Kevin Doran <kd...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/3d765be3
Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/3d765be3
Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/3d765be3
Branch: refs/heads/master
Commit: 3d765be3d6c1cecba6cd5b96830e3f2f8af34e12
Parents: 51b6c78
Author: Bryan Bende <bb...@apache.org>
Authored: Thu May 24 11:23:16 2018 -0400
Committer: Kevin Doran <kd...@apache.org>
Committed: Thu May 24 11:43:44 2018 -0400
----------------------------------------------------------------------
.../java/org/apache/nifi/registry/event/EventFactory.java | 5 ++++-
.../org/apache/nifi/registry/event/StandardEventField.java | 2 +-
.../org/apache/nifi/registry/event/TestEventFactory.java | 8 ++++++++
.../apache/nifi/registry/web/api/ApplicationResource.java | 7 ++++++-
4 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3d765be3/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/EventFactory.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/EventFactory.java b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/EventFactory.java
index ba9e775..b837d6d 100644
--- a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/EventFactory.java
+++ b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/EventFactory.java
@@ -81,13 +81,16 @@ public class EventFactory {
}
public static Event flowVersionCreated(final VersionedFlowSnapshot versionedFlowSnapshot) {
+ final String versionComments = versionedFlowSnapshot.getSnapshotMetadata().getComments() == null
+ ? "" : versionedFlowSnapshot.getSnapshotMetadata().getComments();
+
return new StandardEvent.Builder()
.eventType(EventType.CREATE_FLOW_VERSION)
.addField(EventFieldName.BUCKET_ID, versionedFlowSnapshot.getSnapshotMetadata().getBucketIdentifier())
.addField(EventFieldName.FLOW_ID, versionedFlowSnapshot.getSnapshotMetadata().getFlowIdentifier())
.addField(EventFieldName.VERSION, String.valueOf(versionedFlowSnapshot.getSnapshotMetadata().getVersion()))
.addField(EventFieldName.USER, versionedFlowSnapshot.getSnapshotMetadata().getAuthor())
- .addField(EventFieldName.COMMENT, versionedFlowSnapshot.getSnapshotMetadata().getComments())
+ .addField(EventFieldName.COMMENT, versionComments)
.build();
}
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3d765be3/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/StandardEventField.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/StandardEventField.java b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/StandardEventField.java
index 7ff94c5..21266bb 100644
--- a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/StandardEventField.java
+++ b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/event/StandardEventField.java
@@ -33,7 +33,7 @@ public class StandardEventField implements EventField {
this.name = name;
this.value = value;
Validate.notNull(this.name);
- Validate.notBlank(this.value);
+ Validate.notNull(this.value);
}
@Override
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3d765be3/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
index 95dd6ab..a9ad911 100644
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
@@ -158,4 +158,12 @@ public class TestEventFactory {
event.getField(EventFieldName.COMMENT).getValue());
}
+ @Test
+ public void testFlowVersionedCreatedWhenCommentsMissing() {
+ versionedFlowSnapshot.getSnapshotMetadata().setComments(null);
+ final Event event = EventFactory.flowVersionCreated(versionedFlowSnapshot);
+ event.validate();
+ assertEquals("", event.getField(EventFieldName.COMMENT).getValue());
+ }
+
}
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3d765be3/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/ApplicationResource.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/ApplicationResource.java
index 34369d0..776a693 100644
--- a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/ApplicationResource.java
+++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/ApplicationResource.java
@@ -62,8 +62,13 @@ public class ApplicationResource {
Validate.notNull(this.eventService);
}
+ // We don't want an error creating/publishing an event to cause the overall request to fail, so catch all throwables here
protected void publish(final Event event) {
- eventService.publish(event);
+ try {
+ eventService.publish(event);
+ } catch (Throwable t) {
+ logger.error("Unable to publish event: " + t.getMessage(), t);
+ }
}
protected String generateResourceUri(final String... path) {