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

ClientProxy concurrency close/destroy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 4.0.5
    • None
    • Core
    • None
    • Unknown

    Description

      Hello,

      There is a GC issue to do a missing reference on the `ClientProxy` that is holding the `ClientImpl`. Here is the code snippet we use:

      Object port = getPort();
      try(ClientImpl client = (ClientImpl)ClientProxy.getClient(port)) {
          //...
      }
      

      The problem resides in the method `ClientProxy.getClient` because the latter creates a `ClientProxy` instance and returns its internal `ClientImpl` but there is no more reference to the `ClientProxy` after the method returns... and under heavy load, we might hit either a Connection closed or even the following error (hit by chance after PR2140):

      Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
              at org.apache.cxf.transport.http.HttpClientHTTPConduit$HttpClientWrappedOutputStream.isConnectionAttemptCompleted(HttpClientHTTPConduit.java:780)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit$HttpClientPipedOutputStream.canWrite(HttpClientHTTPConduit.java:540)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit$HttpClientPipedOutputStream.write(HttpClientHTTPConduit.java:550)
              at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
              at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
              at java.base/java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:170)
              at ch.swissdec.jaxws.net.BufferedOutputStreamWrapper.sendBufferedContent(BufferedOutputStreamWrapper.java:37)
              at ch.swissdec.jaxws.net.BufferedOutputStreamWrapper.flush(BufferedOutputStreamWrapper.java:27)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit.close(HttpClientHTTPConduit.java:253)
              at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63)
              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
              at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
              at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:441)
              at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:356)
              at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:314)
              at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:334)
              at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
              ... 14 more
      Caused by: java.io.IOException: shutdownNow
              at java.net.http/jdk.internal.net.http.HttpClientImpl.shutdownNow(HttpClientImpl.java:622)
              at java.net.http/jdk.internal.net.http.HttpClientFacade.shutdownNow(HttpClientFacade.java:182)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit$RefCount.lambda$release$0(HttpClientHTTPConduit.java:143)
              at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit$RefCount.release(HttpClientHTTPConduit.java:138)
              at org.apache.cxf.transport.http.HttpClientHTTPConduit.close(HttpClientHTTPConduit.java:267)
              at org.apache.cxf.endpoint.AbstractConduitSelector.close(AbstractConduitSelector.java:77)
              at org.apache.cxf.endpoint.ClientImpl.destroy(ClientImpl.java:177)
              at org.apache.cxf.frontend.ClientProxy.close(ClientProxy.java:52)
              at org.apache.cxf.jaxws.JaxWsClientProxy.close(JaxWsClientProxy.java:84)
              at org.apache.cxf.frontend.ClientProxy.finalize(ClientProxy.java:123)
              at java.base/java.lang.System$2.invokeFinalize(System.java:2384)
              at java.base/java.lang.ref.Finalizer.runFinalizer(Finalizer.java:96)
              at java.base/java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)
      

      As a workaround, here is the code snipped we use now:

      Object port = getPort();
      ClientProxy proxy = ((ClientProxy)Proxy.getInvocationHandler(port));
      try(ClientImpl client = (ClientImpl)proxy.getClient()) {
          //...
      } finally {
          proxy.close();
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ctabin Cedric Tabin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: