axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r647525 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/sample/ jaxws/src/org/apache/axis2/jaxws/handler/ jaxws/test/org/apache/axis2/jaxws/handler/
Date Sun, 13 Apr 2008 04:42:11 GMT
Author: gawor
Date: Sat Apr 12 21:42:09 2008
New Revision: 647525

URL: http://svn.apache.org/viewvc?rev=647525&view=rev
Log:
suppress exceptions on one-way invocations (AXIS2-3712)

Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
    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-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?rev=647525&r1=647524&r2=647525&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Sat Apr 12 21:42:09 2008
@@ -716,12 +716,13 @@
 
         } catch (Exception e) {
             e.printStackTrace();
-            fail();
+            fail(e.getMessage());
         }
         TestLogger.logger.debug("----------------------------------");
     }
     
     public void testOneWayWithProtocolException() {
+        Exception exception = null;
         try {
             TestLogger.logger.debug("----------------------------------");
             TestLogger.logger.debug("test: " + getName());
@@ -745,32 +746,35 @@
             bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
             // value 99 will trigger exception from AddNumbersClientLogicalHandler
             proxy.oneWayInt(99);
-            fail("Should have got an exception, but did not.");
-        } catch (Exception e) {
+        } catch (Exception e) {            
             e.printStackTrace();
-            assertEquals(e.getMessage(), "I don't like the value 99");
+            exception = e;
+        }
+        
+        // exceptions on one-way invocations are suppressed by default
+        assertNull(exception);
             
-            // one-way invocations run in their own thread,
-            // and we can't tell here in the client when it
-            // has completed.  So, we need to wait long enough
-            // for the invocation to complete, so our log file
-            // is fully populated.
-            try {
-                Thread.sleep(1000 * 5); // 5 seconds
-            } catch (InterruptedException ie) {
-                // nothing
-            }
+        // one-way invocations run in their own thread,
+        // and we can't tell here in the client when it
+        // has completed.  So, we need to wait long enough
+        // for the invocation to complete, so our log file
+        // is fully populated.
+        try {
+            Thread.sleep(1000 * 5); // 5 seconds
+        } catch (InterruptedException ie) {
+            // nothing
+        }
             
-            String log = readLogFile();
-            String expected_calls = "AddNumbersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+        String log = readLogFile();
+        String expected_calls = "AddNumbersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
                 + "AddNumbersClientLogicalHandler CLOSE\n";
-            assertEquals(expected_calls, log);
-            
-        }
+        assertEquals(expected_calls, log);
+                    
         TestLogger.logger.debug("----------------------------------");
     }
     
     public void testOneWayWithRuntimeException() {
+        Exception exception = null;
         try {
             TestLogger.logger.debug("----------------------------------");
             TestLogger.logger.debug("test: " + getName());
@@ -794,27 +798,30 @@
             bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
             // value 99 will trigger exception from AddNumbersClientLogicalHandler
             proxy.oneWayInt(999);
-            fail("Should have got an exception, but did not.");
         } catch (Exception e) {
             e.printStackTrace();
-            assertEquals(e.getMessage(), "I don't like the value 999");
+            exception = e;
+        }
+        
+        // exceptions on one-way invocations are suppressed by default
+        assertNull(exception);            
             
-            // one-way invocations run in their own thread,
-            // and we can't tell here in the client when it
-            // has completed.  So, we need to wait long enough
-            // for the invocation to complete, so our log file
-            // is fully populated.
-            try {
-                Thread.sleep(1000 * 5); // 5 seconds
-            } catch (InterruptedException ie) {
-                // nothing
-            }
+        // one-way invocations run in their own thread,
+        // and we can't tell here in the client when it
+        // has completed.  So, we need to wait long enough
+        // for the invocation to complete, so our log file
+        // is fully populated.
+        try {
+            Thread.sleep(1000 * 5); // 5 seconds
+        } catch (InterruptedException ie) {
+            // nothing
+        }
             
-            String log = readLogFile();
-            String expected_calls = "AddNumbersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+        String log = readLogFile();
+        String expected_calls = "AddNumbersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
                 + "AddNumbersClientLogicalHandler CLOSE\n";
-            assertEquals(expected_calls, log);
-        }
+        assertEquals(expected_calls, log);
+        
         TestLogger.logger.debug("----------------------------------");
     }
 
@@ -880,6 +887,11 @@
         return new StreamSource(fis);
     }
     
+    protected void setUp() {
+        File file = new File(filelogname);
+        file.delete();  // yes, delete for each retrieval, which should only happen once
per test
+    }
+    
     private String readLogFile() {
         try {
             FileReader fr = new FileReader(filelogname);
@@ -893,8 +905,6 @@
                 ret = ret.concat(line + "\n");
             }
             fr.close();
-            File file = new File(filelogname);
-            file.delete();  // yes, delete for each retrieval, which should only happen once
per test
             return ret;
         } catch (FileNotFoundException fnfe) {
             // it's possible the test does not actually call any handlers and therefore

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?rev=647525&r1=647524&r2=647525&view=diff
==============================================================================
--- 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
Sat Apr 12 21:42:09 2008
@@ -265,6 +265,14 @@
                 // a request that requires no response is a one-way message
                 // and we should only close whomever got invoked
                 callCloseHandlers(newStart_inclusive, newEnd, newDirection);
+                
+                // As according to the Sun "experts", exceptions raised by
+                // handlers in one way invocation are discarded. They
+                // are NOT propagated to the user code.
+                if (savedException != null) {
+                    log.warn("Exception thrown by a handler in one way invocation",
+                             savedException);
+                }
             }
             else {
                 // it's a response, so we can safely assume that 
@@ -275,12 +283,13 @@
                 } else {
                     callCloseHandlers(0, handlers.size() - 1, direction);
                 }
-            }
-            if (savedException != null) {
-                // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw 
-                // ProtocolException or any other runtime exception --> No 
-                // response" case.
-                throw savedException;
+ 
+                if (savedException != null) {
+                    // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw 
+                    // ProtocolException or any other runtime exception --> No 
+                    // response" case.
+                    throw savedException;
+                }
             }
         }
     }

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?rev=647525&r1=647524&r2=647525&view=diff
==============================================================================
--- 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
Sat Apr 12 21:42:09 2008
@@ -584,7 +584,7 @@
         } catch (ProtocolException pe) {
             e = pe;
         }
-        assertNotNull(e);
+        assertNull(e);
         // no handleFault calls
         assertEquals("S2m:S1m:L1m: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


Mime
View raw message