Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2668#discussion_r185276958
--- Diff:
nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java
---
@@ -257,9 +260,63 @@ public final void abstractOnScheduled(ProcessContext
context) throws IOException
@OnStopped
public final void abstractOnStopped() {
+ final HdfsResources resources = hdfsResources.get();
+ if (resources != null) {
+ // Attempt to close the FileSystem
+ final FileSystem fileSystem = resources.getFileSystem();
+ try {
+ interruptStatisticsThread(fileSystem);
+ } catch (Exception e) {
+ getLogger().warn("Error stopping FileSystem statistics
thread: " + e.getMessage(), e);
+ } finally {
+ if (fileSystem != null) {
+ try {
+ fileSystem.close();
+ } catch (IOException e) {
+ getLogger().warn("Error close FileSystem: " +
e.getMessage(), e);
+ }
+ }
+ }
+
+ // Clean-up the static reference to the Configuration instance
+ UserGroupInformation.setConfiguration(new Configuration());
+
+ // Clean-up the reference to the InstanceClassLoader that was
put into Configuration
+ final Configuration configuration =
resources.getConfiguration();
+ configuration.setClassLoader(null);
+
+ // Need to remove the Provider instance from the JVM's
Providers class so that InstanceClassLoader can be GC'd eventually
+ final SaslPlainServer.SecurityProvider saslProvider = new
SaslPlainServer.SecurityProvider();
+ Security.removeProvider(saslProvider.getName());
+ }
+
+ // Clear out the reference to the resources
hdfsResources.set(new HdfsResources(null, null, null));
}
--- End diff --
You *could* use commons reflect here, but I'm not sure it matters
---