From 992b5552bb30bc838db1a0dc2a0ffbfd8a57c00d Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Fri, 10 Jun 2016 14:35:47 -0400 Subject: [PATCH] NIFI-1996: Fixed bug in the generation of UUID's for components when dealing with Snippets This closes #519 --- .../main/java/org/apache/nifi/web/util/SnippetUtils.java | 2 +- .../apache/nifi/web/revision/NaiveRevisionManager.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java index 9aaf43ffd1..e29089f64e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java @@ -596,7 +596,7 @@ public final class SnippetUtils { if (seed == null) { return UUID.randomUUID().toString(); } else { - return UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).toString(); + return UUID.nameUUIDFromBytes((currentId + seed).getBytes(StandardCharsets.UTF_8)).toString(); } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java index 7bcf9f4329..2171ea89fb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java @@ -383,6 +383,10 @@ public class NaiveRevisionManager implements RevisionManager { public T get(final String componentId, final ReadOnlyRevisionCallback callback) { final RevisionLock revisionLock = getRevisionLock(new Revision(0L, null, componentId)); logger.debug("Attempting to obtain read lock for {}", revisionLock.getRevision()); + if (logger.isTraceEnabled()) { + logger.trace("Attempting to obtain read lock due to following stack trace", new RuntimeException("Exception for generating stack trace for debugging purposes")); + } + revisionLock.acquireReadLock(null, revisionLock.getRevision().getClientId()); logger.debug("Obtained read lock for {}", revisionLock.getRevision()); @@ -402,6 +406,10 @@ public class NaiveRevisionManager implements RevisionManager { final Stack revisionLocks = new Stack<>(); logger.debug("Will attempt to obtain read locks for components {}", componentIds); + if (logger.isTraceEnabled()) { + logger.trace("Attempting to obtain read lock due to following stack trace", new RuntimeException("Exception for generating stack trace for debugging purposes")); + } + for (final String componentId : sortedIds) { final RevisionLock revisionLock = getRevisionLock(new Revision(0L, null, componentId));