You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2013/01/15 14:12:03 UTC
svn commit: r1433390 [2/3] - in /httpcomponents:
contrib/httpcore/trunk/src/main/java/org/apache/http/contrib/sip/
httpasyncclient/trunk/httpasyncclient-cache/src/main/java/org/apache/http/impl/client/cache/
httpasyncclient/trunk/httpasyncclient/src/ma...
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java Tue Jan 15 13:12:01 2013
@@ -110,14 +110,17 @@ public final class MultihomePlainSocketF
Args.notNull(host, "Target host");
Args.notNull(params, "HTTP parameters");
- if (sock == null)
- sock = createSocket();
+ if (sock == null) {
+ sock = createSocket();
+ }
if ((localAddress != null) || (localPort > 0)) {
// we need to bind explicitly
if (localPort < 0)
- localPort = 0; // indicates "any"
+ {
+ localPort = 0; // indicates "any"
+ }
InetSocketAddress isa =
new InetSocketAddress(localAddress, localPort);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java Tue Jan 15 13:12:01 2013
@@ -55,12 +55,13 @@ public class BasicRouteDirector implemen
int step = UNREACHABLE;
- if ((fact == null) || (fact.getHopCount() < 1))
- step = firstStep(plan);
- else if (plan.getHopCount() > 1)
- step = proxiedStep(plan, fact);
- else
- step = directStep(plan, fact);
+ if ((fact == null) || (fact.getHopCount() < 1)) {
+ step = firstStep(plan);
+ } else if (plan.getHopCount() > 1) {
+ step = proxiedStep(plan, fact);
+ } else {
+ step = directStep(plan, fact);
+ }
return step;
@@ -92,25 +93,30 @@ public class BasicRouteDirector implemen
*/
protected int directStep(RouteInfo plan, RouteInfo fact) {
- if (fact.getHopCount() > 1)
- return UNREACHABLE;
+ if (fact.getHopCount() > 1) {
+ return UNREACHABLE;
+ }
if (!plan.getTargetHost().equals(fact.getTargetHost()))
- return UNREACHABLE;
+ {
+ return UNREACHABLE;
// If the security is too low, we could now suggest to layer
// a secure protocol on the direct connection. Layering on direct
// connections has not been supported in HttpClient 3.x, we don't
// consider it here until there is a real-life use case for it.
+ }
// Should we tolerate if security is better than planned?
// (plan.isSecure() && !fact.isSecure())
- if (plan.isSecure() != fact.isSecure())
- return UNREACHABLE;
+ if (plan.isSecure() != fact.isSecure()) {
+ return UNREACHABLE;
+ }
// Local address has to match only if the plan specifies one.
if ((plan.getLocalAddress() != null) &&
!plan.getLocalAddress().equals(fact.getLocalAddress())
- )
- return UNREACHABLE;
+ ) {
+ return UNREACHABLE;
+ }
return COMPLETE;
}
@@ -127,38 +133,48 @@ public class BasicRouteDirector implemen
*/
protected int proxiedStep(RouteInfo plan, RouteInfo fact) {
- if (fact.getHopCount() <= 1)
- return UNREACHABLE;
- if (!plan.getTargetHost().equals(fact.getTargetHost()))
- return UNREACHABLE;
+ if (fact.getHopCount() <= 1) {
+ return UNREACHABLE;
+ }
+ if (!plan.getTargetHost().equals(fact.getTargetHost())) {
+ return UNREACHABLE;
+ }
final int phc = plan.getHopCount();
final int fhc = fact.getHopCount();
- if (phc < fhc)
- return UNREACHABLE;
+ if (phc < fhc) {
+ return UNREACHABLE;
+ }
for (int i=0; i<fhc-1; i++) {
- if (!plan.getHopTarget(i).equals(fact.getHopTarget(i)))
- return UNREACHABLE;
+ if (!plan.getHopTarget(i).equals(fact.getHopTarget(i))) {
+ return UNREACHABLE;
+ }
}
// now we know that the target matches and proxies so far are the same
if (phc > fhc)
- return TUNNEL_PROXY; // need to extend the proxy chain
+ {
+ return TUNNEL_PROXY; // need to extend the proxy chain
+ }
// proxy chain and target are the same, check tunnelling and layering
if ((fact.isTunnelled() && !plan.isTunnelled()) ||
- (fact.isLayered() && !plan.isLayered()))
- return UNREACHABLE;
-
- if (plan.isTunnelled() && !fact.isTunnelled())
- return TUNNEL_TARGET;
- if (plan.isLayered() && !fact.isLayered())
- return LAYER_PROTOCOL;
+ (fact.isLayered() && !plan.isLayered())) {
+ return UNREACHABLE;
+ }
+
+ if (plan.isTunnelled() && !fact.isTunnelled()) {
+ return TUNNEL_TARGET;
+ }
+ if (plan.isLayered() && !fact.isLayered()) {
+ return LAYER_PROTOCOL;
+ }
// tunnel and layering are the same, remains to check the security
// Should we tolerate if security is better than planned?
// (plan.isSecure() && !fact.isSecure())
- if (plan.isSecure() != fact.isSecure())
- return UNREACHABLE;
+ if (plan.isSecure() != fact.isSecure()) {
+ return UNREACHABLE;
+ }
return COMPLETE;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java Tue Jan 15 13:12:01 2013
@@ -101,10 +101,12 @@ public final class HttpRoute implements
Args.check(proxies.length > 0, "Proxy required if tunnelled");
}
// tunnelled is already checked above, that is in line with the default
- if (tunnelled == null)
- tunnelled = TunnelType.PLAIN;
- if (layered == null)
- layered = LayerType.PLAIN;
+ if (tunnelled == null) {
+ tunnelled = TunnelType.PLAIN;
+ }
+ if (layered == null) {
+ layered = LayerType.PLAIN;
+ }
this.targetHost = target;
this.localAddress = local;
@@ -212,8 +214,9 @@ public final class HttpRoute implements
* @return a proxy chain array, may be empty (never null)
*/
private static HttpHost[] toChain(HttpHost proxy) {
- if (proxy == null)
- return EMPTY_HTTP_HOST_ARRAY;
+ if (proxy == null) {
+ return EMPTY_HTTP_HOST_ARRAY;
+ }
return new HttpHost[]{ proxy };
}
@@ -228,8 +231,9 @@ public final class HttpRoute implements
* @return a new proxy chain array, may be empty (never null)
*/
private static HttpHost[] toChain(HttpHost[] proxies) {
- if ((proxies == null) || (proxies.length < 1))
- return EMPTY_HTTP_HOST_ARRAY;
+ if ((proxies == null) || (proxies.length < 1)) {
+ return EMPTY_HTTP_HOST_ARRAY;
+ }
// copy the proxy chain, the traditional way
HttpHost[] result = new HttpHost[proxies.length];
System.arraycopy(proxies, 0, result, 0, proxies.length);
@@ -262,10 +266,11 @@ public final class HttpRoute implements
Args.check(hop < hopcount, "Hop index exceeds tracked route length");
HttpHost result = null;
- if (hop < hopcount-1)
- result = this.proxyChain[hop];
- else
- result = this.targetHost;
+ if (hop < hopcount-1) {
+ result = this.proxyChain[hop];
+ } else {
+ result = this.targetHost;
+ }
return result;
}
@@ -311,7 +316,9 @@ public final class HttpRoute implements
*/
@Override
public final boolean equals(Object obj) {
- if (this == obj) return true;
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof HttpRoute) {
HttpRoute that = (HttpRoute) obj;
return
@@ -361,12 +368,15 @@ public final class HttpRoute implements
cab.append("->");
}
cab.append('{');
- if (this.tunnelled == TunnelType.TUNNELLED)
- cab.append('t');
- if (this.layered == LayerType.LAYERED)
- cab.append('l');
- if (this.secure)
- cab.append('s');
+ if (this.tunnelled == TunnelType.TUNNELLED) {
+ cab.append('t');
+ }
+ if (this.layered == LayerType.LAYERED) {
+ cab.append('l');
+ }
+ if (this.secure) {
+ cab.append('s');
+ }
cab.append("}->");
for (HttpHost aProxyChain : this.proxyChain) {
cab.append(aProxyChain);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java Tue Jan 15 13:12:01 2013
@@ -196,10 +196,11 @@ public final class RouteTracker implemen
public final int getHopCount() {
int hops = 0;
if (this.connected) {
- if (proxyChain == null)
- hops = 1;
- else
- hops = proxyChain.length + 1;
+ if (proxyChain == null) {
+ hops = 1;
+ } else {
+ hops = proxyChain.length + 1;
+ }
}
return hops;
}
@@ -209,10 +210,11 @@ public final class RouteTracker implemen
final int hopcount = getHopCount();
Args.check(hop < hopcount, "Hop index exceeds tracked route length");
HttpHost result = null;
- if (hop < hopcount-1)
- result = this.proxyChain[hop];
- else
- result = this.targetHost;
+ if (hop < hopcount-1) {
+ result = this.proxyChain[hop];
+ } else {
+ result = this.targetHost;
+ }
return result;
}
@@ -270,10 +272,12 @@ public final class RouteTracker implemen
*/
@Override
public final boolean equals(Object o) {
- if (o == this)
- return true;
- if (!(o instanceof RouteTracker))
- return false;
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof RouteTracker)) {
+ return false;
+ }
RouteTracker that = (RouteTracker) o;
return
@@ -327,14 +331,18 @@ public final class RouteTracker implemen
cab.append("->");
}
cab.append('{');
- if (this.connected)
- cab.append('c');
- if (this.tunnelled == TunnelType.TUNNELLED)
- cab.append('t');
- if (this.layered == LayerType.LAYERED)
- cab.append('l');
- if (this.secure)
- cab.append('s');
+ if (this.connected) {
+ cab.append('c');
+ }
+ if (this.tunnelled == TunnelType.TUNNELLED) {
+ cab.append('t');
+ }
+ if (this.layered == LayerType.LAYERED) {
+ cab.append('l');
+ }
+ if (this.secure) {
+ cab.append('s');
+ }
cab.append("}->");
if (this.proxyChain != null) {
for (HttpHost element : this.proxyChain) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java Tue Jan 15 13:12:01 2013
@@ -237,7 +237,9 @@ public final class Scheme {
@Override
public final boolean equals(Object obj) {
- if (this == obj) return true;
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof Scheme) {
Scheme that = (Scheme) obj;
return this.name.equals(that.name)
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java Tue Jan 15 13:12:01 2013
@@ -79,8 +79,12 @@ class SchemeSocketFactoryAdaptor impleme
@Override
public boolean equals(final Object obj) {
- if (obj == null) return false;
- if (this == obj) return true;
+ if (obj == null) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof SchemeSocketFactoryAdaptor) {
return this.factory.equals(((SchemeSocketFactoryAdaptor)obj).factory);
} else {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java Tue Jan 15 13:12:01 2013
@@ -83,8 +83,12 @@ class SocketFactoryAdaptor implements So
@Override
public boolean equals(final Object obj) {
- if (obj == null) return false;
- if (this == obj) return true;
+ if (obj == null) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof SocketFactoryAdaptor) {
return this.factory.equals(((SocketFactoryAdaptor)obj).factory);
} else {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java Tue Jan 15 13:12:01 2013
@@ -161,14 +161,17 @@ public abstract class GGSSchemeBase exte
} catch (GSSException gsse) {
state = State.FAILED;
if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
- || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
- throw new InvalidCredentialsException(gsse.getMessage(), gsse);
- if (gsse.getMajor() == GSSException.NO_CRED )
- throw new InvalidCredentialsException(gsse.getMessage(), gsse);
+ || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED) {
+ throw new InvalidCredentialsException(gsse.getMessage(), gsse);
+ }
+ if (gsse.getMajor() == GSSException.NO_CRED ) {
+ throw new InvalidCredentialsException(gsse.getMessage(), gsse);
+ }
if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
|| gsse.getMajor() == GSSException.DUPLICATE_TOKEN
- || gsse.getMajor() == GSSException.OLD_TOKEN)
- throw new AuthenticationException(gsse.getMessage(), gsse);
+ || gsse.getMajor() == GSSException.OLD_TOKEN) {
+ throw new AuthenticationException(gsse.getMessage(), gsse);
+ }
// other error
throw new AuthenticationException(gsse.getMessage());
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java Tue Jan 15 13:12:01 2013
@@ -185,8 +185,9 @@ final class NTLMEngineImpl implements NT
/** Strip dot suffix from a name */
private static String stripDotSuffix(String value) {
int index = value.indexOf(".");
- if (index != -1)
- return value.substring(0, index);
+ if (index != -1) {
+ return value.substring(0, index);
+ }
return value;
}
@@ -201,24 +202,27 @@ final class NTLMEngineImpl implements NT
}
private static int readULong(byte[] src, int index) throws NTLMEngineException {
- if (src.length < index + 4)
- throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
+ if (src.length < index + 4) {
+ throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
+ }
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8)
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}
private static int readUShort(byte[] src, int index) throws NTLMEngineException {
- if (src.length < index + 2)
- throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
+ if (src.length < index + 2) {
+ throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
+ }
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
private static byte[] readSecurityBuffer(byte[] src, int index) throws NTLMEngineException {
int length = readUShort(src, index);
int offset = readULong(src, index + 4);
- if (src.length < offset + length)
- throw new NTLMEngineException(
+ if (src.length < offset + length) {
+ throw new NTLMEngineException(
"NTLM authentication - buffer too small for data item");
+ }
byte[] buffer = new byte[length];
System.arraycopy(src, offset, buffer, 0, length);
return buffer;
@@ -299,56 +303,63 @@ final class NTLMEngineImpl implements NT
/** Calculate and return client challenge */
public byte[] getClientChallenge()
throws NTLMEngineException {
- if (clientChallenge == null)
- clientChallenge = makeRandomChallenge();
+ if (clientChallenge == null) {
+ clientChallenge = makeRandomChallenge();
+ }
return clientChallenge;
}
/** Calculate and return random secondary key */
public byte[] getSecondaryKey()
throws NTLMEngineException {
- if (secondaryKey == null)
- secondaryKey = makeSecondaryKey();
+ if (secondaryKey == null) {
+ secondaryKey = makeSecondaryKey();
+ }
return secondaryKey;
}
/** Calculate and return the LMHash */
public byte[] getLMHash()
throws NTLMEngineException {
- if (lmHash == null)
- lmHash = lmHash(password);
+ if (lmHash == null) {
+ lmHash = lmHash(password);
+ }
return lmHash;
}
/** Calculate and return the LMResponse */
public byte[] getLMResponse()
throws NTLMEngineException {
- if (lmResponse == null)
- lmResponse = lmResponse(getLMHash(),challenge);
+ if (lmResponse == null) {
+ lmResponse = lmResponse(getLMHash(),challenge);
+ }
return lmResponse;
}
/** Calculate and return the NTLMHash */
public byte[] getNTLMHash()
throws NTLMEngineException {
- if (ntlmHash == null)
- ntlmHash = ntlmHash(password);
+ if (ntlmHash == null) {
+ ntlmHash = ntlmHash(password);
+ }
return ntlmHash;
}
/** Calculate and return the NTLMResponse */
public byte[] getNTLMResponse()
throws NTLMEngineException {
- if (ntlmResponse == null)
- ntlmResponse = lmResponse(getNTLMHash(),challenge);
+ if (ntlmResponse == null) {
+ ntlmResponse = lmResponse(getNTLMHash(),challenge);
+ }
return ntlmResponse;
}
/** Calculate the NTLMv2 hash */
public byte[] getNTLMv2Hash()
throws NTLMEngineException {
- if (ntlmv2Hash == null)
- ntlmv2Hash = ntlmv2Hash(target, user, password);
+ if (ntlmv2Hash == null) {
+ ntlmv2Hash = ntlmv2Hash(target, user, password);
+ }
return ntlmv2Hash;
}
@@ -371,32 +382,36 @@ final class NTLMEngineImpl implements NT
/** Calculate the NTLMv2Blob */
public byte[] getNTLMv2Blob()
throws NTLMEngineException {
- if (ntlmv2Blob == null)
- ntlmv2Blob = createBlob(getClientChallenge(), targetInformation, getTimestamp());
+ if (ntlmv2Blob == null) {
+ ntlmv2Blob = createBlob(getClientChallenge(), targetInformation, getTimestamp());
+ }
return ntlmv2Blob;
}
/** Calculate the NTLMv2Response */
public byte[] getNTLMv2Response()
throws NTLMEngineException {
- if (ntlmv2Response == null)
- ntlmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getNTLMv2Blob());
+ if (ntlmv2Response == null) {
+ ntlmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getNTLMv2Blob());
+ }
return ntlmv2Response;
}
/** Calculate the LMv2Response */
public byte[] getLMv2Response()
throws NTLMEngineException {
- if (lmv2Response == null)
- lmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getClientChallenge());
+ if (lmv2Response == null) {
+ lmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getClientChallenge());
+ }
return lmv2Response;
}
/** Get NTLM2SessionResponse */
public byte[] getNTLM2SessionResponse()
throws NTLMEngineException {
- if (ntlm2SessionResponse == null)
- ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(),challenge,getClientChallenge());
+ if (ntlm2SessionResponse == null) {
+ ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(),challenge,getClientChallenge());
+ }
return ntlm2SessionResponse;
}
@@ -557,8 +572,9 @@ final class NTLMEngineImpl implements NT
System.arraycopy(digest, 0, sessionHash, 0, 8);
return lmResponse(ntlmHash, sessionHash);
} catch (Exception e) {
- if (e instanceof NTLMEngineException)
- throw (NTLMEngineException) e;
+ if (e instanceof NTLMEngineException) {
+ throw (NTLMEngineException) e;
+ }
throw new NTLMEngineException(e.getMessage(), e);
}
}
@@ -802,21 +818,24 @@ final class NTLMEngineImpl implements NT
messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody,
DEFAULT_CHARSET));
// Look for NTLM message
- if (messageContents.length < SIGNATURE.length)
- throw new NTLMEngineException("NTLM message decoding error - packet too short");
+ if (messageContents.length < SIGNATURE.length) {
+ throw new NTLMEngineException("NTLM message decoding error - packet too short");
+ }
int i = 0;
while (i < SIGNATURE.length) {
- if (messageContents[i] != SIGNATURE[i])
- throw new NTLMEngineException(
+ if (messageContents[i] != SIGNATURE[i]) {
+ throw new NTLMEngineException(
"NTLM message expected - instead got unrecognized bytes");
+ }
i++;
}
// Check to be sure there's a type 2 message indicator next
int type = readULong(SIGNATURE.length);
- if (type != expectedType)
- throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType)
+ if (type != expectedType) {
+ throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType)
+ " message expected - instead got type " + Integer.toString(type));
+ }
currentOutputPosition = messageContents.length;
}
@@ -836,15 +855,17 @@ final class NTLMEngineImpl implements NT
/** Read a byte from a position within the message buffer */
protected byte readByte(int position) throws NTLMEngineException {
- if (messageContents.length < position + 1)
- throw new NTLMEngineException("NTLM: Message too short");
+ if (messageContents.length < position + 1) {
+ throw new NTLMEngineException("NTLM: Message too short");
+ }
return messageContents[position];
}
/** Read a bunch of bytes from a position in the message buffer */
protected void readBytes(byte[] buffer, int position) throws NTLMEngineException {
- if (messageContents.length < position + buffer.length)
- throw new NTLMEngineException("NTLM: Message too short");
+ if (messageContents.length < position + buffer.length) {
+ throw new NTLMEngineException("NTLM: Message too short");
+ }
System.arraycopy(messageContents, position, buffer, 0, buffer.length);
}
@@ -1062,10 +1083,11 @@ final class NTLMEngineImpl implements NT
flags = readULong(20);
- if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0)
- throw new NTLMEngineException(
+ if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
+ throw new NTLMEngineException(
"NTLM type 2 message has flags that make no sense: "
+ Integer.toString(flags));
+ }
// Do the target!
target = null;
@@ -1156,31 +1178,35 @@ final class NTLMEngineImpl implements NT
// NTLMv2
ntResp = gen.getNTLMv2Response();
lmResp = gen.getLMv2Response();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0)
- userSessionKey = gen.getLanManagerSessionKey();
- else
- userSessionKey = gen.getNTLMv2UserSessionKey();
+ if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
+ userSessionKey = gen.getLanManagerSessionKey();
+ } else {
+ userSessionKey = gen.getNTLMv2UserSessionKey();
+ }
} else {
// NTLMv1
if ((type2Flags & FLAG_REQUEST_NTLM2_SESSION) != 0) {
// NTLM2 session stuff is requested
ntResp = gen.getNTLM2SessionResponse();
lmResp = gen.getLM2SessionResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0)
- userSessionKey = gen.getLanManagerSessionKey();
- else
- userSessionKey = gen.getNTLM2SessionResponseUserSessionKey();
+ if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
+ userSessionKey = gen.getLanManagerSessionKey();
+ }
+ else {
+ userSessionKey = gen.getNTLM2SessionResponseUserSessionKey();
// All the other flags we send (signing, sealing, key
// exchange) are supported, but they don't do anything
// at all in an
// NTLM2 context! So we're done at this point.
+ }
} else {
ntResp = gen.getNTLMResponse();
lmResp = gen.getLMResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0)
- userSessionKey = gen.getLanManagerSessionKey();
- else
- userSessionKey = gen.getNTLMUserSessionKey();
+ if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
+ userSessionKey = gen.getLanManagerSessionKey();
+ } else {
+ userSessionKey = gen.getNTLMUserSessionKey();
+ }
}
}
} catch (NTLMEngineException e) {
@@ -1188,16 +1214,18 @@ final class NTLMEngineImpl implements NT
// fail back to just using LM
ntResp = new byte[0];
lmResp = gen.getLMResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0)
- userSessionKey = gen.getLanManagerSessionKey();
- else
- userSessionKey = gen.getLMUserSessionKey();
+ if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
+ userSessionKey = gen.getLanManagerSessionKey();
+ } else {
+ userSessionKey = gen.getLMUserSessionKey();
+ }
}
- if ((type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) != 0)
- sessionKey = RC4(gen.getSecondaryKey(), userSessionKey);
- else
- sessionKey = null;
+ if ((type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) != 0) {
+ sessionKey = RC4(gen.getSecondaryKey(), userSessionKey);
+ } else {
+ sessionKey = null;
+ }
try {
domainBytes = domain.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked");
@@ -1218,10 +1246,11 @@ final class NTLMEngineImpl implements NT
int hostLen = hostBytes.length;
int userLen = userBytes.length;
int sessionKeyLen;
- if (sessionKey != null)
- sessionKeyLen = sessionKey.length;
- else
- sessionKeyLen = 0;
+ if (sessionKey != null) {
+ sessionKeyLen = sessionKey.length;
+ } else {
+ sessionKeyLen = 0;
+ }
// Calculate the layout within the packet
int lmRespOffset = 72; // allocate space for the version
@@ -1319,8 +1348,9 @@ final class NTLMEngineImpl implements NT
addBytes(domainBytes);
addBytes(userBytes);
addBytes(hostBytes);
- if (sessionKey != null)
- addBytes(sessionKey);
+ if (sessionKey != null) {
+ addBytes(sessionKey);
+ }
return super.getResponse();
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java Tue Jan 15 13:12:01 2013
@@ -87,14 +87,18 @@ public class AIMDBackoffManager implemen
int curr = connPerRoute.getMaxPerRoute(route);
Long lastUpdate = getLastUpdate(lastRouteBackoffs, route);
long now = clock.getCurrentTime();
- if (now - lastUpdate.longValue() < coolDown) return;
+ if (now - lastUpdate.longValue() < coolDown) {
+ return;
+ }
connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr));
lastRouteBackoffs.put(route, Long.valueOf(now));
}
}
private int getBackedOffPoolSize(int curr) {
- if (curr <= 1) return 1;
+ if (curr <= 1) {
+ return 1;
+ }
return (int)(Math.floor(backoffFactor * curr));
}
@@ -105,8 +109,9 @@ public class AIMDBackoffManager implemen
Long lastProbe = getLastUpdate(lastRouteProbes, route);
Long lastBackoff = getLastUpdate(lastRouteBackoffs, route);
long now = clock.getCurrentTime();
- if (now - lastProbe.longValue() < coolDown || now - lastBackoff.longValue() < coolDown)
- return;
+ if (now - lastProbe.longValue() < coolDown || now - lastBackoff.longValue() < coolDown) {
+ return;
+ }
connPerRoute.setMaxPerRoute(route, max);
lastRouteProbes.put(route, Long.valueOf(now));
}
@@ -114,7 +119,9 @@ public class AIMDBackoffManager implemen
private Long getLastUpdate(Map<HttpRoute,Long> updates, HttpRoute route) {
Long lastUpdate = updates.get(route);
- if (lastUpdate == null) lastUpdate = Long.valueOf(0L);
+ if (lastUpdate == null) {
+ lastUpdate = Long.valueOf(0L);
+ }
return lastUpdate;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java Tue Jan 15 13:12:01 2013
@@ -840,8 +840,12 @@ public abstract class AbstractHttpClient
if (connectionBackoffStrategy.shouldBackoff(e)) {
backoffManager.backOff(route);
}
- if (e instanceof HttpException) throw (HttpException)e;
- if (e instanceof IOException) throw (IOException)e;
+ if (e instanceof HttpException) {
+ throw (HttpException)e;
+ }
+ if (e instanceof IOException) {
+ throw (IOException)e;
+ }
throw new UndeclaredThrowableException(e);
}
if (connectionBackoffStrategy.shouldBackoff(out)) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java Tue Jan 15 13:12:01 2013
@@ -147,7 +147,9 @@ public class DecompressingHttpClient imp
public HttpResponse execute(HttpHost target, HttpRequest request,
HttpContext context) throws IOException, ClientProtocolException {
try {
- if (context == null) context = new BasicHttpContext();
+ if (context == null) {
+ context = new BasicHttpContext();
+ }
HttpRequest wrapped;
if (request instanceof HttpEntityEnclosingRequest) {
wrapped = new EntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request);
@@ -205,7 +207,9 @@ public class DecompressingHttpClient imp
return responseHandler.handleResponse(response);
} finally {
HttpEntity entity = response.getEntity();
- if (entity != null) EntityUtils.consume(entity);
+ if (entity != null) {
+ EntityUtils.consume(entity);
+ }
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java Tue Jan 15 13:12:01 2013
@@ -562,8 +562,9 @@ public class DefaultRequestDirector impl
if ((response == null) || (response.getEntity() == null) ||
!response.getEntity().isStreaming()) {
// connection not needed and (assumed to be) in re-usable state
- if (reuse)
- managedConn.markReusable();
+ if (reuse) {
+ managedConn.markReusable();
+ }
releaseConnection();
} else {
// install an auto-release entity
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java Tue Jan 15 13:12:01 2013
@@ -158,18 +158,21 @@ public abstract class AbstractClientConn
public boolean isOpen() {
OperatedClientConnection conn = getWrappedConnection();
- if (conn == null)
- return false;
+ if (conn == null) {
+ return false;
+ }
return conn.isOpen();
}
public boolean isStale() {
- if (isReleased())
- return true;
- OperatedClientConnection conn = getWrappedConnection();
- if (conn == null)
- return true;
+ if (isReleased()) {
+ return true;
+ }
+ OperatedClientConnection conn = getWrappedConnection();
+ if (conn == null) {
+ return true;
+ }
return conn.isStale();
}
@@ -273,16 +276,18 @@ public abstract class AbstractClientConn
public Socket getSocket() {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
- if (!isOpen())
- return null;
+ if (!isOpen()) {
+ return null;
+ }
return conn.getSocket();
}
public SSLSession getSSLSession() {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
- if (!isOpen())
- return null;
+ if (!isOpen()) {
+ return null;
+ }
SSLSession result = null;
Socket sock = conn.getSocket();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java Tue Jan 15 13:12:01 2013
@@ -150,8 +150,9 @@ public abstract class AbstractPooledConn
public void close() throws IOException {
AbstractPoolEntry entry = getPoolEntry();
- if (entry != null)
- entry.shutdownEntry();
+ if (entry != null) {
+ entry.shutdownEntry();
+ }
OperatedClientConnection conn = getWrappedConnection();
if (conn != null) {
@@ -161,8 +162,9 @@ public abstract class AbstractPooledConn
public void shutdown() throws IOException {
AbstractPoolEntry entry = getPoolEntry();
- if (entry != null)
- entry.shutdownEntry();
+ if (entry != null) {
+ entry.shutdownEntry();
+ }
OperatedClientConnection conn = getWrappedConnection();
if (conn != null) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java Tue Jan 15 13:12:01 2013
@@ -156,8 +156,9 @@ public class DefaultClientConnection ext
log.debug("Connection " + this + " shut down");
}
Socket sock = this.socket; // copy volatile attribute
- if (sock != null)
- sock.close();
+ if (sock != null) {
+ sock.close();
+ }
} catch (IOException ex) {
log.debug("I/O error shutting down connection", ex);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java Tue Jan 15 13:12:01 2013
@@ -88,8 +88,9 @@ public class DefaultHttpRoutePlanner imp
// If we have a forced route, we can do without a target.
HttpRoute route =
ConnRouteParams.getForcedRoute(request.getParams());
- if (route != null)
- return route;
+ if (route != null) {
+ return route;
+ }
// If we get here, there is no forced route.
// So we need a target to compute a route.
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java Tue Jan 15 13:12:01 2013
@@ -124,8 +124,9 @@ public class ProxySelectorRoutePlanner i
// If we have a forced route, we can do without a target.
HttpRoute route =
ConnRouteParams.getForcedRoute(request.getParams());
- if (route != null)
- return route;
+ if (route != null) {
+ return route;
+ }
// If we get here, there is no forced route.
// So we need a target to compute a route.
@@ -169,10 +170,12 @@ public class ProxySelectorRoutePlanner i
// the proxy selector can be 'unset', so we better deal with null here
ProxySelector psel = this.proxySelector;
- if (psel == null)
- psel = ProxySelector.getDefault();
- if (psel == null)
- return null;
+ if (psel == null) {
+ psel = ProxySelector.getDefault();
+ }
+ if (psel == null) {
+ return null;
+ }
URI targetURI = null;
try {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java Tue Jan 15 13:12:01 2013
@@ -243,8 +243,9 @@ public class SingleClientConnManager imp
}
}
- if (recreate)
- uniquePoolEntry = new PoolEntry();
+ if (recreate) {
+ uniquePoolEntry = new PoolEntry();
+ }
managedConn = new ConnAdapter(uniquePoolEntry, route);
@@ -266,7 +267,9 @@ public class SingleClientConnManager imp
ConnAdapter sca = (ConnAdapter) conn;
synchronized (sca) {
if (sca.poolEntry == null)
- return; // already released
+ {
+ return; // already released
+ }
ClientConnectionManager manager = sca.getManager();
Asserts.check(manager == this, "Connection not obtained from this manager");
try {
@@ -285,18 +288,20 @@ public class SingleClientConnManager imp
sca.shutdown();
}
} catch (IOException iox) {
- if (log.isDebugEnabled())
- log.debug("Exception shutting down released connection.",
+ if (log.isDebugEnabled()) {
+ log.debug("Exception shutting down released connection.",
iox);
+ }
} finally {
sca.detach();
synchronized (this) {
managedConn = null;
lastReleaseTime = System.currentTimeMillis();
- if(validDuration > 0)
- connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime;
- else
- connectionExpiresTime = Long.MAX_VALUE;
+ if(validDuration > 0) {
+ connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime;
+ } else {
+ connectionExpiresTime = Long.MAX_VALUE;
+ }
}
}
}
@@ -335,8 +340,9 @@ public class SingleClientConnManager imp
this.isShutDown = true;
synchronized (this) {
try {
- if (uniquePoolEntry != null) // and connection open?
- uniquePoolEntry.shutdown();
+ if (uniquePoolEntry != null) {
+ uniquePoolEntry.shutdown();
+ }
} catch (IOException iox) {
// ignore
log.debug("Problem while shutting down manager.", iox);
@@ -349,8 +355,9 @@ public class SingleClientConnManager imp
protected void revokeConnection() {
ConnAdapter conn = managedConn;
- if (conn == null)
- return;
+ if (conn == null) {
+ return;
+ }
conn.detach();
synchronized (this) {
@@ -381,8 +388,9 @@ public class SingleClientConnManager imp
*/
protected void close() throws IOException {
shutdownEntry();
- if (connection.isOpen())
- connection.close();
+ if (connection.isOpen()) {
+ connection.close();
+ }
}
/**
@@ -390,8 +398,9 @@ public class SingleClientConnManager imp
*/
protected void shutdown() throws IOException {
shutdownEntry();
- if (connection.isOpen())
- connection.shutdown();
+ if (connection.isOpen()) {
+ connection.shutdown();
+ }
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java Tue Jan 15 13:12:01 2013
@@ -194,8 +194,9 @@ public abstract class AbstractConnPool {
poolLock.lock();
try {
- if (isShutDown)
- return;
+ if (isShutDown) {
+ return;
+ }
// close all connections that are issued to an application
Iterator<BasicPoolEntry> iter = leasedConnections.iterator();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java Tue Jan 15 13:12:01 2013
@@ -499,9 +499,10 @@ public class ConnPoolByRoute extends Abs
if (entry.isExpired(System.currentTimeMillis())) {
// If the free entry isn't valid anymore, get rid of it
// and loop to find another one that might be valid.
- if (log.isDebugEnabled())
- log.debug("Closing expired free connection"
+ if (log.isDebugEnabled()) {
+ log.debug("Closing expired free connection"
+ " [" + rospl.getRoute() + "][" + state + "]");
+ }
closeConnection(entry);
// We use dropEntry instead of deleteEntry because the entry
// is no longer "free" (we just allocated it), and deleteEntry
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java Tue Jan 15 13:12:01 2013
@@ -242,8 +242,9 @@ public class RouteSpecificPool {
public boolean deleteEntry(BasicPoolEntry entry) {
final boolean found = freeEntries.remove(entry);
- if (found)
- numEntries--;
+ if (found) {
+ numEntries--;
+ }
return found;
}
@@ -301,8 +302,9 @@ public class RouteSpecificPool {
* @param wt the waiting thread
*/
public void removeThread(WaitingThread wt) {
- if (wt == null)
- return;
+ if (wt == null) {
+ return;
+ }
this.waitingThreads.remove(wt);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java Tue Jan 15 13:12:01 2013
@@ -270,9 +270,10 @@ public class ThreadSafeClientConnManager
hca.shutdown();
}
} catch (IOException iox) {
- if (log.isDebugEnabled())
- log.debug("Exception shutting down released connection.",
+ if (log.isDebugEnabled()) {
+ log.debug("Exception shutting down released connection.",
iox);
+ }
} finally {
boolean reusable = hca.isMarkedReusable();
if (log.isDebugEnabled()) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java Tue Jan 15 13:12:01 2013
@@ -145,8 +145,9 @@ public class WaitingThread {
"\nwaiter: " + this.waiter);
}
- if (aborted)
- throw new InterruptedException("Operation interrupted");
+ if (aborted) {
+ throw new InterruptedException("Operation interrupted");
+ }
this.waiter = Thread.currentThread();
@@ -158,8 +159,9 @@ public class WaitingThread {
this.cond.await();
success = true;
}
- if (aborted)
- throw new InterruptedException("Operation interrupted");
+ if (aborted) {
+ throw new InterruptedException("Operation interrupted");
+ }
} finally {
this.waiter = null;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java Tue Jan 15 13:12:01 2013
@@ -47,8 +47,9 @@ public class WaitingThreadAborter {
public void abort() {
aborted = true;
- if (waitingThread != null)
- waitingThread.interrupt();
+ if (waitingThread != null) {
+ waitingThread.interrupt();
+ }
}
@@ -60,8 +61,9 @@ public class WaitingThreadAborter {
*/
public void setWaitingThread(WaitingThread waitingThread) {
this.waitingThread = waitingThread;
- if (aborted)
- waitingThread.interrupt();
+ if (aborted) {
+ waitingThread.interrupt();
+ }
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java Tue Jan 15 13:12:01 2013
@@ -156,8 +156,9 @@ public final class DateUtils {
dateParser.set2DigitYearStart(startDate);
ParsePosition pos = new ParsePosition(0);
Date result = dateParser.parse(dateValue, pos);
- if (pos.getIndex() != 0)
- return result;
+ if (pos.getIndex() != 0) {
+ return result;
+ }
}
// we were unable to parse the date
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java Tue Jan 15 13:12:01 2013
@@ -79,7 +79,9 @@ public class PublicSuffixFilter implemen
* Never matches if the cookie's domain is from the blacklist.
*/
public boolean match(Cookie cookie, CookieOrigin origin) {
- if (isForPublicSuffix(cookie)) return false;
+ if (isForPublicSuffix(cookie)) {
+ return false;
+ }
return wrapped.match(cookie, origin);
}
@@ -93,23 +95,35 @@ public class PublicSuffixFilter implemen
private boolean isForPublicSuffix(Cookie cookie) {
String domain = cookie.getDomain();
- if (domain.startsWith(".")) domain = domain.substring(1);
+ if (domain.startsWith(".")) {
+ domain = domain.substring(1);
+ }
domain = Punycode.toUnicode(domain);
// An exception rule takes priority over any other matching rule.
if (this.exceptions != null) {
- if (this.exceptions.contains(domain)) return false;
+ if (this.exceptions.contains(domain)) {
+ return false;
+ }
}
- if (this.suffixes == null) return false;
+ if (this.suffixes == null) {
+ return false;
+ }
do {
- if (this.suffixes.contains(domain)) return true;
+ if (this.suffixes.contains(domain)) {
+ return true;
+ }
// patterns
- if (domain.startsWith("*.")) domain = domain.substring(2);
+ if (domain.startsWith("*.")) {
+ domain = domain.substring(2);
+ }
int nextdot = domain.indexOf('.');
- if (nextdot == -1) break;
+ if (nextdot == -1) {
+ break;
+ }
domain = "*" + domain.substring(nextdot);
} while (domain.length() > 0);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java Tue Jan 15 13:12:01 2013
@@ -66,12 +66,22 @@ public class PublicSuffixListParser {
while (more) {
more = readLine(r, sb);
String line = sb.toString();
- if (line.length() == 0) continue;
- if (line.startsWith("//")) continue; //entire lines can also be commented using //
- if (line.startsWith(".")) line = line.substring(1); // A leading dot is optional
+ if (line.length() == 0) {
+ continue;
+ }
+ if (line.startsWith("//"))
+ {
+ continue; //entire lines can also be commented using //
+ }
+ if (line.startsWith("."))
+ {
+ line = line.substring(1); // A leading dot is optional
+ }
// An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule
boolean isException = line.startsWith("!");
- if (isException) line = line.substring(1);
+ if (isException) {
+ line = line.substring(1);
+ }
if (isException) {
exceptions.add(line);
@@ -97,11 +107,20 @@ public class PublicSuffixListParser {
boolean hitWhitespace = false;
while ((b = r.read()) != -1) {
char c = (char) b;
- if (c == '\n') break;
+ if (c == '\n') {
+ break;
+ }
// Each line is only read up to the first whitespace
- if (Character.isWhitespace(c)) hitWhitespace = true;
- if (!hitWhitespace) sb.append(c);
- if (sb.length() > MAX_LINE_LEN) throw new IOException("Line too long"); // prevent excess memory usage
+ if (Character.isWhitespace(c)) {
+ hitWhitespace = true;
+ }
+ if (!hitWhitespace) {
+ sb.append(c);
+ }
+ if (sb.length() > MAX_LINE_LEN)
+ {
+ throw new IOException("Line too long"); // prevent excess memory usage
+ }
}
return (b != -1);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java Tue Jan 15 13:12:01 2013
@@ -82,9 +82,15 @@ public class BackoffStrategyExec impleme
if (this.connectionBackoffStrategy.shouldBackoff(ex)) {
this.backoffManager.backOff(route);
}
- if (ex instanceof RuntimeException) throw (RuntimeException) ex;
- if (ex instanceof HttpException) throw (HttpException) ex;
- if (ex instanceof IOException) throw (IOException) ex;
+ if (ex instanceof RuntimeException) {
+ throw (RuntimeException) ex;
+ }
+ if (ex instanceof HttpException) {
+ throw (HttpException) ex;
+ }
+ if (ex instanceof IOException) {
+ throw (IOException) ex;
+ }
throw new UndeclaredThrowableException(ex);
}
if (this.connectionBackoffStrategy.shouldBackoff(out)) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java Tue Jan 15 13:12:01 2013
@@ -137,12 +137,13 @@ public class TestScheme {
boolean flaghttps = false;
String name = names.get(0);
- if ("http".equals(name))
- flaghttp = true;
- else if ("https".equals(name))
- flaghttps = true;
- else
- Assert.fail("unexpected name in iterator: " + name);
+ if ("http".equals(name)) {
+ flaghttp = true;
+ } else if ("https".equals(name)) {
+ flaghttps = true;
+ } else {
+ Assert.fail("unexpected name in iterator: " + name);
+ }
Assert.assertNotNull(schmreg.get(name));
schmreg.unregister(name);
@@ -151,9 +152,13 @@ public class TestScheme {
name = names.get(1);
if ("http".equals(name)) {
- if (flaghttp) Assert.fail("name 'http' found twice");
+ if (flaghttp) {
+ Assert.fail("name 'http' found twice");
+ }
} else if ("https".equals(name)) {
- if (flaghttps) Assert.fail("name 'https' found twice");
+ if (flaghttps) {
+ Assert.fail("name 'https' found twice");
+ }
} else {
Assert.fail("unexpected name in iterator: " + name);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java Tue Jan 15 13:12:01 2013
@@ -691,8 +691,9 @@ public class TestRouteTracker {
* @return the result of <code>rt.toString()</code>
*/
public final static String checkToString(RouteTracker rt) {
- if (rt == null)
- return null;
+ if (rt == null) {
+ return null;
+ }
final String rts = rt.toString();
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java Tue Jan 15 13:12:01 2013
@@ -47,8 +47,9 @@ public class TestNTLMEngineImpl {
/* Test suite helper */
static byte toNibble(char c) {
- if (c >= 'a' && c <= 'f')
- return (byte) (c - 'a' + 0x0a);
+ if (c >= 'a' && c <= 'f') {
+ return (byte) (c - 'a' + 0x0a);
+ }
return (byte) (c - '0');
}
@@ -71,13 +72,15 @@ public class TestNTLMEngineImpl {
md4.update(input.getBytes("ASCII"));
byte[] answer = md4.getOutput();
byte[] correctAnswer = toBytes(hexOutput);
- if (answer.length != correctAnswer.length)
- throw new Exception("Answer length disagrees for MD4('" + input + "')");
+ if (answer.length != correctAnswer.length) {
+ throw new Exception("Answer length disagrees for MD4('" + input + "')");
+ }
int i = 0;
while (i < answer.length) {
- if (answer[i] != correctAnswer[i])
- throw new Exception("Answer value for MD4('" + input + "') disagrees at position "
+ if (answer[i] != correctAnswer[i]) {
+ throw new Exception("Answer value for MD4('" + input + "') disagrees at position "
+ Integer.toString(i));
+ }
i++;
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java Tue Jan 15 13:12:01 2013
@@ -159,8 +159,12 @@ public class TestAIMDBackoffManager {
@Test
public void coolDownPeriodIsConfigurable() {
long cd = new Random().nextLong() / 2;
- if (cd < 0) cd *= -1;
- if (cd < 1) cd++;
+ if (cd < 0) {
+ cd *= -1;
+ }
+ if (cd < 1) {
+ cd++;
+ }
long now = System.currentTimeMillis();
impl.setCooldownMillis(cd);
clock.setCurrentTime(now);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java Tue Jan 15 13:12:01 2013
@@ -155,8 +155,12 @@ public class TestDecompressingHttpClient
boolean foundDeflate = false;
for(Header h : captured.getHeaders("Accept-Encoding")) {
for(HeaderElement elt : h.getElements()) {
- if ("gzip".equals(elt.getName())) foundGzip = true;
- if ("deflate".equals(elt.getName())) foundDeflate = true;
+ if ("gzip".equals(elt.getName())) {
+ foundGzip = true;
+ }
+ if ("deflate".equals(elt.getName())) {
+ foundDeflate = true;
+ }
}
}
assertTrue(foundGzip);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java Tue Jan 15 13:12:01 2013
@@ -81,7 +81,9 @@ public class TestDefaultBackoffStrategy
@Test
public void doesNotBackOffForNon503StatusCodes() {
for(int i = 100; i <= 599; i++) {
- if (i == HttpStatus.SC_SERVICE_UNAVAILABLE) continue;
+ if (i == HttpStatus.SC_SERVICE_UNAVAILABLE) {
+ continue;
+ }
HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1,
i, "Foo");
assertFalse(impl.shouldBackoff(resp));
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java Tue Jan 15 13:12:01 2013
@@ -215,8 +215,9 @@ public class TestAbortHandling extends I
public void run() {
try {
try {
- if(!startLatch.await(1, TimeUnit.SECONDS))
- throw new RuntimeException("Took too long to start!");
+ if(!startLatch.await(1, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Took too long to start!");
+ }
} catch(InterruptedException interrupted) {
throw new RuntimeException("Never started!", interrupted);
}
@@ -374,11 +375,13 @@ public class TestAbortHandling extends I
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(timeout == 0)
- timeout = Integer.MAX_VALUE;
-
- if(!awaitLatch.await(timeout, tunit))
- throw new ConnectionPoolTimeoutException();
+ if(timeout == 0) {
+ timeout = Integer.MAX_VALUE;
+ }
+
+ if(!awaitLatch.await(timeout, tunit)) {
+ throw new ConnectionPoolTimeoutException();
+ }
return Mockito.mock(HttpClientConnection.class);
}
@@ -432,11 +435,13 @@ public class TestAbortHandling extends I
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(timeout == 0)
- timeout = Integer.MAX_VALUE;
-
- if(!awaitLatch.await(timeout, tunit))
- throw new ConnectionPoolTimeoutException();
+ if(timeout == 0) {
+ timeout = Integer.MAX_VALUE;
+ }
+
+ if(!awaitLatch.await(timeout, tunit)) {
+ throw new ConnectionPoolTimeoutException();
+ }
return Mockito.mock(HttpClientConnection.class);
}
@@ -485,8 +490,9 @@ public class TestAbortHandling extends I
@Override
public void setCancellable(Cancellable cancellable) {
try {
- if(!releaseTriggerLatch.await(1, TimeUnit.SECONDS))
- throw new RuntimeException("Waited too long...");
+ if(!releaseTriggerLatch.await(1, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Waited too long...");
+ }
} catch(InterruptedException ie) {
throw new RuntimeException(ie);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java Tue Jan 15 13:12:01 2013
@@ -462,8 +462,9 @@ public class TestConnectionManagement ex
} catch(SocketException expected) {}
abortingThread.join(5000);
- if(throwRef.get() != null)
- throw new RuntimeException(throwRef.get());
+ if(throwRef.get() != null) {
+ throw new RuntimeException(throwRef.get());
+ }
Assert.assertFalse(conn.isOpen());
Assert.assertEquals(0, localServer.getAcceptedConnectionCount());
@@ -516,8 +517,9 @@ public class TestConnectionManagement ex
}
abortingThread.join(5000);
- if(throwRef.get() != null)
- throw new RuntimeException(throwRef.get());
+ if(throwRef.get() != null) {
+ throw new RuntimeException(throwRef.get());
+ }
Assert.assertFalse(conn.isOpen());
Assert.assertEquals(0, localServer.getAcceptedConnectionCount());
@@ -570,15 +572,17 @@ public class TestConnectionManagement ex
}
abortingThread.join(5000);
- if(throwRef.get() != null)
- throw new RuntimeException(throwRef.get());
+ if(throwRef.get() != null) {
+ throw new RuntimeException(throwRef.get());
+ }
Assert.assertFalse(conn.isOpen());
// Give the server a bit of time to accept the connection, but
// ensure that it can accept it.
for(int i = 0; i < 10; i++) {
- if(localServer.getAcceptedConnectionCount() == 1)
- break;
+ if(localServer.getAcceptedConnectionCount() == 1) {
+ break;
+ }
Thread.sleep(100);
}
Assert.assertEquals(1, localServer.getAcceptedConnectionCount());
@@ -603,15 +607,17 @@ public class TestConnectionManagement ex
}
void waitForState() throws InterruptedException {
- if(!waitLatch.await(1, TimeUnit.SECONDS))
- throw new RuntimeException("waited too long");
+ if(!waitLatch.await(1, TimeUnit.SECONDS)) {
+ throw new RuntimeException("waited too long");
+ }
}
void latch() {
waitLatch.countDown();
try {
- if (!continueLatch.await(60, TimeUnit.SECONDS))
- throw new RuntimeException("waited too long!");
+ if (!continueLatch.await(60, TimeUnit.SECONDS)) {
+ throw new RuntimeException("waited too long!");
+ }
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
@@ -637,21 +643,24 @@ public class TestConnectionManagement ex
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpContext context) throws IOException, ConnectTimeoutException {
- if(waitPolicy == WaitPolicy.BEFORE_CONNECT)
- latch();
+ if(waitPolicy == WaitPolicy.BEFORE_CONNECT) {
+ latch();
+ }
Socket socket = delegate.connectSocket(
connectTimeout, sock, host, remoteAddress, localAddress, context);
- if(waitPolicy == WaitPolicy.AFTER_CONNECT)
- latch();
+ if(waitPolicy == WaitPolicy.AFTER_CONNECT) {
+ latch();
+ }
return socket;
}
public Socket createSocket(final HttpContext context) throws IOException {
- if(waitPolicy == WaitPolicy.BEFORE_CREATE)
- latch();
+ if(waitPolicy == WaitPolicy.BEFORE_CREATE) {
+ latch();
+ }
return delegate.createSocket(context);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java Tue Jan 15 13:12:01 2013
@@ -82,8 +82,9 @@ public class EchoHandler
}
HttpEntity entity = null;
- if (request instanceof HttpEntityEnclosingRequest)
- entity = ((HttpEntityEnclosingRequest)request).getEntity();
+ if (request instanceof HttpEntityEnclosingRequest) {
+ entity = ((HttpEntityEnclosingRequest)request).getEntity();
+ }
// For some reason, just putting the incoming entity into
// the response will not work. We have to buffer the message.
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java Tue Jan 15 13:12:01 2013
@@ -272,10 +272,11 @@ public class LocalTestServer {
ServerSocket ssock = servicedSocket; // avoid synchronization
StringBuilder sb = new StringBuilder(80);
sb.append("LocalTestServer/");
- if (ssock == null)
- sb.append("stopped");
- else
- sb.append(ssock.getLocalSocketAddress());
+ if (ssock == null) {
+ sb.append("stopped");
+ } else {
+ sb.append(ssock.getLocalSocketAddress());
+ }
return sb.toString();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java Tue Jan 15 13:12:01 2013
@@ -251,8 +251,9 @@ public class TestIdentityDecoder {
long pos = beginning.length;
while (!decoder.isCompleted()) {
- if(testfile.length() < pos)
- testfile.setLength(pos);
+ if(testfile.length() < pos) {
+ testfile.setLength(pos);
+ }
long bytesRead = decoder.transfer(fchannel, pos, 10);
if (bytesRead > 0) {
pos += bytesRead;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java Tue Jan 15 13:12:01 2013
@@ -367,8 +367,9 @@ public class TestLengthDelimitedDecoder
long pos = beginning.length;
while (!decoder.isCompleted()) {
- if(testfile.length() < pos)
- testfile.setLength(pos);
+ if(testfile.length() < pos) {
+ testfile.setLength(pos);
+ }
long bytesRead = decoder.transfer(fchannel, pos, 10);
if (bytesRead > 0) {
pos += bytesRead;
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java Tue Jan 15 13:12:01 2013
@@ -187,7 +187,9 @@ public final class HttpHost implements C
@Override
public boolean equals(final Object obj) {
- if (this == obj) return true;
+ if (this == obj) {
+ return true;
+ }
if (obj instanceof HttpHost) {
HttpHost that = (HttpHost) obj;
return this.lcHostname.equals(that.lcHostname)
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java Tue Jan 15 13:12:01 2013
@@ -107,8 +107,9 @@ public class DefaultConnectionReuseStrat
// the "Proxy-Connection" header. The latter is an unspecified and
// broken but unfortunately common extension of HTTP.
HeaderIterator hit = response.headerIterator(HTTP.CONN_DIRECTIVE);
- if (!hit.hasNext())
- hit = response.headerIterator("Proxy-Connection");
+ if (!hit.hasNext()) {
+ hit = response.headerIterator("Proxy-Connection");
+ }
// Experimental usage of the "Connection" header in HTTP/1.0 is
// documented in RFC 2068, section 19.7.1. A token "keep-alive" is
@@ -147,8 +148,10 @@ public class DefaultConnectionReuseStrat
}
}
if (keepalive)
- return true;
+ {
+ return true;
// neither "close" nor "keep-alive", use default policy
+ }
} catch (ParseException px) {
// invalid connection header means no persistent connection
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java?rev=1433390&r1=1433389&r2=1433390&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java Tue Jan 15 13:12:01 2013
@@ -78,8 +78,9 @@ public class EnglishReasonPhraseCatalog
int subcode = status - 100*category;
String reason = null;
- if (REASON_PHRASES[category].length > subcode)
- reason = REASON_PHRASES[category][subcode];
+ if (REASON_PHRASES[category].length > subcode) {
+ reason = REASON_PHRASES[category][subcode];
+ }
return reason;
}