You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/12/27 19:48:10 UTC
svn commit: r1776187 [13/21] - in /httpcomponents/httpclient/trunk: ./
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/
httpclient5-cache/src/test/java/org/apache/h...
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java Tue Dec 27 19:48:07 2016
@@ -35,7 +35,8 @@ import java.util.concurrent.ConcurrentHa
import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
import org.apache.hc.client5.http.cookie.CookieAttributeHandler;
import org.apache.hc.client5.http.cookie.CookieSpec;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Asserts;
/**
@@ -46,7 +47,7 @@ import org.apache.hc.core5.util.Asserts;
*
* @since 4.0
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE)
public abstract class AbstractCookieSpec implements CookieSpec {
/**
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java Tue Dec 27 19:48:07 2016
@@ -34,7 +34,6 @@ import java.util.Locale;
import java.util.Map;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.NotThreadSafe;
import org.apache.hc.core5.util.Args;
/**
@@ -42,7 +41,6 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.0
*/
-@NotThreadSafe
public class BasicClientCookie implements SetCookie, Cloneable, Serializable {
private static final long serialVersionUID = -3869795591041535538L;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java Tue Dec 27 19:48:07 2016
@@ -34,8 +34,9 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieRestrictionViolationException;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.client5.http.utils.InetAddressUtils;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.net.InetAddressUtils;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
@@ -43,7 +44,7 @@ import org.apache.hc.core5.util.TextUtil
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicDomainHandler implements CommonCookieAttributeHandler {
public BasicDomainHandler() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java Tue Dec 27 19:48:07 2016
@@ -33,14 +33,15 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
import org.apache.hc.client5.http.utils.DateUtils;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/** Valid date patterns */
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java Tue Dec 27 19:48:07 2016
@@ -32,14 +32,15 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
public BasicMaxAgeHandler() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java Tue Dec 27 19:48:07 2016
@@ -32,7 +32,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieRestrictionViolationException;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
@@ -40,7 +41,7 @@ import org.apache.hc.core5.util.TextUtil
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicPathHandler implements CommonCookieAttributeHandler {
public BasicPathHandler() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java Tue Dec 27 19:48:07 2016
@@ -31,14 +31,15 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieOrigin;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
public BasicSecureHandler() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java Tue Dec 27 19:48:07 2016
@@ -37,7 +37,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieAttributeHandler;
import org.apache.hc.client5.http.cookie.CookieOrigin;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.util.Args;
@@ -47,7 +48,7 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.0
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
public abstract class CookieSpecBase extends AbstractCookieSpec {
public CookieSpecBase() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java Tue Dec 27 19:48:07 2016
@@ -33,7 +33,8 @@ import java.util.List;
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.CookieOrigin;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.Header;
/**
@@ -41,7 +42,7 @@ import org.apache.hc.core5.http.Header;
*
* @since 4.1
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE)
public class IgnoreSpec extends CookieSpecBase {
@Override
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java Tue Dec 27 19:48:07 2016
@@ -29,7 +29,8 @@ package org.apache.hc.client5.http.impl.
import org.apache.hc.client5.http.cookie.CookieSpec;
import org.apache.hc.client5.http.cookie.CookieSpecProvider;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -37,7 +38,7 @@ import org.apache.hc.core5.http.protocol
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class IgnoreSpecProvider implements CookieSpecProvider {
private volatile CookieSpec cookieSpec;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java Tue Dec 27 19:48:07 2016
@@ -39,7 +39,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.message.ParserCursor;
import org.apache.hc.core5.util.Args;
@@ -47,7 +48,7 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
static final TimeZone UTC = TimeZone.getTimeZone("UTC");
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java Tue Dec 27 19:48:07 2016
@@ -34,7 +34,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
@@ -42,7 +43,7 @@ import org.apache.hc.core5.util.TextUtil
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
private final static Pattern MAX_AGE_PATTERN = Pattern.compile("^\\-?[0-9]+$");
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java Tue Dec 27 19:48:07 2016
@@ -36,7 +36,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.SetCookie;
import org.apache.hc.client5.http.psl.PublicSuffixList;
import org.apache.hc.client5.http.psl.PublicSuffixMatcher;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
@@ -50,7 +51,7 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.4
*/
-@Immutable // dependencies are expected to be immutable or thread-safe
+@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
public class PublicSuffixDomainFilter implements CommonCookieAttributeHandler {
private final CommonCookieAttributeHandler handler;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java Tue Dec 27 19:48:07 2016
@@ -44,7 +44,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookiePriorityComparator;
import org.apache.hc.client5.http.cookie.CookieSpec;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.FormattedHeader;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.ParseException;
@@ -59,7 +60,7 @@ import org.apache.hc.core5.util.CharArra
*
* @since 4.5
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
public class RFC6265CookieSpec implements CookieSpec {
private final static char PARAM_DELIMITER = ';';
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java Tue Dec 27 19:48:07 2016
@@ -33,7 +33,8 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieSpecProvider;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.psl.PublicSuffixMatcher;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -43,7 +44,7 @@ import org.apache.hc.core5.http.protocol
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
public class RFC6265CookieSpecProvider implements CookieSpecProvider {
public enum CompatibilityLevel {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java Tue Dec 27 19:48:07 2016
@@ -28,7 +28,8 @@
package org.apache.hc.client5.http.impl.cookie;
import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
/**
* Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation that enforces a more relaxed
@@ -38,7 +39,7 @@ import org.apache.hc.core5.annotation.Th
*
* @since 4.4
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE)
public class RFC6265LaxSpec extends RFC6265CookieSpecBase {
public RFC6265LaxSpec() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java Tue Dec 27 19:48:07 2016
@@ -29,7 +29,8 @@ package org.apache.hc.client5.http.impl.
import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
import org.apache.hc.client5.http.utils.DateUtils;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
/**
* Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation that enforces syntax
@@ -38,7 +39,7 @@ import org.apache.hc.core5.annotation.Th
*
* @since 4.4
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE)
public class RFC6265StrictSpec extends RFC6265CookieSpecBase {
final static String[] DATE_PATTERNS = {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java Tue Dec 27 19:48:07 2016
@@ -45,8 +45,8 @@ import org.apache.hc.client5.http.io.Man
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
-import org.apache.hc.core5.annotation.GuardedBy;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.ConnectionConfig;
import org.apache.hc.core5.http.config.Lookup;
@@ -79,7 +79,7 @@ import org.apache.logging.log4j.Logger;
*
* @since 4.3
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE)
public class BasicHttpClientConnectionManager implements HttpClientConnectionManager, Closeable {
private final Logger log = LogManager.getLogger(getClass());
@@ -87,28 +87,13 @@ public class BasicHttpClientConnectionMa
private final HttpClientConnectionOperator connectionOperator;
private final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory;
- @GuardedBy("this")
private ManagedHttpClientConnection conn;
-
- @GuardedBy("this")
private HttpRoute route;
-
- @GuardedBy("this")
private Object state;
-
- @GuardedBy("this")
private long updated;
-
- @GuardedBy("this")
private long expiry;
-
- @GuardedBy("this")
private boolean leased;
-
- @GuardedBy("this")
private SocketConfig socketConfig;
-
- @GuardedBy("this")
private ConnectionConfig connConfig;
private final AtomicBoolean isShutdown;
@@ -358,7 +343,7 @@ public class BasicHttpClientConnectionMa
}
@Override
- public synchronized void closeExpiredConnections() {
+ public synchronized void closeExpired() {
if (this.isShutdown.get()) {
return;
}
@@ -368,7 +353,7 @@ public class BasicHttpClientConnectionMa
}
@Override
- public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public synchronized void closeIdle(final long idletime, final TimeUnit tunit) {
Args.notNull(tunit, "Time unit");
if (this.isShutdown.get()) {
return;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/CPoolProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/CPoolProxy.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/CPoolProxy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/CPoolProxy.java Tue Dec 27 19:48:07 2016
@@ -32,40 +32,54 @@ import java.net.SocketAddress;
import javax.net.ssl.SSLSession;
+import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
-import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpConnectionMetrics;
import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.io.HttpClientConnection;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.pool.PoolEntry;
/**
* @since 4.3
*/
-@NotThreadSafe
class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
- private volatile CPoolEntry poolEntry;
+ private volatile PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry;
+ private volatile boolean routeComplete;
- CPoolProxy(final CPoolEntry entry) {
+ CPoolProxy(final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry) {
super();
this.poolEntry = entry;
}
- CPoolEntry getPoolEntry() {
+ PoolEntry<HttpRoute, ManagedHttpClientConnection> getPoolEntry() {
return this.poolEntry;
}
- CPoolEntry detach() {
- final CPoolEntry local = this.poolEntry;
+ boolean isDetached() {
+ return this.poolEntry == null;
+ }
+
+ PoolEntry<HttpRoute, ManagedHttpClientConnection> detach() {
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> local = this.poolEntry;
this.poolEntry = null;
return local;
}
+ public void markRouteComplete() {
+ this.routeComplete = true;
+ }
+
+ public boolean isRouteComplete() {
+ return this.routeComplete;
+ }
+
ManagedHttpClientConnection getConnection() {
- final CPoolEntry local = this.poolEntry;
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> local = this.poolEntry;
if (local == null) {
return null;
}
@@ -82,32 +96,40 @@ class CPoolProxy implements ManagedHttpC
@Override
public void close() throws IOException {
- final CPoolEntry local = this.poolEntry;
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> local = this.poolEntry;
if (local != null) {
- local.closeConnection();
+ final ManagedHttpClientConnection conn = local.getConnection();
+ if (conn != null) {
+ conn.close();
+ }
}
}
@Override
public void shutdown() throws IOException {
- final CPoolEntry local = this.poolEntry;
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> local = this.poolEntry;
if (local != null) {
- local.shutdownConnection();
+ final ManagedHttpClientConnection conn = local.getConnection();
+ if (conn != null) {
+ conn.close();
+ }
}
}
@Override
public boolean isOpen() {
- final CPoolEntry local = this.poolEntry;
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> local = this.poolEntry;
if (local != null) {
- return !local.isClosed();
- } else {
- return false;
+ final ManagedHttpClientConnection conn = local.getConnection();
+ if (conn != null) {
+ return conn.isOpen();
+ }
}
+ return false;
}
@Override
- public boolean isStale() {
+ public boolean isStale() throws IOException {
final HttpClientConnection conn = getConnection();
if (conn != null) {
return conn.isStale();
@@ -117,6 +139,11 @@ class CPoolProxy implements ManagedHttpC
}
@Override
+ public ProtocolVersion getProtocolVersion() {
+ return getValidConnection().getProtocolVersion();
+ }
+
+ @Override
public void setSocketTimeout(final int timeout) {
getValidConnection().setSocketTimeout(timeout);
}
@@ -152,7 +179,7 @@ class CPoolProxy implements ManagedHttpC
}
@Override
- public void terminateRequest(final HttpRequest request) throws HttpException, IOException {
+ public void terminateRequest(final ClassicHttpRequest request) throws HttpException, IOException {
getValidConnection().terminateRequest(request);
}
@@ -162,22 +189,22 @@ class CPoolProxy implements ManagedHttpC
}
@Override
- public void sendRequestHeader(final HttpRequest request) throws HttpException, IOException {
+ public void sendRequestHeader(final ClassicHttpRequest request) throws HttpException, IOException {
getValidConnection().sendRequestHeader(request);
}
@Override
- public void sendRequestEntity(final HttpRequest request) throws HttpException, IOException {
+ public void sendRequestEntity(final ClassicHttpRequest request) throws HttpException, IOException {
getValidConnection().sendRequestEntity(request);
}
@Override
- public HttpResponse receiveResponseHeader() throws HttpException, IOException {
+ public ClassicHttpResponse receiveResponseHeader() throws HttpException, IOException {
return getValidConnection().receiveResponseHeader();
}
@Override
- public void receiveResponseEntity(final HttpResponse response) throws HttpException, IOException {
+ public void receiveResponseEntity(final ClassicHttpResponse response) throws HttpException, IOException {
getValidConnection().receiveResponseEntity(response);
}
@@ -230,6 +257,10 @@ class CPoolProxy implements ManagedHttpC
}
@Override
+ public void setProtocolVersion(final ProtocolVersion version) {
+ }
+
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder("CPoolProxy{");
final ManagedHttpClientConnection conn = getConnection();
@@ -242,27 +273,11 @@ class CPoolProxy implements ManagedHttpC
return sb.toString();
}
- public static HttpClientConnection newProxy(final CPoolEntry poolEntry) {
- return new CPoolProxy(poolEntry);
- }
-
- private static CPoolProxy getProxy(final HttpClientConnection conn) {
+ static CPoolProxy getProxy(final HttpClientConnection conn) {
if (!CPoolProxy.class.isInstance(conn)) {
throw new IllegalStateException("Unexpected connection proxy class: " + conn.getClass());
}
return CPoolProxy.class.cast(conn);
}
- public static CPoolEntry getPoolEntry(final HttpClientConnection proxy) {
- final CPoolEntry entry = getProxy(proxy).getPoolEntry();
- if (entry == null) {
- throw new ConnectionShutdownException();
- }
- return entry;
- }
-
- public static CPoolEntry detach(final HttpClientConnection conn) {
- return getProxy(conn).detach();
- }
-
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ConnectionShutdownException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ConnectionShutdownException.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ConnectionShutdownException.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ConnectionShutdownException.java Tue Dec 27 19:48:07 2016
@@ -27,15 +27,12 @@
package org.apache.hc.client5.http.impl.io;
-import org.apache.hc.core5.annotation.Immutable;
-
/**
* Signals that the connection has been shut down or released back to the
* the connection pool
*
* @since 4.1
*/
-@Immutable
public class ConnectionShutdownException extends IllegalStateException {
private static final long serialVersionUID = 5868657401162844497L;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java Tue Dec 27 19:48:07 2016
@@ -46,7 +46,8 @@ import org.apache.hc.client5.http.io.Man
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.config.SocketConfig;
@@ -62,7 +63,7 @@ import org.apache.logging.log4j.Logger;
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
public class DefaultHttpClientConnectionOperator implements HttpClientConnectionOperator {
static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java Tue Dec 27 19:48:07 2016
@@ -27,11 +27,12 @@
package org.apache.hc.client5.http.impl.io;
-import org.apache.hc.core5.annotation.Immutable;
-import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.config.MessageConstraints;
-import org.apache.hc.core5.http.impl.DefaultHttpResponseFactory;
+import org.apache.hc.core5.http.config.H1Config;
+import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory;
import org.apache.hc.core5.http.io.HttpMessageParser;
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
import org.apache.hc.core5.http.message.BasicLineParser;
@@ -42,23 +43,23 @@ import org.apache.hc.core5.http.message.
*
* @since 4.3
*/
-@Immutable
-public class DefaultHttpResponseParserFactory implements HttpMessageParserFactory<HttpResponse> {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class DefaultHttpResponseParserFactory implements HttpMessageParserFactory<ClassicHttpResponse> {
public static final DefaultHttpResponseParserFactory INSTANCE = new DefaultHttpResponseParserFactory();
private final LineParser lineParser;
- private final HttpResponseFactory responseFactory;
+ private final HttpResponseFactory<ClassicHttpResponse> responseFactory;
public DefaultHttpResponseParserFactory(
final LineParser lineParser,
- final HttpResponseFactory responseFactory) {
+ final HttpResponseFactory<ClassicHttpResponse> responseFactory) {
super();
this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
- this.responseFactory = responseFactory != null ? responseFactory : DefaultHttpResponseFactory.INSTANCE;
+ this.responseFactory = responseFactory != null ? responseFactory : DefaultClassicHttpResponseFactory.INSTANCE;
}
- public DefaultHttpResponseParserFactory(final HttpResponseFactory responseFactory) {
+ public DefaultHttpResponseParserFactory(final HttpResponseFactory<ClassicHttpResponse> responseFactory) {
this(null, responseFactory);
}
@@ -67,8 +68,8 @@ public class DefaultHttpResponseParserFa
}
@Override
- public HttpMessageParser<HttpResponse> create(final MessageConstraints constraints) {
- return new LenientHttpResponseParser(this.lineParser, this.responseFactory, constraints);
+ public HttpMessageParser<ClassicHttpResponse> create(final H1Config h1Config) {
+ return new LenientHttpResponseParser(this.lineParser, this.responseFactory, h1Config);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java Tue Dec 27 19:48:07 2016
@@ -34,18 +34,18 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
-import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentLengthStrategy;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection;
+import org.apache.hc.core5.http.impl.io.SocketHolder;
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpContext;
@@ -54,39 +54,34 @@ import org.apache.hc.core5.http.protocol
* Default {@link ManagedHttpClientConnection} implementation.
* @since 4.3
*/
-@NotThreadSafe
public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnection
- implements ManagedHttpClientConnection, HttpContext {
+ implements ManagedHttpClientConnection, HttpContext {
private final String id;
private final Map<String, Object> attributes;
- private final AtomicReference<Socket> socketHolder;
private volatile boolean shutdown;
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize,
- final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
- final MessageConstraints constraints,
+ final H1Config h1Config,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
- final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
- constraints, incomingContentStrategy, outgoingContentStrategy,
+ final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
+ final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
+ super(buffersize, chardecoder, charencoder, h1Config, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<>();
- this.socketHolder = new AtomicReference<>(null);
}
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize) {
- this(id, buffersize, buffersize, null, null, null, null, null, null, null);
+ this(id, buffersize, null, null, null, null, null, null, null);
}
@Override
@@ -101,40 +96,25 @@ public class DefaultManagedHttpClientCon
}
@Override
- public Object getAttribute(final String id) {
- return this.attributes.get(id);
- }
-
- @Override
- public Object removeAttribute(final String id) {
- return this.attributes.remove(id);
- }
-
- @Override
- public void setAttribute(final String id, final Object obj) {
- this.attributes.put(id, obj);
- }
-
- @Override
- public void bind(final Socket socket) throws IOException {
+ public void bind(final SocketHolder socketHolder) throws IOException {
if (this.shutdown) {
+ final Socket socket = socketHolder.getSocket();
socket.close(); // allow this to throw...
// ...but if it doesn't, explicitly throw one ourselves.
throw new InterruptedIOException("Connection already shutdown");
}
- if (!this.socketHolder.compareAndSet(socket, socket)) {
- super.bind(socket);
- }
+ super.bind(socketHolder);
}
@Override
public Socket getSocket() {
- return this.socketHolder.get();
+ final SocketHolder socketHolder = getSocketHolder();
+ return socketHolder != null ? socketHolder.getSocket() : null;
}
@Override
public SSLSession getSSLSession() {
- final Socket socket = this.socketHolder.get();
+ final Socket socket = getSocket();
if (socket instanceof SSLSocket) {
return ((SSLSocket) socket).getSession();
} else {
@@ -142,4 +122,23 @@ public class DefaultManagedHttpClientCon
}
}
+ @Override
+ public void setProtocolVersion(final ProtocolVersion version) {
+ }
+
+ @Override
+ public Object getAttribute(final String id) {
+ return this.attributes.get(id);
+ }
+
+ @Override
+ public void setAttribute(final String id, final Object obj) {
+ this.attributes.put(id, obj);
+ }
+
+ @Override
+ public Object removeAttribute(final String id) {
+ return this.attributes.remove(id);
+ }
+
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java Tue Dec 27 19:48:07 2016
@@ -29,11 +29,10 @@ package org.apache.hc.client5.http.impl.
import java.io.IOException;
-import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser;
import org.apache.hc.core5.http.message.LineParser;
import org.apache.hc.core5.util.CharArrayBuffer;
@@ -46,7 +45,6 @@ import org.apache.logging.log4j.Logger;
*
* @since 4.2
*/
-@NotThreadSafe
public class LenientHttpResponseParser extends DefaultHttpResponseParser {
private final Logger log = LogManager.getLogger(getClass());
@@ -57,31 +55,32 @@ public class LenientHttpResponseParser e
* @param lineParser the line parser. If {@code null}
* {@link org.apache.hc.core5.http.message.BasicLineParser#INSTANCE} will be used.
* @param responseFactory HTTP response factory. If {@code null}
- * {@link org.apache.hc.core5.http.impl.DefaultHttpResponseFactory#INSTANCE} will be used.
- * @param constraints the message constraints. If {@code null}
- * {@link MessageConstraints#DEFAULT} will be used.
+ * {@link org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory#INSTANCE}
+ * will be used.
+ * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link H1Config#DEFAULT} will be used.
+ *
* @since 4.3
*/
public LenientHttpResponseParser(
final LineParser lineParser,
- final HttpResponseFactory responseFactory,
- final MessageConstraints constraints) {
- super(lineParser, responseFactory, constraints);
+ final HttpResponseFactory<ClassicHttpResponse> responseFactory,
+ final H1Config h1Config) {
+ super(lineParser, responseFactory, h1Config);
}
/**
* Creates new instance of DefaultHttpResponseParser.
*
- * @param constraints the message constraints. If {@code null}
- * {@link MessageConstraints#DEFAULT} will be used.
+ * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link H1Config#DEFAULT} will be used.
+ *
* @since 4.3
*/
- public LenientHttpResponseParser(final MessageConstraints constraints) {
- this(null, null, constraints);
+ public LenientHttpResponseParser(final H1Config h1Config) {
+ this(null, null, h1Config);
}
@Override
- protected HttpResponse createMessage(final CharArrayBuffer buffer) throws IOException {
+ protected ClassicHttpResponse createMessage(final CharArrayBuffer buffer) throws IOException {
try {
return super.createMessage(buffer);
} catch (final HttpException ex) {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingInputStream.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingInputStream.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingInputStream.java Tue Dec 27 19:48:07 2016
@@ -30,14 +30,11 @@ package org.apache.hc.client5.http.impl.
import java.io.IOException;
import java.io.InputStream;
-import org.apache.hc.core5.annotation.NotThreadSafe;
-
/**
* Internal class.
*
* @since 4.3
*/
-@NotThreadSafe
class LoggingInputStream extends InputStream {
private final InputStream in;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingManagedHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingManagedHttpClientConnection.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingManagedHttpClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingManagedHttpClientConnection.java Tue Dec 27 19:48:07 2016
@@ -28,23 +28,22 @@
package org.apache.hc.client5.http.impl.io;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
-import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentLengthStrategy;
import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.config.H1Config;
+import org.apache.hc.core5.http.impl.io.SocketHolder;
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
+import org.apache.hc.core5.http.message.RequestLine;
+import org.apache.hc.core5.http.message.StatusLine;
import org.apache.logging.log4j.Logger;
-@NotThreadSafe
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
private final Logger log;
@@ -57,16 +56,14 @@ class LoggingManagedHttpClientConnection
final Logger headerlog,
final Logger wirelog,
final int buffersize,
- final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
- final MessageConstraints constraints,
+ final H1Config h1Config,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
- final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
- constraints, incomingContentStrategy, outgoingContentStrategy,
+ final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
+ final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
+ super(id, buffersize, chardecoder, charencoder, h1Config, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.log = log;
this.headerlog = headerlog;
@@ -101,27 +98,14 @@ class LoggingManagedHttpClientConnection
}
@Override
- protected InputStream getSocketInputStream(final Socket socket) throws IOException {
- InputStream in = super.getSocketInputStream(socket);
- if (this.wire.enabled()) {
- in = new LoggingInputStream(in, this.wire);
- }
- return in;
- }
-
- @Override
- protected OutputStream getSocketOutputStream(final Socket socket) throws IOException {
- OutputStream out = super.getSocketOutputStream(socket);
- if (this.wire.enabled()) {
- out = new LoggingOutputStream(out, this.wire);
- }
- return out;
+ public void bind(final Socket socket) throws IOException {
+ super.bind(this.wire.enabled() ? new LoggingSocketHolder(socket, this.wire) : new SocketHolder(socket));
}
@Override
- protected void onResponseReceived(final HttpResponse response) {
+ protected void onResponseReceived(final ClassicHttpResponse response) {
if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " << " + response.getStatusLine().toString());
+ this.headerlog.debug(getId() + " << " + new StatusLine(response));
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
this.headerlog.debug(getId() + " << " + header.toString());
@@ -130,9 +114,9 @@ class LoggingManagedHttpClientConnection
}
@Override
- protected void onRequestSubmitted(final HttpRequest request) {
+ protected void onRequestSubmitted(final ClassicHttpRequest request) {
if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
+ this.headerlog.debug(getId() + " >> " + new RequestLine(request));
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
this.headerlog.debug(getId() + " >> " + header.toString());
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingOutputStream.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingOutputStream.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingOutputStream.java Tue Dec 27 19:48:07 2016
@@ -30,14 +30,11 @@ package org.apache.hc.client5.http.impl.
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.hc.core5.annotation.NotThreadSafe;
-
/**
* Internal class.
*
* @since 4.3
*/
-@NotThreadSafe
class LoggingOutputStream extends OutputStream {
private final OutputStream out;
Copied: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingSocketHolder.java (from r1772287, httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/RequestBasicAuth.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingSocketHolder.java?p2=httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingSocketHolder.java&p1=httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/RequestBasicAuth.java&r1=1772287&r2=1776187&rev=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/RequestBasicAuth.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LoggingSocketHolder.java Tue Dec 27 19:48:07 2016
@@ -25,29 +25,31 @@
*
*/
-package org.apache.hc.client5.http.localserver;
+package org.apache.hc.client5.http.impl.io;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpRequestInterceptor;
-import org.apache.hc.core5.http.protocol.HttpContext;
-
-public class RequestBasicAuth implements HttpRequestInterceptor {
-
- private final BasicAuthTokenExtractor authTokenExtractor;
-
- public RequestBasicAuth() {
- super();
- this.authTokenExtractor = new BasicAuthTokenExtractor();
+import org.apache.hc.core5.http.impl.io.SocketHolder;
+
+class LoggingSocketHolder extends SocketHolder {
+
+ private final Wire wire;
+
+ LoggingSocketHolder(final Socket socket, final Wire wire) {
+ super(socket);
+ this.wire = wire;
}
@Override
- public void process(
- final HttpRequest request,
- final HttpContext context) throws HttpException, IOException {
- context.setAttribute("creds", this.authTokenExtractor.extract(request));
+ protected InputStream getInputStream(final Socket socket) throws IOException {
+ return new LoggingInputStream(super.getInputStream(socket), wire);
}
+ @Override
+ protected OutputStream getOutputStream(final Socket socket) throws IOException {
+ return new LoggingOutputStream(super.getOutputStream(socket), wire);
+ }
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java Tue Dec 27 19:48:07 2016
@@ -36,11 +36,13 @@ import java.util.concurrent.atomic.Atomi
import org.apache.hc.client5.http.HttpConnectionFactory;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentLengthStrategy;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
@@ -52,20 +54,20 @@ import org.apache.logging.log4j.Logger;
* Factory for {@link ManagedHttpClientConnection} instances.
* @since 4.3
*/
-@Immutable
-public class ManagedHttpClientConnectionFactory
- implements HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> {
private static final AtomicLong COUNTER = new AtomicLong();
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
private final Logger log = LogManager.getLogger(DefaultManagedHttpClientConnection.class);
- private final Logger headerlog = LogManager.getLogger("org.apache.http.headers");
- private final Logger wirelog = LogManager.getLogger("org.apache.http.wire");
+ private final Logger headerlog = LogManager.getLogger("org.apache.hc.client5.http.headers");
+ private final Logger wirelog = LogManager.getLogger("org.apache.hc.client5.http.wire");
- private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
- private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
+ private final H1Config h1Config;
+ private final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
+ private final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
private final ContentLengthStrategy incomingContentStrategy;
private final ContentLengthStrategy outgoingContentStrategy;
@@ -73,11 +75,13 @@ public class ManagedHttpClientConnection
* @since 4.4
*/
public ManagedHttpClientConnectionFactory(
- final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
- final HttpMessageParserFactory<HttpResponse> responseParserFactory,
+ final H1Config h1Config,
+ final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
+ final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
+ this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE;
this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
@@ -89,14 +93,16 @@ public class ManagedHttpClientConnection
}
public ManagedHttpClientConnectionFactory(
- final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
- final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- this(requestWriterFactory, responseParserFactory, null, null);
+ final H1Config h1Config,
+ final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
+ final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
+ this(h1Config, requestWriterFactory, responseParserFactory, null, null);
}
public ManagedHttpClientConnectionFactory(
- final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- this(null, responseParserFactory);
+ final H1Config h1Config,
+ final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
+ this(h1Config, null, responseParserFactory);
}
public ManagedHttpClientConnectionFactory() {
@@ -128,10 +134,9 @@ public class ManagedHttpClientConnection
headerlog,
wirelog,
cconfig.getBufferSize(),
- cconfig.getFragmentSizeHint(),
chardecoder,
charencoder,
- cconfig.getMessageConstraints(),
+ h1Config,
incomingContentStrategy,
outgoingContentStrategy,
requestWriterFactory,
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java Tue Dec 27 19:48:07 2016
@@ -50,7 +50,9 @@ import org.apache.hc.client5.http.io.Man
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
-import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.ConnectionConfig;
import org.apache.hc.core5.http.config.Lookup;
@@ -60,11 +62,11 @@ import org.apache.hc.core5.http.config.S
import org.apache.hc.core5.http.io.HttpClientConnection;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.pool.ConnPoolControl;
-import org.apache.hc.core5.pool.PoolEntryCallback;
+import org.apache.hc.core5.pool.ConnPoolPolicy;
+import org.apache.hc.core5.pool.PoolEntry;
import org.apache.hc.core5.pool.PoolStats;
-import org.apache.hc.core5.pool.io.ConnFactory;
+import org.apache.hc.core5.pool.StrictConnPool;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Asserts;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -100,7 +102,7 @@ import org.apache.logging.log4j.Logger;
*
* @since 4.3
*/
-@ThreadSafe
+@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
public class PoolingHttpClientConnectionManager
implements HttpClientConnectionManager, ConnPoolControl<HttpRoute>, Closeable {
@@ -110,10 +112,13 @@ public class PoolingHttpClientConnection
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 5;
private final ConfigData configData;
- private final CPool pool;
+ private final StrictConnPool<HttpRoute, ManagedHttpClientConnection> pool;
+ private final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory;
private final HttpClientConnectionOperator connectionOperator;
private final AtomicBoolean isShutDown;
+ private volatile int validateAfterInactivity;
+
private static Registry<ConnectionSocketFactory> getDefaultRegistry() {
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
@@ -175,17 +180,15 @@ public class PoolingHttpClientConnection
* @since 4.4
*/
public PoolingHttpClientConnectionManager(
- final HttpClientConnectionOperator httpClientConnectionOperator,
- final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
- final long timeToLive, final TimeUnit tunit) {
+ final HttpClientConnectionOperator httpClientConnectionOperator,
+ final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
+ final long timeToLive, final TimeUnit tunit) {
super();
+ this.connectionOperator = Args.notNull(httpClientConnectionOperator, "Connection operator");
+ this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
this.configData = new ConfigData();
- this.pool = new CPool(new InternalConnectionFactory(
- this.configData, connFactory),
- DEFAULT_MAX_CONNECTIONS_PER_ROUTE, DEFAULT_MAX_TOTAL_CONNECTIONS,
- timeToLive, tunit);
- this.pool.setValidateAfterInactivity(2000);
- this.connectionOperator = Args.notNull(httpClientConnectionOperator, "HttpClientConnectionOperator");
+ this.pool = new StrictConnPool<>(
+ DEFAULT_MAX_CONNECTIONS_PER_ROUTE, DEFAULT_MAX_TOTAL_CONNECTIONS, timeToLive, tunit, ConnPoolPolicy.LIFO, null);
this.isShutDown = new AtomicBoolean(false);
}
@@ -193,15 +196,16 @@ public class PoolingHttpClientConnection
* Visible for test.
*/
PoolingHttpClientConnectionManager(
- final CPool pool,
+ final StrictConnPool<HttpRoute, ManagedHttpClientConnection> pool,
final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver) {
super();
- this.configData = new ConfigData();
- this.pool = pool;
this.connectionOperator = new DefaultHttpClientConnectionOperator(
socketFactoryRegistry, schemePortResolver, dnsResolver);
+ this.connFactory = ManagedHttpClientConnectionFactory.INSTANCE;
+ this.configData = new ConfigData();
+ this.pool = pool;
this.isShutDown = new AtomicBoolean(false);
}
@@ -240,9 +244,10 @@ public class PoolingHttpClientConnection
return buf.toString();
}
- private String format(final CPoolEntry entry) {
+ private String format(final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry) {
final StringBuilder buf = new StringBuilder();
- buf.append("[id: ").append(entry.getId()).append("]");
+ final ManagedHttpClientConnection conn = entry.getConnection();
+ buf.append("[id: ").append(conn != null ? conn.getId() : "unknown").append("]");
buf.append("[route: ").append(entry.getRoute()).append("]");
final Object state = entry.getState();
if (state != null) {
@@ -259,7 +264,7 @@ public class PoolingHttpClientConnection
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
- final Future<CPoolEntry> future = this.pool.lease(route, state, null);
+ final Future<PoolEntry<HttpRoute, ManagedHttpClientConnection>> future = this.pool.lease(route, state, null);
return new ConnectionRequest() {
@Override
@@ -279,46 +284,81 @@ public class PoolingHttpClientConnection
}
protected HttpClientConnection leaseConnection(
- final Future<CPoolEntry> future,
+ final Future<PoolEntry<HttpRoute, ManagedHttpClientConnection>> future,
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
- final CPoolEntry entry;
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry;
try {
entry = future.get(timeout, tunit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
- Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection leased: " + format(entry) + formatStats(entry.getRoute()));
- }
- return CPoolProxy.newProxy(entry);
} catch (final TimeoutException ex) {
+ future.cancel(true);
throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
}
+ if (this.validateAfterInactivity > 0) {
+ final ManagedHttpClientConnection connection = entry.getConnection();
+ if (connection != null
+ && entry.getUpdated() + this.validateAfterInactivity <= System.currentTimeMillis()) {
+ boolean stale;
+ try {
+ stale = connection.isStale();
+ } catch (IOException ignore) {
+ stale = true;
+ }
+ if (stale) {
+ entry.discardConnection();
+ }
+ }
+ }
+ final HttpRoute route = entry.getRoute();
+ final CPoolProxy poolProxy = new CPoolProxy(entry);
+ if (entry.hasConnection()) {
+ poolProxy.markRouteComplete();
+ } else {
+ ConnectionConfig config = null;
+ if (route.getProxyHost() != null) {
+ config = this.configData.getConnectionConfig(route.getProxyHost());
+ }
+ if (config == null) {
+ config = this.configData.getConnectionConfig(route.getTargetHost());
+ }
+ if (config == null) {
+ config = this.configData.getDefaultConnectionConfig();
+ }
+ if (config == null) {
+ config = ConnectionConfig.DEFAULT;
+ }
+ entry.assignConnection(this.connFactory.create(route, config));
+ }
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Connection leased: " + format(entry) + formatStats(route));
+ }
+ return poolProxy;
}
@Override
public void releaseConnection(
final HttpClientConnection managedConn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepAlive, final TimeUnit timeUnit) {
Args.notNull(managedConn, "Managed connection");
synchronized (managedConn) {
- final CPoolEntry entry = CPoolProxy.detach(managedConn);
- if (entry == null) {
+ final CPoolProxy poolProxy = CPoolProxy.getProxy(managedConn);
+ if (poolProxy.isDetached()) {
return;
}
- final ManagedHttpClientConnection conn = entry.getConnection();
+ final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = poolProxy.detach();
try {
+ final ManagedHttpClientConnection conn = entry.getConnection();
if (conn.isOpen()) {
- final TimeUnit effectiveUnit = tunit != null ? tunit : TimeUnit.MILLISECONDS;
- entry.setState(state);
- entry.updateExpiry(keepalive, effectiveUnit);
+ final TimeUnit effectiveUnit = timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS;
+ entry.updateConnection(keepAlive, effectiveUnit, state);
if (this.log.isDebugEnabled()) {
final String s;
- if (keepalive > 0) {
- s = "for " + (double) effectiveUnit.toMillis(keepalive) / 1000 + " seconds";
+ if (keepAlive > 0) {
+ s = "for " + (double) effectiveUnit.toMillis(keepAlive) / 1000 + " seconds";
} else {
s = "indefinitely";
}
@@ -326,7 +366,8 @@ public class PoolingHttpClientConnection
}
}
} finally {
- this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
+ final ManagedHttpClientConnection conn = entry.getConnection();
+ this.pool.release(entry, conn.isOpen() && poolProxy.isRouteComplete());
if (this.log.isDebugEnabled()) {
this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
}
@@ -344,8 +385,8 @@ public class PoolingHttpClientConnection
Args.notNull(route, "HTTP route");
final ManagedHttpClientConnection conn;
synchronized (managedConn) {
- final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
- conn = entry.getConnection();
+ final CPoolProxy poolProxy = CPoolProxy.getProxy(managedConn);
+ conn = poolProxy.getConnection();
}
final HttpHost host;
if (route.getProxyHost() != null) {
@@ -374,8 +415,8 @@ public class PoolingHttpClientConnection
Args.notNull(route, "HTTP route");
final ManagedHttpClientConnection conn;
synchronized (managedConn) {
- final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
- conn = entry.getConnection();
+ final CPoolProxy poolProxy = CPoolProxy.getProxy(managedConn);
+ conn = poolProxy.getConnection();
}
this.connectionOperator.upgrade(conn, route.getTargetHost(), context);
}
@@ -388,8 +429,8 @@ public class PoolingHttpClientConnection
Args.notNull(managedConn, "Managed Connection");
Args.notNull(route, "HTTP route");
synchronized (managedConn) {
- final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
- entry.markRouteComplete();
+ final CPoolProxy poolProxy = CPoolProxy.getProxy(managedConn);
+ poolProxy.markRouteComplete();
}
}
@@ -397,17 +438,13 @@ public class PoolingHttpClientConnection
public void shutdown() {
if (this.isShutDown.compareAndSet(false, true)) {
this.log.debug("Connection manager is shutting down");
- try {
- this.pool.shutdown();
- } catch (final IOException ex) {
- this.log.debug("I/O exception shutting down connection manager", ex);
- }
+ this.pool.shutdown();
this.log.debug("Connection manager shut down");
}
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdle(final long idleTimeout, final TimeUnit tunit) {
if (this.log.isDebugEnabled()) {
this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
}
@@ -415,16 +452,16 @@ public class PoolingHttpClientConnection
}
@Override
- public void closeExpiredConnections() {
+ public void closeExpired() {
this.log.debug("Closing expired connections");
this.pool.closeExpired();
}
- protected void enumAvailable(final PoolEntryCallback<HttpRoute, ManagedHttpClientConnection> callback) {
+ protected void enumAvailable(final Callback<PoolEntry<HttpRoute, ManagedHttpClientConnection>> callback) {
this.pool.enumAvailable(callback);
}
- protected void enumLeased(final PoolEntryCallback<HttpRoute, ManagedHttpClientConnection> callback) {
+ protected void enumLeased(final Callback<PoolEntry<HttpRoute, ManagedHttpClientConnection>> callback) {
this.pool.enumLeased(callback);
}
@@ -513,7 +550,7 @@ public class PoolingHttpClientConnection
* @since 4.4
*/
public int getValidateAfterInactivity() {
- return pool.getValidateAfterInactivity();
+ return validateAfterInactivity;
}
/**
@@ -528,7 +565,7 @@ public class PoolingHttpClientConnection
* @since 4.4
*/
public void setValidateAfterInactivity(final int ms) {
- pool.setValidateAfterInactivity(ms);
+ validateAfterInactivity = ms;
}
static class ConfigData {
@@ -577,39 +614,5 @@ public class PoolingHttpClientConnection
}
}
-
- static class InternalConnectionFactory implements ConnFactory<HttpRoute, ManagedHttpClientConnection> {
-
- private final ConfigData configData;
- private final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory;
-
- InternalConnectionFactory(
- final ConfigData configData,
- final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory) {
- super();
- this.configData = configData != null ? configData : new ConfigData();
- this.connFactory = connFactory != null ? connFactory :
- ManagedHttpClientConnectionFactory.INSTANCE;
- }
-
- @Override
- public ManagedHttpClientConnection create(final HttpRoute route) throws IOException {
- ConnectionConfig config = null;
- if (route.getProxyHost() != null) {
- config = this.configData.getConnectionConfig(route.getProxyHost());
- }
- if (config == null) {
- config = this.configData.getConnectionConfig(route.getTargetHost());
- }
- if (config == null) {
- config = this.configData.getDefaultConnectionConfig();
- }
- if (config == null) {
- config = ConnectionConfig.DEFAULT;
- }
- return this.connFactory.create(route, config);
- }
-
- }
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/Wire.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/Wire.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/Wire.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/Wire.java Tue Dec 27 19:48:07 2016
@@ -30,7 +30,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
import org.apache.logging.log4j.Logger;
@@ -39,7 +40,7 @@ import org.apache.logging.log4j.Logger;
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
class Wire {
private final Logger log;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/protocol/DefaultAuthenticationStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/protocol/DefaultAuthenticationStrategy.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/protocol/DefaultAuthenticationStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/protocol/DefaultAuthenticationStrategy.java Tue Dec 27 19:48:07 2016
@@ -43,7 +43,8 @@ import org.apache.hc.client5.http.config
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.protocol.AuthenticationStrategy;
import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
@@ -55,7 +56,7 @@ import org.apache.logging.log4j.Logger;
*
* @since 5.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class DefaultAuthenticationStrategy implements AuthenticationStrategy {
private final Logger log = LogManager.getLogger(getClass());