hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1495520 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
Date Fri, 21 Jun 2013 17:51:18 GMT
Author: olegk
Date: Fri Jun 21 17:51:17 2013
New Revision: 1495520

URL: http://svn.apache.org/r1495520
Log:
Added #onLease/#onRelease callbacks to both blocking and non-blocking connection pool implementations

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1495520&r1=1495519&r2=1495520&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
Fri Jun 21 17:51:17 2013
@@ -180,6 +180,18 @@ public abstract class AbstractNIOConnPoo
 
     protected abstract E createEntry(T route, C conn);
 
+    /**
+     * @since 4.3
+     */
+    protected void onLease(final E entry) {
+    }
+
+    /**
+     * @since 4.3
+     */
+    protected void onRelease(final E entry) {
+    }
+
     public boolean isShutdown() {
         return this.isShutDown.get();
     }
@@ -287,6 +299,7 @@ public abstract class AbstractNIOConnPoo
                 pool.free(entry, reusable);
                 if (reusable) {
                     this.available.addFirst(entry);
+                    onRelease(entry);
                 } else {
                     entry.close();
                 }
@@ -359,6 +372,7 @@ public abstract class AbstractNIOConnPoo
             this.available.remove(entry);
             this.leased.add(entry);
             request.completed(entry);
+            onLease(entry);
             return true;
         }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java?rev=1495520&r1=1495519&r2=1495520&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
Fri Jun 21 17:51:17 2013
@@ -97,6 +97,18 @@ public abstract class AbstractConnPool<T
      */
     protected abstract E createEntry(T route, C conn);
 
+    /**
+     * @since 4.3
+     */
+    protected void onLease(final E entry) {
+    }
+
+    /**
+     * @since 4.3
+     */
+    protected void onRelease(final E entry) {
+    }
+
     public boolean isShutdown() {
         return this.isShutDown;
     }
@@ -162,7 +174,9 @@ public abstract class AbstractConnPool<T
                     final long timeout,
                     final TimeUnit tunit)
                         throws InterruptedException, TimeoutException, IOException {
-                return getPoolEntryBlocking(route, state, timeout, tunit, this);
+                final E entry = getPoolEntryBlocking(route, state, timeout, tunit, this);
+                onLease(entry);
+                return entry;
             }
 
         };
@@ -306,6 +320,7 @@ public abstract class AbstractConnPool<T
                 pool.free(entry, reusable);
                 if (reusable && !this.isShutDown) {
                     this.available.addFirst(entry);
+                    onRelease(entry);
                 } else {
                     entry.close();
                 }



Mime
View raw message