cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1035626 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/test/java/org/apache/cxf/transport/http/ systest...
Date Tue, 16 Nov 2010 13:03:34 GMT
Author: sergeyb
Date: Tue Nov 16 13:03:34 2010
New Revision: 1035626

URL: http://svn.apache.org/viewvc?rev=1035626&view=rev
Log:
Merged revisions 1035614 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1035614 | sergeyb | 2010-11-16 12:43:32 +0000 (Tue, 16 Nov 2010) | 1 line
  
  [CXF-3127] Updating HttpConduit to check a non-error input stream only in case of successful
requests
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.3.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 16 13:03:34 2010
@@ -1 +1 @@
-/cxf/trunk:1035559
+/cxf/trunk:1035559,1035614

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Nov 16 13:03:34 2010
@@ -1 +1 @@
-/cxf/trunk:1-1022155,1022157-1023401,1023420-1030540,1030542-1031074,1031076-1033529,1033531,1033533-1033888,1033890-1033925,1033927-1034174,1034637,1035203,1035206,1035220,1035302,1035377,1035391,1035428,1035559
+/cxf/trunk:1-1022155,1022157-1023401,1023420-1030540,1030542-1031074,1031076-1033529,1033531,1033533-1033888,1033890-1033925,1033927-1034174,1034637,1035203,1035206,1035220,1035302,1035377,1035391,1035428,1035559,1035614

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1035626&r1=1035625&r2=1035626&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Tue Nov 16 13:03:34 2010
@@ -601,6 +601,9 @@ public class AbstractClient implements C
         exchange.put(MessageObserver.class, new ClientMessageObserver(cfg));
         exchange.put(Endpoint.class, cfg.getConduitSelector().getEndpoint());
         exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
+        // no need for the underlying conduit to throw the IO exceptions in case of
+        // client requests returning error HTTP code, it can be overridden if really needed

+        exchange.put("org.apache.cxf.http.no_io_exceptions", true);
         m.setExchange(exchange);
         
         PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
@@ -614,6 +617,7 @@ public class AbstractClient implements C
             m.put(Message.INVOCATION_CONTEXT, context);
             m.putAll(cfg.getRequestContext());
             exchange.putAll(cfg.getRequestContext());
+            exchange.putAll(cfg.getResponseContext());
         }
         
         //setup conduit selector

Modified: cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1035626&r1=1035625&r2=1035626&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Tue Nov 16 13:03:34 2010
@@ -2281,12 +2281,20 @@ public class HTTPConduit 
                     }
                 }
             }
-            if (responseCode != HttpURLConnection.HTTP_NOT_FOUND) {
-                in = in == null
-                     ? connection.getErrorStream() == null
-                       ? connection.getInputStream()
-                       : connection.getErrorStream()
-                     : in;
+            if (in == null) {
+                if (responseCode >= HttpURLConnection.HTTP_BAD_REQUEST) {
+                    in = connection.getErrorStream();
+                    if (in == null) {
+                        try {
+                            // just in case - but this will most likely cause an exception
+                            in = connection.getInputStream();
+                        } catch (IOException ex) {
+                            // ignore
+                        }
+                    }
+                } else {
+                    in = connection.getInputStream();
+                }
             }
             // if (in == null) : it's perfectly ok for non-soap http services
             // have no response body : those interceptors which do need it will check anyway
       

Modified: cxf/branches/2.3.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java?rev=1035626&r1=1035625&r2=1035626&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
Tue Nov 16 13:03:34 2010
@@ -55,7 +55,7 @@ import org.junit.Test;
  */
 public class HTTPConduitURLEasyMockTest extends Assert {
     
-    private enum ResponseStyle { NONE, BACK_CHANNEL, DECOUPLED };
+    private enum ResponseStyle { NONE, BACK_CHANNEL, BACK_CHANNEL_ERROR, DECOUPLED };
     private enum ResponseDelimiter { LENGTH, CHUNKED, EOF };
 
     private static final String NOWHERE = "http://nada.nothing.nowhere.null/";
@@ -136,7 +136,18 @@ public class HTTPConduitURLEasyMockTest 
         message.put("Content-Type", "text/xml;charset=utf8");
         setUpHeaders(message);
         conduit.prepare(message);
-        verifySentMessage(conduit, message, true, "POST");
+        verifySentMessage(conduit, message, true, "POST", false);
+        finalVerify();
+    }
+    
+    public void testSendWithHeadersCheckErrorStream() throws Exception {
+        control = EasyMock.createNiceControl();
+        HTTPConduit conduit = setUpConduit(true, false);
+        Message message = new MessageImpl();
+        message.put("Content-Type", "text/xml;charset=utf8");
+        setUpHeaders(message);
+        conduit.prepare(message);
+        verifySentMessage(conduit, message, true, "POST", true);
         finalVerify();
     }
     
@@ -308,18 +319,19 @@ public class HTTPConduitURLEasyMockTest 
 
     private void verifySentMessage(HTTPConduit conduit, Message message, String method)
         throws IOException {
-        verifySentMessage(conduit, message, false, method);
+        verifySentMessage(conduit, message, false, method, false);
     }
 
     private void verifySentMessage(HTTPConduit conduit,
                                    Message message,
                                    boolean expectHeaders,
-                                   String method)
+                                   String method,
+                                   boolean errorExpected)
         throws IOException {
         verifySentMessage(conduit,
                           message,
                           expectHeaders, 
-                          ResponseStyle.BACK_CHANNEL,
+                          errorExpected ? ResponseStyle.BACK_CHANNEL_ERROR : ResponseStyle.BACK_CHANNEL,
                           method);
     }
 
