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

HTTPConduit reads response before it completes sending request

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 2.4
    • 2.4.1
    • Core
    • None

    Description

      Hi,

      In CXF 2.4, HTTP Conduit has a new debug log as below. However, this logging message can cause HTTPConduit reads the response before it completes sending request, and it results in an IOException in the client side.
      The reason is that the method connection.getContentType() will trigger httpconnect to send current data to the HttpServer and want the server to return the response, so the server thinks the client complete the whole request and the server just reply nothing and closes the http connection.

      Code in HttpConduit.java

              protected void onFirstWrite() throws IOException {
                  ...            
                  if (LOG.isLoggable(Level.FINE)) {
                      LOG.fine("Sending "
                          + connection.getRequestMethod() 
                          + " Message with Headers to " 
                          + connection.getURL()
                          + " Conduit :"
                          + conduitName
                          + "\nContent-Type: " + connection.getContentType() + "\n");
                  }
              }
      

      To reproduce the issue: please create a simple web service in cxf 2.4 and enable its debug log, and then use a generated proxy client to call the http service, then you can see the error below.

      David

      Exception:

      Caused by: java.io.IOException: IOException invoking http://localhost:7777/Hello: Stream is closed
      	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:1385)
      	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1370)
      	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
      	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:614)
      	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
      	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:484)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:414)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:269)
      	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
      	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
      	... 2 more
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            veaven David Liu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: