File tree Expand file tree Collapse file tree
httpclient5/src/main/java/org/apache/hc/client5/http/impl/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434import org .apache .hc .core5 .io .ModalCloseable ;
3535import org .apache .hc .core5 .pool .DisposalCallback ;
3636
37+ /**
38+ * {@link DisposalCallback} that defers graceful connection disposal so it can
39+ * be executed outside core pool synchronization.
40+ * <p>
41+ * Calls with {@link CloseMode#IMMEDIATE} are delegated directly to the
42+ * underlying callback on the caller thread. All other modes are queued and
43+ * later disposed with {@link CloseMode#GRACEFUL} when {@link #drain()} is
44+ * invoked by {@link PoolingHttpClientConnectionManager}.
45+ *
46+ * @since 5.6
47+ */
3748@ Internal
3849final class OffLockDisposalCallback <T extends ModalCloseable > implements DisposalCallback <T > {
3950
Original file line number Diff line number Diff line change 4646import org .apache .hc .core5 .http .config .RegistryBuilder ;
4747import org .apache .hc .core5 .http .io .HttpConnectionFactory ;
4848import org .apache .hc .core5 .http .io .SocketConfig ;
49+ import org .apache .hc .core5 .io .CloseMode ;
4950import org .apache .hc .core5 .pool .PoolConcurrencyPolicy ;
5051import org .apache .hc .core5 .pool .PoolReusePolicy ;
5152import org .apache .hc .core5 .util .TimeValue ;
@@ -308,7 +309,17 @@ public final PoolingHttpClientConnectionManagerBuilder useSystemProperties() {
308309 }
309310
310311 /**
311- * Enable/disable off-lock disposal.
312+ * Enable or disable off-lock connection disposal for blocking I/O pools.
313+ * <p>
314+ * When enabled, graceful connection closes are deferred and performed
315+ * outside the core pool synchronization in
316+ * {@link PoolingHttpClientConnectionManager}. This reduces the time spent
317+ * holding internal locks at the cost of slightly more complex disposal
318+ * logic. Immediate closes {@link CloseMode#IMMEDIATE} are still executed
319+ * on the caller thread.
320+ *
321+ * @param enabled {@code true} to enable off-lock disposal, {@code false} to disable
322+ * @return this builder
312323 * @since 5.6
313324 */
314325 @ Experimental
@@ -317,6 +328,7 @@ public final PoolingHttpClientConnectionManagerBuilder setOffLockDisposalEnabled
317328 return this ;
318329 }
319330
331+
320332 @ Internal
321333 protected HttpClientConnectionOperator createConnectionOperator (
322334 final SchemePortResolver schemePortResolver ,
You can’t perform that action at this time.
0 commit comments