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

NullPointerException in InvokeHTTP processor when trusted hostname property is used

    XMLWordPrintableJSON

Details

    Description

      When a user configures the InvokeHTTP processor with HTTPS (using an SSLContextService) and populates the trustedHostname property, the processor will throw a NullPointerException because the OkHttp client does not have a valid HostnameVerifier configured when the @OnScheduled method is called and that verifier is delegated to the processor. This results in the stacktrace below:

      2017-07-17 19:15:49,341 ERROR [Timer-Driven Process Thread-6] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=53784003-015d-1000-ffb0-e07173729c9c] Routing to Failure due to exception: java.lang.NullPointerException: java.lang.NullPointerException
      java.lang.NullPointerException: null
      	at org.apache.nifi.processors.standard.InvokeHTTP$OverrideHostnameVerifier.verify(InvokeHTTP.java:1050)
      	at com.squareup.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
      	at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:145)
      	at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:108)
      	at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
      	at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
      	at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
      	at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:283)
      	at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
      	at com.squareup.okhttp.Call.getResponse(Call.java:286)
      	at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
      	at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
      	at com.squareup.okhttp.Call.execute(Call.java:80)
      	at org.apache.nifi.processors.standard.InvokeHTTP.onTrigger(InvokeHTTP.java:630)
      	at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
      	at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1120)
      	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147)
      	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
      	at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:132)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      When that method is invoked, the existence of the HostnameVerifier should be checked before it is provided to the OverrideHostnameVerifier, and a default value of OkHostnameVerifier.INSTANCE (public static singleton) should be provided if none is available.

      Attachments

        1. flow_20170717-192339_trusted_hostname.xml
          14 kB
          Andy LoPresto
        2. Screen Shot 2018-07-12 at 3.29.50 PM.png
          262 kB
          Nathan Gough
        3. Screen Shot 2018-07-12 at 4.39.27 PM.png
          252 kB
          Nathan Gough

        Activity

          People

            thenatog Nathan Gough
            alopresto Andy LoPresto
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: