Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6408

HTTP Conduit throws NPE exception for "invalid" 401 HTTP response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.2, 3.1
    • 3.1.1, 3.0.6, 2.7.17
    • JAX-RS, Transports
    • None
    • Windows 7, JDK1.7.0_65, cxf-rt-transports-http: 3.0.x

    • Unknown

    Description

      Hi guys,

      In process of using RESTful client based on Apache CXF JAX-RS with activated auto-redirect option, I observed NPE on my logs. The short investigation shows that the problem was caused by Web Service side, that send "401 Unauthorized" HTTP response without "WWW-Authenticate" header.

      In this case, on HTTPConduit class when we try to handle retransmits (by auto-redirect option), we expect that response message MUST contains authentication header params, but map doesn't contain it. As a result we observe the following exception:

      2015-05-18 21:43:12,730 [WARN|org.apache.cxf.phase.PhaseInterceptorChain|LogUtils] Interceptor for

      {<TEST_SERVER>}

      WebClient has thrown exception, unwinding now
      java.lang.NullPointerException: NullPointerException invoking <TEST_SERVER>: null
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1359)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1348)
      at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
      at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:638)
      at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      at org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:619)
      at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1084)
      at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:883)
      at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:854)
      at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:320)
      at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:346)
      at com.edifecs.etools.xeserver.restful.client.transport.impl.Test.main(Test.java:40)
      Caused by: java.lang.NullPointerException
      at org.apache.cxf.transport.http.auth.HttpAuthHeader.<init>(HttpAuthHeader.java:52)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.authorizationRetransmit(HTTPConduit.java:1480)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.processRetransmit(HTTPConduit.java:1420)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRetransmits(HTTPConduit.java:1395)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1522)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1330)
      ... 11 more

      I understand that described case is invalid by server side, but I think it will be really cool if we write to log some more informative message.
      For example: "Authentication parameters is not specified by server. URI: <TEST_SERVER>".

      Thank you!

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            ParanoidUser Capt. Cutlass
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: