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

Root cause eaten when hostname rejected by the parser of URI.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.2.8
    • Fix Version/s: None
    • Component/s: Transports
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      I'm using CXF (3.2.8 a bit old but the involved code seems always the same on master) to access the SOAP WebService WinRM on Windows Servers with the lib WinRM4J which use the org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit.

      I saw that the underscore character is not allowed in hostname (as describe in RFC 2396) but in the Active Directory DNS you can use underscore, so here in our private Cloud AzurePack it's possible to create a VM with an underscore in its hostname.

      When the WebService on a such VM is accessed the following exception is thrown :

      java.lang.IllegalStateException: Buffer already closed for writing
      	at org.apache.cxf.transport.http.asyncclient.SharedOutputBuffer.write(SharedOutputBuffer.java:229)
      	at org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit$AsyncWrappedOutputStream$1.write(AsyncHTTPConduit.java:436)
      	at org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:80)
      	at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:167)
      	at org.apache.cxf.io.CachedOutputStream.writeCacheTo(CachedOutputStream.java:314)
      	at org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit$AsyncWrappedOutputStream.close(AsyncHTTPConduit.java:415)
      	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
      	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:673)
      	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
      	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
      	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
      	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
      	at com.sun.proxy.$Proxy212.create(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at io.cloudsoft.winrm4j.client.RetryingProxyHandler.invokeWithRetry(RetryingProxyHandler.java:46)
      	at io.cloudsoft.winrm4j.client.RetryingProxyHandler.invoke(RetryingProxyHandler.java:34)
      	at com.sun.proxy.$Proxy213.create(Unknown Source)
      	at io.cloudsoft.winrm4j.client.WinRmClient.createShell(WinRmClient.java:485)
      	at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:335)
      	at com.carl.remote.winrm.WinrmConnection.execute(WinrmConnection.java:88)
      

      It's not the root cause, so it's a bit difficult to find out the problem.

      The root cause is in fact an IllegalArgumentException: Host name may not be null thrown by the HttpHost when it's instanciated by ​CXFHttpAsyncRequestProducer#getTarget().

      The hostname is null because the parsing do by the java.net.URI reject the underscore (but doesn't thrown an URISyntaxException).

      I have managed a workaround (you can see it on this branch https://github.com/zerikv/cxf/commits/fix-lost-exception-hostname-with-underscore) at the end of the connect() method in the inner class AsyncWrappedOutputStream of AsyncHTTPConduit so that IllegalArgumentException now goes back to the user.
      It's not even the real root cause but I think it's a little better than the Buffer already closed for writing message, at least it indicates that something is wrong with the hostname.

      For my initial problem (accept the hostnames with underscore because they exist I have meet them) the only solution I can find would be to replace the URI with the URL, but I guess it's not really an option.
      If someone see another way thank for advices.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                zerikv Eric Vernier
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

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