cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1438085 - in /cxf/branches/2.7.x-fixes/rt: transports/http/src/main/java/org/apache/cxf/transport/http/ transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ transports/http/src/test/java/org/apache/cxf/transport/http/po...
Date Thu, 24 Jan 2013 17:23:02 GMT
Author: dkulp
Date: Thu Jan 24 17:23:01 2013
New Revision: 1438085

URL: http://svn.apache.org/viewvc?rev=1438085&view=rev
Log:
Merged revisions 1438078 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1438078 | dkulp | 2013-01-24 12:18:29 -0500 (Thu, 24 Jan 2013) | 2 lines

  [CXF-4765] Intersect the policy timeouts a bit better

........

Modified:
    cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
    cxf/branches/2.7.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
    cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyDataEngineImpl.java

Modified: cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1438085&r1=1438084&r2=1438085&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Thu Jan 24 17:23:01 2013
@@ -808,16 +808,18 @@ public abstract class HTTPConduit 
     
     public HTTPClientPolicy getClient(Message message) {
         ClientPolicyCalculator cpc = new ClientPolicyCalculator();
-        HTTPClientPolicy messagePol = message.get(HTTPClientPolicy.class);
-        if (messagePol != null) {
-            return cpc.intersect(messagePol, clientSidePolicy);
+        HTTPClientPolicy pol = message.get(HTTPClientPolicy.class);
+        if (pol != null) {
+            pol = cpc.intersect(pol, clientSidePolicy);
+        } else {
+            pol = clientSidePolicy;
         }
 
         PolicyDataEngine policyDataEngine = bus.getExtension(PolicyDataEngine.class);
         if (policyDataEngine == null) {
-            return clientSidePolicy;
+            return pol;
         }
-        return policyDataEngine.getPolicy(message, clientSidePolicy, cpc);
+        return policyDataEngine.getPolicy(message, pol, cpc);
     }
 
     /**

Modified: cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java?rev=1438085&r1=1438084&r2=1438085&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/impl/ClientPolicyCalculator.java
Thu Jan 24 17:23:01 2013
@@ -136,11 +136,15 @@ public class ClientPolicyCalculator impl
             p.setProxyServerType(p2.getProxyServerType());
         }
         p.setReferer(StringUtils.combine(p1.getReferer(), p2.getReferer()));
-        if (p1.isSetConnectionTimeout() || p2.isSetConnectionTimeout()) {
-            p.setConnectionTimeout(Math.min(p1.getConnectionTimeout(), p2.getConnectionTimeout()));
-        }
-        if (p1.isSetReceiveTimeout() || p2.isSetReceiveTimeout()) {
-            p.setReceiveTimeout(Math.min(p1.getReceiveTimeout(), p2.getReceiveTimeout()));
+        if (p1.isSetConnectionTimeout()) {
+            p.setConnectionTimeout(p1.getConnectionTimeout());
+        } else if (p2.isSetConnectionTimeout()) {
+            p.setConnectionTimeout(p2.getConnectionTimeout());
+        }
+        if (p1.isSetReceiveTimeout()) {
+            p.setReceiveTimeout(p1.getReceiveTimeout());
+        } else if (p2.isSetReceiveTimeout()) {
+            p.setReceiveTimeout(p2.getReceiveTimeout());
         }
 
         return p;

Modified: cxf/branches/2.7.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java?rev=1438085&r1=1438084&r2=1438085&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/ClientPolicyCalculatorTest.java
Thu Jan 24 17:23:01 2013
@@ -76,5 +76,38 @@ public class ClientPolicyCalculatorTest 
         p1.setReceiveTimeout(10000L);
         assertTrue(!calc.equals(p1, p2));
     }
+    
+    @Test
+    public void testLongTimeouts() {
+        ClientPolicyCalculator calc = new ClientPolicyCalculator();
+        HTTPClientPolicy p1 = new HTTPClientPolicy();
+        HTTPClientPolicy p2 = new HTTPClientPolicy();
+        p2.setReceiveTimeout(120000);
+        p2.setConnectionTimeout(60000);
+        HTTPClientPolicy p = calc.intersect(p1, p2);
+        assertEquals(120000, p.getReceiveTimeout());
+        assertEquals(60000, p.getConnectionTimeout());
+        
+        p1 = new HTTPClientPolicy();
+        p2 = new HTTPClientPolicy();
+        p1.setReceiveTimeout(120000);
+        p1.setConnectionTimeout(60000);
+        p = calc.intersect(p1, p2);
+        assertEquals(120000, p.getReceiveTimeout());
+        assertEquals(60000, p.getConnectionTimeout());
+
+        p2.setReceiveTimeout(50000);
+        p2.setConnectionTimeout(20000);
+        p = calc.intersect(p1, p2);
+        //p1 should have priority
+        assertEquals(120000, p.getReceiveTimeout());
+        assertEquals(60000, p.getConnectionTimeout());
+
+        //reverse intersect
+        p = calc.intersect(p2, p1);
+        //p2 should have priority
+        assertEquals(50000, p.getReceiveTimeout());
+        assertEquals(20000, p.getConnectionTimeout());
+    }
 
 }

Modified: cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyDataEngineImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyDataEngineImpl.java?rev=1438085&r1=1438084&r2=1438085&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyDataEngineImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyDataEngineImpl.java
Thu Jan 24 17:23:01 2013
@@ -73,7 +73,9 @@ public class PolicyDataEngineImpl implem
     public <T> T getPolicy(Message message, T confPolicy, PolicyCalculator<T>
intersector) {
         List<T> policies = getPoliciesFromMessage(intersector.getDataClassName(), 
                                                   message, intersector.getDataClass());
-        policies.add(confPolicy);
+        if (!policies.contains(confPolicy)) {
+            policies.add(confPolicy); 
+        }
         return getPolicy(policies, intersector);
     }
 
@@ -132,8 +134,8 @@ public class PolicyDataEngineImpl implem
         for (T p : policies) {
             if (null == compatible) {
                 compatible = p;
-            } else {
-                compatible = intersector.intersect(compatible, p);
+            } else if (compatible != p) {
+                compatible = intersector.intersect(p, compatible);
                 if (null == compatible) {
                     logAndThrowPolicyException(p);
                 }



Mime
View raw message