mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-17 23:45:33 +00:00
Method to check if the connection manager has been shut down and is closed or not.
This commit is contained in:
parent
4c464b2432
commit
6ba9b4acdc
@ -299,7 +299,7 @@ private void validate() {
|
||||
}
|
||||
|
||||
synchronized ManagedHttpClientConnection getConnection(final HttpRoute route, final Object state) throws IOException {
|
||||
Asserts.check(!this.closed.get(), "Connection manager has been shut down");
|
||||
Asserts.check(!isClosed(), "Connection manager has been shut down");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("{} Get connection for route {}", id, route);
|
||||
}
|
||||
@ -336,7 +336,7 @@ public synchronized void release(final ConnectionEndpoint endpoint, final Object
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("{} Releasing connection {}", id, conn);
|
||||
}
|
||||
if (this.closed.get()) {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -345,7 +345,6 @@ public synchronized void release(final ConnectionEndpoint endpoint, final Object
|
||||
}
|
||||
this.updated = System.currentTimeMillis();
|
||||
if (!this.conn.isOpen() && !this.conn.isConsistent()) {
|
||||
this.conn = null;
|
||||
this.route = null;
|
||||
this.conn = null;
|
||||
this.expiry = Long.MAX_VALUE;
|
||||
@ -427,7 +426,7 @@ public synchronized void upgrade(
|
||||
}
|
||||
|
||||
public synchronized void closeExpired() {
|
||||
if (this.closed.get()) {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
}
|
||||
if (!this.leased) {
|
||||
@ -437,7 +436,7 @@ public synchronized void closeExpired() {
|
||||
|
||||
public synchronized void closeIdle(final TimeValue idleTime) {
|
||||
Args.notNull(idleTime, "Idle time");
|
||||
if (this.closed.get()) {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
}
|
||||
if (!this.leased) {
|
||||
@ -556,4 +555,15 @@ public ClassicHttpResponse execute(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that can be called to determine whether the connection manager has been shut down and
|
||||
* is closed or not.
|
||||
*
|
||||
* @return {@code true} if the connection manager has been shut down and is closed, otherwise
|
||||
* return {@code false}.
|
||||
*/
|
||||
boolean isClosed() {
|
||||
return this.closed.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -686,5 +686,4 @@ public ClassicHttpResponse execute(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -727,4 +727,15 @@ public void execute(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that can be called to determine whether the connection manager has been shut down and
|
||||
* is closed or not.
|
||||
*
|
||||
* @return {@code true} if the connection manager has been shut down and is closed, otherwise
|
||||
* return {@code false}.
|
||||
*/
|
||||
boolean isClosed() {
|
||||
return this.closed.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user