NIFI-1187: Fixing issue of possible assigment reordering causing uninitalized values to be possibly returned

Signed-off-by: Aldrin Piri <aldrin@apache.org>
This commit is contained in:
Tony Kurc 2015-11-17 22:16:24 -05:00 committed by Aldrin Piri
parent c541c82c35
commit ab7940368a
2 changed files with 6 additions and 17 deletions

View File

@ -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);
}
}
}

View File

@ -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)");