@@ -396,9 +408,7 @@ public class HTTPConduitURLEasyMockTest 
         assertNotNull("expected in message", inMessage);
         Map<?, ?> headerMap = (Map<?, ?>) inMessage.get(Message.PROTOCOL_HEADERS);
         assertEquals("unexpected response headers", headerMap.size(), 0);
-        Integer expectedResponseCode = style == ResponseStyle.BACK_CHANNEL
-                                       ? HttpURLConnection.HTTP_OK
-                                       : HttpURLConnection.HTTP_ACCEPTED;
+        Integer expectedResponseCode = getResponseCode(style);
         assertEquals("unexpected response code",
                      expectedResponseCode,
                      inMessage.get(Message.RESPONSE_CODE));
@@ -472,9 +482,7 @@ public class HTTPConduitURLEasyMockTest 
                                       HTTPConduit conduit) throws IOException {
         connection.getHeaderFields();
         EasyMock.expectLastCall().andReturn(Collections.EMPTY_MAP).anyTimes();
-        int responseCode = style == ResponseStyle.BACK_CHANNEL
-                           ? HttpURLConnection.HTTP_OK
-                           : HttpURLConnection.HTTP_ACCEPTED;
+        int responseCode = getResponseCode(style);
         if (conduit.getClient().isAutoRedirect()) {
             connection.getResponseCode();
             EasyMock.expectLastCall().andReturn(301).once().andReturn(responseCode).anyTimes();
@@ -513,9 +521,12 @@ public class HTTPConduitURLEasyMockTest 
             break;
             
         case BACK_CHANNEL:
+            break;
+            
+        case BACK_CHANNEL_ERROR:
             connection.getErrorStream();
             EasyMock.expectLastCall().andReturn(null);
-            break;
+            break;    
             
         default:
             break;
@@ -528,5 +539,16 @@ public class HTTPConduitURLEasyMockTest 
             control = null;
         }
     }
-    
+
+    private int getResponseCode(ResponseStyle style) {
+        int code;
+        if (style == ResponseStyle.BACK_CHANNEL) {
+            code = HttpURLConnection.HTTP_OK; 
+        } else if (style == ResponseStyle.BACK_CHANNEL_ERROR) {
+            code = HttpURLConnection.HTTP_BAD_REQUEST; 
+        } else {
+            code = HttpURLConnection.HTTP_ACCEPTED;
+        }
+        return code;
+    }
 }

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1035626&r1=1035625&r2=1035626&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Tue Nov 16 13:03:34 2010
@@ -74,7 +74,7 @@ public class JAXRSSoapBookTest extends A
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerRestSoap.class, true));
+                   launchServer(BookServerRestSoap.class));
     }
     
     @Test
@@ -543,7 +543,7 @@ public class JAXRSSoapBookTest extends A
     @Test
     public void testServerFaultInInterceptor() throws Exception {
         //testing faults created by server handled correctly
-        serverFaultInInterceptorTest("321");
+        
         //999 causes error code of 404, 404 has a different code path so need to test too
         serverFaultInInterceptorTest("999");
         //322 causes a checked exception to be thrown so need to 
@@ -586,6 +586,7 @@ public class JAXRSSoapBookTest extends A
         features.add((AbstractFeature)testFeature);
         bean.setFeatures(features);
         BookStoreJaxrsJaxws proxy = (BookStoreJaxrsJaxws)bean.create();
+        WebClient.getConfig(proxy).getRequestContext().put("org.apache.cxf.http.no_io_exceptions",
false);
         try {
             //321 is special case - causes error code of 525
             proxy.getBook(new Long(param));



Mime
View raw message