NIFI-1187: Fixing issue of possible assigment reordering causing uninitalized values to be possibly returned
Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/ab794036 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/ab794036 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/ab794036 Branch: refs/heads/NIFI-655 Commit: ab7940368a18e8d29d8fadcc435db8ae8b4ee001 Parents: c541c82 Author: Tony Kurc <[email protected]> Authored: Tue Nov 17 22:16:24 2015 -0500 Committer: Aldrin Piri <[email protected]> Committed: Wed Nov 18 17:37:47 2015 -0500 ---------------------------------------------------------------------- .../couchbase/AbstractCouchbaseProcessor.java | 8 +++----- .../nifi/processors/flume/util/FlowFileEvent.java | 15 +++------------ 2 files changed, 6 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/ab794036/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/main/java/org/apache/nifi/processors/couchbase/AbstractCouchbaseProcessor.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/main/java/org/apache/nifi/processors/couchbase/AbstractCouchbaseProcessor.java b/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/main/java/org/apache/nifi/processors/couchbase/AbstractCouchbaseProcessor.java index 158caa1..ec0e9ab 100644 --- a/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/main/java/org/apache/nifi/processors/couchbase/AbstractCouchbaseProcessor.java +++ b/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/main/java/org/apache/nifi/processors/couchbase/AbstractCouchbaseProcessor.java @@ -137,12 +137,10 @@ public abstract class AbstractCouchbaseProcessor extends AbstractProcessor { } private CouchbaseClusterControllerService getClusterService(final ProcessContext context) { - if (clusterService == null) { - synchronized (AbstractCouchbaseProcessor.class) { - if (clusterService == null) { - clusterService = context.getProperty(COUCHBASE_CLUSTER_SERVICE) + synchronized (AbstractCouchbaseProcessor.class) { + if (clusterService == null) { + clusterService = context.getProperty(COUCHBASE_CLUSTER_SERVICE) .asControllerService(CouchbaseClusterControllerService.class); - } } } http://git-wip-us.apache.org/repos/asf/nifi/blob/ab794036/nifi-nar-bundles/nifi-flume-bundle/nifi-flume-processors/src/main/java/org/apache/nifi/processors/flume/util/FlowFileEvent.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-flume-bundle/nifi-flume-processors/src/main/java/org/apache/nifi/processors/flume/util/FlowFileEvent.java b/nifi-nar-bundles/nifi-flume-bundle/nifi-flume-processors/src/main/java/org/apache/nifi/processors/flume/util/FlowFileEvent.java index fdff203..c552d4d 100644 --- a/nifi-nar-bundles/nifi-flume-bundle/nifi-flume-processors/src/main/java/org/apache/nifi/processors/flume/util/FlowFileEvent.java +++ b/nifi-nar-bundles/nifi-flume-bundle/nifi-flume-processors/src/main/java/org/apache/nifi/processors/flume/util/FlowFileEvent.java @@ -59,12 +59,8 @@ public class FlowFileEvent implements Event { @Override public Map<String, String> getHeaders() { - if (!headersLoaded) { - synchronized (headers) { - if (headersLoaded) { - return headers; - } - + synchronized (headers) { + if (!headersLoaded) { headers.putAll(flowFile.getAttributes()); headers.put(ENTRY_DATE_HEADER, Long.toString(flowFile.getEntryDate())); headers.put(ID_HEADER, Long.toString(flowFile.getId())); @@ -76,7 +72,6 @@ public class FlowFileEvent implements Event { } headers.put(LINEAGE_START_DATE_HEADER, Long.toString(flowFile.getLineageStartDate())); headers.put(SIZE_HEADER, Long.toString(flowFile.getSize())); - headersLoaded = true; } } @@ -94,11 +89,7 @@ public class FlowFileEvent implements Event { @Override public byte[] getBody() { - if (bodyLoaded) { - return body; - } - - synchronized (bodyLock ) { + synchronized (bodyLock) { if (!bodyLoaded) { if (flowFile.getSize() > Integer.MAX_VALUE) { throw new RuntimeException("Can't get body of Event because the backing FlowFile is too large (" + flowFile.getSize() + " bytes)");
