Repository: nifi Updated Branches: refs/heads/master 32a8db225 -> d4632bdd5
NIFI-4944: Guard against race condition in Snappy for PutHiveStreaming NIFI-4944: Removed unnecessary synchronized block, added more comments This closes #2519 Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d4632bdd Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d4632bdd Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d4632bdd Branch: refs/heads/master Commit: d4632bdd5dce85cc7adb8c70bafda44d6a333da9 Parents: 32a8db2 Author: Matthew Burgess <[email protected]> Authored: Wed Mar 7 15:19:39 2018 -0500 Committer: Matt Gilman <[email protected]> Committed: Mon Mar 12 13:22:40 2018 -0400 ---------------------------------------------------------------------- .../apache/nifi/processors/hive/PutHiveStreaming.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/d4632bdd/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java index f5f8dc6..35af734 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java +++ b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java @@ -63,6 +63,7 @@ import org.apache.nifi.util.hive.HiveConfigurator; import org.apache.nifi.util.hive.HiveOptions; import org.apache.nifi.util.hive.HiveUtils; import org.apache.nifi.util.hive.HiveWriter; +import org.xerial.snappy.Snappy; import java.io.ByteArrayOutputStream; import java.io.File; @@ -137,6 +138,17 @@ public class PutHiveStreaming extends AbstractSessionFactoryProcessor { private static final Set<String> RESERVED_METADATA; static { + // This is used to prevent a race condition in Snappy 1.0.5 where two classloaders could + // try to define the native loader class at the same time, causing an error. Make a no-op + // call here to ensure Snappy's static initializers are called. Note that this block is + // called once by the extensions loader before any actual processor instances are created, + // so the race condition will not occur, and for each other instance, this is a no-op + try { + Snappy.compress(""); + } catch (IOException ioe) { + // Do nothing here, should never happen as it is intended to be a no-op + } + Set<String> reservedMetadata = new HashSet<>(); reservedMetadata.add("avro.schema"); reservedMetadata.add("avro.codec");
