cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1306877 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/
Date Thu, 29 Mar 2012 14:18:06 GMT
Author: sergeyb
Date: Thu Mar 29 14:18:05 2012
New Revision: 1306877

URL: http://svn.apache.org/viewvc?rev=1306877&view=rev
Log:
[CXF-4154] Minor updates to JAX-RS AbstractClient and failover test

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1306877&r1=1306876&r2=1306877&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Thu Mar 29 14:18:05 2012
@@ -24,7 +24,6 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.net.HttpURLConnection;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -460,21 +459,22 @@ public abstract class AbstractClient imp
         return null;                                                
     }
     
-    protected void completeExchange(Object response, Exchange exchange) {
+    protected void completeExchange(Object response, Exchange exchange, boolean proxy) {
         // higher level conduits such as FailoverTargetSelector need to
         // clear the request state but a fair number of response objects 
         // depend on InputStream being still open thus lower-level conduits
         // operating on InputStream don't have to close streams pro-actively
         exchange.put(KEEP_CONDUIT_ALIVE, true);    
         getConfiguration().getConduitSelector().complete(exchange);
-        try {
-            String s = (String)exchange.getOutMessage().get(Message.BASE_PATH);
-            if (s != null) {
-                state.setBaseURI(new URI(s));
-            }
-        } catch (URISyntaxException e) {
-            //ignore
+        String s = (String)exchange.getOutMessage().get(Message.BASE_PATH);
+        if (s != null && !state.getBaseURI().toString().equals(s)) {
+            // usually the (failover) conduit change will result in a retry call
+            // which in turn will reset the base and current request URI.
+            // In some cases, such as the "upfront" load-balancing, etc, the retries
+            // won't be executed so it is necessary to reset the base address 
+            calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy);
         }
+        
     }
     
     protected Object[] preProcessResult(Message message) throws Exception {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1306877&r1=1306876&r2=1306877&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Thu Mar 29 14:18:05 2012
@@ -535,7 +535,7 @@ public class ClientProxyImpl extends Abs
             response = ex;
             throw ex;
         } finally {
-            completeExchange(response, outMessage.getExchange());
+            completeExchange(response, outMessage.getExchange(), true);
         }
         
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1306877&r1=1306876&r2=1306877&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Thu
Mar 29 14:18:05 2012
@@ -770,7 +770,7 @@ public class WebClient extends AbstractC
             entity = ex;
             throw ex;
         } finally {
-            completeExchange(entity, m.getExchange());
+            completeExchange(entity, m.getExchange(), false);
         }
     }
     

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1306877&r1=1306876&r2=1306877&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Thu Mar 29 14:18:05 2012
@@ -775,7 +775,8 @@ public class JAXRSClientServerBookTest e
         HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
         urlConnection.setReadTimeout(30000); // 30 seconds tops
         urlConnection.setConnectTimeout(30000); // 30 second tops
-        urlConnection.addRequestProperty("Content-Type", "MissingSeparator");
+        urlConnection.addRequestProperty("Content-Type", "xxx/xxx");
+        urlConnection.addRequestProperty("Accept", "*/*");
         urlConnection.setRequestMethod("POST");
         assertEquals(415, urlConnection.getResponseCode());
     }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java?rev=1306877&r1=1306876&r2=1306877&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
Thu Mar 29 14:18:05 2012
@@ -248,8 +248,8 @@ public class FailoverTest extends Abstra
         } 
         
         for (int i = 0; i < 20; i++) {
-            feature.getTargetSelector().close();
             if (!singleProxy) {
+                feature.getTargetSelector().close();
                 bookStore = getBookStore(inactiveReplica, feature);
             }
             verifyStrategy(bookStore, expectRandom 
@@ -344,7 +344,10 @@ public class FailoverTest extends Abstra
 
     
     protected String getCurrentEndpointAddress(Object client) {
-        return WebClient.client(client).getBaseURI().toString();
+        String currentBaseURI = WebClient.client(client).getBaseURI().toString();
+        String currentURI = WebClient.client(client).getCurrentURI().toString();
+        assertTrue(currentURI.startsWith(currentBaseURI));
+        return currentBaseURI;
     }
     
         



Mime
View raw message