You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2013/02/26 23:55:08 UTC

svn commit: r1450509 - /cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java

Author: ay
Date: Tue Feb 26 22:55:08 2013
New Revision: 1450509

URL: http://svn.apache.org/r1450509
Log:
[CXF-4846] A confusing excpetion may be thrown from HTTPConduit when oneway call results in HTTP 500 resp (only for 2.6.x)

Modified:
    cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java

Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1450509&r1=1450508&r2=1450509&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Tue Feb 26 22:55:08 2013
@@ -1092,15 +1092,7 @@ public class HTTPConduit 
             return connection;
         }
         try {
-            //try and consume any content so that the connection might be reusable
-            InputStream ins = connection.getErrorStream();
-            if (ins == null) {
-                ins = connection.getInputStream();
-            }
-            if (ins != null) {
-                IOUtils.consume(ins);
-                ins.close();
-            }
+            closeInputStream(connection);
         } catch (Throwable t) {
             //ignore
         }
@@ -1630,7 +1622,10 @@ public class HTTPConduit 
                 if ((in == null) || (!doProcessResponse(outMessage))) {
                     // oneway operation or decoupled MEP without 
                     // partial response
-                    connection.getInputStream().close();
+                    closeInputStream(connection);
+                    if (isOneway(exchange) && responseCode > 300) {
+                        throw new HTTPException(responseCode, connection.getResponseMessage(), connection.getURL());
+                    }
                     ClientCallback cc = exchange.get(ClientCallback.class);
                     if (null != cc) {
                         //REVISIT move the decoupled destination property name into api
@@ -1764,6 +1759,18 @@ public class HTTPConduit 
         policyDataEngine.assertMessage(message, getClient(), new ClientPolicyCalculator());
     }
     
+    protected void closeInputStream(HttpURLConnection connection) throws IOException {
+        //try and consume any content so that the connection might be reusable
+        InputStream ins = connection.getErrorStream();
+        if (ins == null) {
+            ins = connection.getInputStream();
+        }
+        if (ins != null) {
+            IOUtils.consume(ins);
+            ins.close();
+        }
+    }
+
     public boolean canAssert(QName type) {
         return new ClientPolicyCalculator().equals(type);  
     }