Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-12567

NPE in CuratorLeaderElectionManager.getLeadershipChangeCount

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.25.0
    • Core Framework
    • None

    Description

      Since NiFi 1.10, a NPE can happen in the code of CuratorLeaderElectionManager.getLeadershipChangeCount when trying to get diagnostic data for a NiFi node:

       

      ERROR org.apache.nifi.diagnostics.bootstrap.BootstrapDiagnosticsFactory: Failed to obtain diagnostics information from class org.apache.nifi.diagnostics.bootstrap.tasks.ClusterDiagnosticTask
      java.lang.NullPointerException: null
      	at org.apache.nifi.controller.leader.election.CuratorLeaderElectionManager.getLeadershipChangeCount(CuratorLeaderElectionManager.java:241)
      	at org.apache.nifi.diagnostics.bootstrap.tasks.ClusterDiagnosticTask.captureDump(ClusterDiagnosticTask.java:75)
      	at org.apache.nifi.diagnostics.bootstrap.BootstrapDiagnosticsFactory.create(BootstrapDiagnosticsFactory.java:58)
      	at org.apache.nifi.BootstrapListener.writeDiagnostics(BootstrapListener.java:288)
      	at org.apache.nifi.BootstrapListener.access$600(BootstrapListener.java:41)
      	at org.apache.nifi.BootstrapListener$Listener$1.run(BootstrapListener.java:240)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748) 

       

      The problematic line is here:

      https://github.com/apache/nifi/blob/support/nifi-1.x/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/leader/election/CuratorLeaderElectionManager.java#L241

      This problem does not exist in NiFi 2.x as we have a proper null check at

      https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-leader-election-shared/src/main/java/org/apache/nifi/controller/leader/election/TrackedLeaderElectionManager.java#L60

      This JIRA is to track the addition of a similar null check in the NiFi 1.x support line.

      Attachments

        Issue Links

          Activity

            People

              pvillard Pierre Villard
              pvillard Pierre Villard
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h