You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ng...@apache.org on 2007/06/28 20:04:04 UTC

svn commit: r551641 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java

Author: ngallardo
Date: Thu Jun 28 11:04:03 2007
New Revision: 551641

URL: http://svn.apache.org/viewvc?view=rev&rev=551641
Log:
Handler.close() is not being called in the correct order for fault scenarios.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?view=diff&rev=551641&r1=551640&r2=551641
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Thu Jun 28 11:04:03 2007
@@ -44,9 +44,13 @@
 import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.utility.SAAJFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class HandlerChainProcessor {
 
+    private static final Log log = LogFactory.getLog(HandlerChainProcessor.class);
+    
     public enum Direction {
         IN, OUT
     };
@@ -296,12 +300,22 @@
         if (direction == Direction.OUT) {
             for (; i <= end; i++) {
                 switchContext(direction, i);
-				((Handler) handlers.get(i)).handleMessage(currentMC);
+                Handler handler = (Handler) handlers.get(i);
+                
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking handleMessage on: " + handler.getClass().getName());
+                }
+                handler.handleMessage(currentMC);
             }
         } else { // IN case
             for (; i >= end; i--) {
                 switchContext(direction, i);
-				((Handler) handlers.get(i)).handleMessage(currentMC);
+                Handler handler = (Handler) handlers.get(i);
+               
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking handleMessage on: " + handler.getClass().getName());
+                }
+                handler.handleMessage(currentMC);
             }
         }
     }
@@ -316,16 +330,33 @@
     private int handleMessage(Handler handler, Direction direction,
                               boolean expectResponse) throws RuntimeException {
         try {
+            if (log.isDebugEnabled()) {
+                log.debug("Invoking handleMessage on: " + handler.getClass().getName()); 
+            }
             boolean success = handler.handleMessage(currentMC);
-            if (success)
+            if (success) {
+                if (log.isDebugEnabled()) {
+                    log.debug("handleMessage() returned true");
+                }
                 return SUCCESSFUL;
+            }
             else {
+                if (log.isDebugEnabled()) {
+                    log.debug("handleMessage() returned false");
+                }
                 if (expectResponse)
                     currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
                                     (direction != Direction.OUT));
                 return FAILED;
             }
-        } catch (RuntimeException re) {  // RuntimeException and ProtocolException
+        } 
+        catch (RuntimeException re) { 
+            // RuntimeException and ProtocolException
+            if(log.isDebugEnabled()) {
+               log.debug("An exception was thrown during the handleMessage() invocation");
+               log.debug("Exception: " + re.getClass().getName() + ":" +re.getMessage());
+            }
+            
             savedException = re;
             if (expectResponse)
                 // mark it as reverse direction
@@ -355,24 +386,40 @@
             for (; i <= end; i++) {
                 try {
                     switchContext(direction, i);
-					((Handler) handlers.get(i)).close(currentMC);
+                    Handler handler = (Handler) handlers.get(i);
+                    if (log.isDebugEnabled()) {
+                        log.debug("Invoking close on: " + handler.getClass().getName());
+                    }
+                    handler.close(currentMC);
+                    
                     // TODO when we close, are we done with the handler instance, and thus
                     // may call the PreDestroy annotated method?  I don't think so, especially
                     // if we've cached the handler list somewhere.
                 } catch (Exception e) {
-                    // TODO: log it, but otherwise ignore
+                    if (log.isDebugEnabled()) {
+                        log.debug("An Exception occurred while calling handler.close()");
+                        log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage());
+                    }
                 }
             }
         } else { // IN case
             for (; i >= end; i--) {
                 try {
                     switchContext(direction, i);
-					((Handler) handlers.get(i)).close(currentMC);
-					// TODO when we close, are we done with the handler instance, and thus
+                    Handler handler = (Handler) handlers.get(i);
+                    if (log.isDebugEnabled()) {
+                        log.debug("Invoking close on: " + handler.getClass().getName());
+                    }
+                    handler.close(currentMC);
+                    
+                    // TODO when we close, are we done with the handler instance, and thus
                     // may call the PreDestroy annotated method?  I don't think so, especially
                     // if we've cached the handler list somewhere.
                 } catch (Exception e) {
-                    // TODO: log it, but otherwise ignore
+                    if (log.isDebugEnabled()) {
+                        log.debug("An Exception occurred while calling handler.close()");
+                        log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage());
+                    }
                 }
             }
         }
@@ -411,7 +458,7 @@
             // we can close all the Handlers in reverse order
             if (direction == Direction.OUT) {
                 initContext(Direction.IN);
-                callCloseHandlers(handlers.size() - 1, 0, Direction.IN);
+                callCloseHandlers(0, handlers.size() - 1, Direction.OUT);
             } else { // IN case
                 initContext(Direction.IN);
                 callCloseHandlers(0, handlers.size() - 1, Direction.OUT);
@@ -437,14 +484,24 @@
 
         if (direction == Direction.OUT) {
             for (; i <= end; i++) {
-                boolean success = ((Handler) handlers.get(i)).handleFault(currentMC);
+                Handler handler = (Handler) handlers.get(i);
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking handleFault on: " + handler.getClass().getName());
+                }
+                boolean success = handler.handleFault(currentMC);
+
                 if (!success)
                     break;
                 switchContext(direction, i + 1);
             }
         } else { // IN case
             for (; i >= end; i--) {
-                boolean success = ((Handler) handlers.get(i)).handleFault(currentMC);
+                Handler handler = (Handler) handlers.get(i);
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking handleFault on: " + handler.getClass().getName());
+                }
+                boolean success = handler.handleFault(currentMC);
+
                 if (!success)
                     break;
                 switchContext(direction, i - 1);

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java?view=diff&rev=551641&r1=551640&r2=551641
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java Thu Jun 28 11:04:03 2007
@@ -780,7 +780,7 @@
         mc1.setMEPContext(new MEPContext(mc1));
         processor.processFault(mc1.getMEPContext(), HandlerChainProcessor.Direction.OUT);
 
-        assertEquals("L2f:L1f:S1f:S2f:S2c:S1c:L1c:L2c:", result);
+        assertEquals("L2f:L1f:S1f:S2f:L2c:L1c:S1c:S2c:", result);
     }
 
     /*
@@ -809,7 +809,7 @@
         processor.processFault(mc1.getMEPContext(), HandlerChainProcessor.Direction.OUT);
 
         // notice all handlers are closed in this scenario
-        assertEquals("L2f:L1f:S2c:S1c:L1c:L2c:", result);
+        assertEquals("L2f:L1f:L2c:L1c:S1c:S2c:", result);
     }
 
     /*



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org