Github user prasanthj commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2755#discussion_r194301151
--- Diff:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/main/java/org/apache/nifi/processors/hive/PutHive3Streaming.java
---
@@ -397,6 +398,9 @@ public void onTrigger(ProcessContext context,
ProcessSession session) throws Pro
}
hiveStreamingConnection = makeStreamingConnection(options,
reader);
+ // Add shutdown handler with higher priority than
FileSystem shutdown hook so that streaming connection gets closed first before
+ // filesystem close (to avoid ClosedChannelException)
+
ShutdownHookManager.addShutdownHook(hiveStreamingConnection::close,
FileSystem.SHUTDOWN_HOOK_PRIORITY + 1);
--- End diff --
You may also want to add uncaught exception handler as I have seen
instances where runtime exception or illegal state exception thrown by some
other code which if not caught can create broken files.
---