Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public boolean equals(HTTPClientPolicy p1, HTTPClientPolicy p2) {
&& (p1.isSetProxyServerPort() ? p1.getProxyServerPort() == p2.getProxyServerPort() : !p2
.isSetProxyServerPort())
&& p1.getProxyServerType().value().equals(p2.getProxyServerType().value())
&& (p1.getConnectionRequestTimeout() == p2.getConnectionRequestTimeout())
&& (p1.getReceiveTimeout() == p2.getReceiveTimeout())
&& StringUtils.equals(p1.getReferer(), p2.getReferer());

Expand Down Expand Up @@ -141,6 +142,11 @@ public HTTPClientPolicy intersect(HTTPClientPolicy p1, HTTPClientPolicy p2) {
} else if (p2.isSetConnectionTimeout()) {
p.setConnectionTimeout(p2.getConnectionTimeout());
}
if (p1.isSetConnectionRequestTimeout()) {
p.setConnectionRequestTimeout(p1.getConnectionRequestTimeout());
} else if (p2.isSetConnectionRequestTimeout()) {
p.setConnectionRequestTimeout(p2.getConnectionRequestTimeout());
}
if (p1.isSetReceiveTimeout()) {
p.setReceiveTimeout(p1.getReceiveTimeout());
} else if (p2.isSetReceiveTimeout()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.cxf.transport.http.policy;

import java.util.concurrent.ThreadLocalRandom;

import org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

Expand Down Expand Up @@ -46,6 +48,7 @@ public void testCompatibleClientPolicies() {

@Test
public void testIntersectClientPolicies() {
ThreadLocalRandom random = ThreadLocalRandom.current();
ClientPolicyCalculator calc = new ClientPolicyCalculator();
HTTPClientPolicy p1 = new HTTPClientPolicy();
HTTPClientPolicy p2 = new HTTPClientPolicy();
Expand All @@ -55,9 +58,22 @@ public void testIntersectClientPolicies() {
p = calc.intersect(p1, p2);
assertEquals("browser", p.getBrowserType());
p1.setBrowserType(null);
p1.setConnectionTimeout(10000L);

long connectionRequestTimeout = random.nextLong(0, 10000);
p1.setConnectionRequestTimeout(connectionRequestTimeout);
p = calc.intersect(p1, p2);
assertEquals(connectionRequestTimeout, p.getConnectionRequestTimeout());

long receiveTimeout = random.nextLong(0, 10000);
p1.setReceiveTimeout(receiveTimeout);
p = calc.intersect(p1, p2);
assertEquals(10000L, p.getConnectionTimeout());
assertEquals(receiveTimeout, p.getReceiveTimeout());

long connectionTimeout = random.nextLong(0, 10000);
p1.setConnectionTimeout(connectionTimeout);
p = calc.intersect(p1, p2);
assertEquals(connectionTimeout, p.getConnectionTimeout());

p1.setAllowChunking(false);
p2.setAllowChunking(false);
p = calc.intersect(p1, p2);
Expand Down