You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/03/11 22:03:24 UTC

svn commit: r752613 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java

Author: dkulp
Date: Wed Mar 11 21:03:24 2009
New Revision: 752613

URL: http://svn.apache.org/viewvc?rev=752613&view=rev
Log:
[CXF-2104] outgoing exceptions to async calls cause the client to hang.  Patch from Gyorgy Orban applied.

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java?rev=752613&r1=752612&r2=752613&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java Wed Mar 11 21:03:24 2009
@@ -19,29 +19,41 @@
 
 package org.apache.cxf.interceptor;
 
+import java.util.Map;
 import java.util.SortedSet;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.ClientCallback;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseManager;
 
 public class ClientOutFaultObserver extends AbstractFaultChainInitiatorObserver {
 
-    
     public ClientOutFaultObserver(Bus bus) {
         super(bus);
     }
-    
+
     @Override
     protected SortedSet<Phase> getPhases() {
         return getBus().getExtension(PhaseManager.class).getOutPhases();
     }
+
     /**
      * override the super class method
      */
     public void onMessage(Message m) {
-        // do nothing for exception occurred during client sending out request
+        Exception ex = m.getContent(Exception.class);
+        ClientCallback callback = m.getExchange().get(ClientCallback.class);
+
+        if (callback != null) {
+            Map<String, Object> resCtx = CastUtils.cast((Map<?, ?>) m.getExchange().getOutMessage().get(
+                    Message.INVOCATION_CONTEXT));
+            resCtx = CastUtils.cast((Map<?, ?>) resCtx.get(ClientImpl.RESPONSE_CONTEXT));
+            callback.handleException(resCtx, ex);
+        }
     }
 
     protected boolean isOutboundObserver() {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=752613&r1=752612&r2=752613&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Wed Mar 11 21:03:24 2009
@@ -275,6 +275,48 @@
                 notifyAll();
             }
         }
+
+        @Override
+        public void handleException(Map<String, Object> ctx, final Throwable ex) {
+            context = ctx;
+            exception = ex;
+            if (handler != null) {
+                handler.handleResponse(new Response<Object>() {
+
+                    public Map<String, Object> getContext() {
+                        return context;
+                    }
+
+                    public boolean cancel(boolean mayInterruptIfRunning) {
+                        cancelled = true;
+                        return true;
+                    }
+
+                    public Object get() throws InterruptedException, ExecutionException {
+                        throw new ExecutionException(ex);
+                    }
+
+                    public Object get(long timeout, TimeUnit unit) 
+                        throws InterruptedException, ExecutionException, TimeoutException {
+                        
+                        throw new ExecutionException(ex);
+                    }
+
+                    public boolean isCancelled() {
+                        return cancelled;
+                    }
+
+                    public boolean isDone() {
+                        return true;
+                    }
+
+                });
+            }
+            done = true;
+            synchronized (this) {
+                notifyAll();
+            }
+        }
     }
     static class ResponseCallback implements Response<Object> {
         ClientCallback callback;