Author: ay
Date: Fri Mar  1 21:36:45 2013
New Revision: 1451723

URL: http://svn.apache.org/r1451723
Log:
Merged revisions 1450509 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1450509 | ay | 2013-02-26 23:55:08 +0100 (Tue, 26 Feb 2013) | 1 line
  
  [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.5.x-fixes/   (props changed)
    
cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java

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

Modified: 
cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1451723&r1=1451722&r2=1451723&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
 Fri Mar  1 21:36:45 2013
@@ -1071,15 +1071,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
         }
@@ -1613,7 +1605,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
@@ -1746,6 +1741,18 @@ public class HTTPConduit 
         PolicyUtils.assertClientPolicy(message, clientSidePolicy);
     }
     
+    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 PolicyUtils.HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(type);  
     }


Reply via email to