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/11/17 02:25:44 UTC

svn commit: r881084 - in /cxf/branches/2.1.x-fixes: ./ rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java

Author: dkulp
Date: Tue Nov 17 01:25:44 2009
New Revision: 881084

URL: http://svn.apache.org/viewvc?rev=881084&view=rev
Log:
Merged revisions 881003 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes

................
  r881003 | dkulp | 2009-11-16 17:13:28 -0500 (Mon, 16 Nov 2009) | 12 lines
  
  Merged revisions 880991 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r880991 | dkulp | 2009-11-16 17:03:54 -0500 (Mon, 16 Nov 2009) | 4 lines
    
    [CXF-2537] Enhance the error messages on the client side for http
    conduits.
    
    Heavily modified patch from Cyrille Le Clerc applied.
  ........
................

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.1.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=881084&r1=881083&r2=881084&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Tue Nov 17 01:25:44 2009
@@ -1937,13 +1937,32 @@
             }
             try {
                 handleResponse();
+            } catch (IOException e) {
+                throw mapException(e.getClass().getSimpleName() 
+                                   + " invoking " + connection.getURL(), e,
+                                   IOException.class);
+            } catch (RuntimeException e) {
+                throw mapException(e.getClass().getSimpleName() 
+                                   + " invoking " + connection.getURL(), e,
+                                   RuntimeException.class);
             } finally {
                 if (cachingForRetransmission && cachedStream != null) {
                     cachedStream.close();
                 }
             }
         }
-        
+        private <T extends Exception> T mapException(String msg, T ex, Class<T> cls) {
+            T ex2 = ex;
+            try {
+                ex2 = cls.cast(ex.getClass().getConstructor(String.class).newInstance(msg));
+                ex2.initCause(ex);
+            } catch (Throwable e) {
+                ex2 = ex;
+            }
+            
+            
+            return ex2;
+        }
         
         /**
          * This procedure handles all retransmits, if any.
@@ -2060,7 +2079,8 @@
         
             
             if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
-                throw new IOException(connection.getResponseMessage());
+                throw new IOException("HTTP response '" + responseCode + ": " 
+                        + connection.getResponseMessage() + "'");
             }
 
             

Modified: cxf/branches/2.1.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?rev=881084&r1=881083&r2=881084&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Tue Nov 17 01:25:44 2009
@@ -153,6 +153,7 @@
             greeter.greetMe("cxf");
             fail("Didn't get the exception");
         } catch (Exception ex) {
+            ex.printStackTrace();
             assertTrue(ex.getCause().getClass().getName(), ex.getCause() instanceof SocketTimeoutException);
         }