@Override @Deprecated public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) { setCancellable(new Cancellable() { @Override public boolean cancel() { try { releaseTrigger.abortConnection(); return true; } catch (final IOException ex) { return false; } } }); }
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) throws IOException { if (this.aborted) { throw new IOException("Request already aborted"); } this.abortLock.lock(); try { this.releaseTrigger = releaseTrigger; } finally { this.abortLock.unlock(); } }
@Deprecated public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) { setCancellable(new Cancellable() { public boolean cancel() { try { releaseTrigger.abortConnection(); return true; } catch (final IOException ex) { return false; } } }); }
public static void a(InputStream paramInputStream) { if ((paramInputStream instanceof ConnectionReleaseTrigger)) {} try { ((ConnectionReleaseTrigger)paramInputStream).abortConnection(); return; } catch (Throwable localThrowable) {} }
@Override public InputStream getBody() throws IOException { final InputStream body = response.getBody(); return new FilterInputStream(body) { @Override public void close() throws IOException { if (body instanceof ConnectionReleaseTrigger) { // effectively releasing the connection back to the pool in order to prevent starvation ConnectionReleaseTrigger.class.cast(body).abortConnection(); } super.close(); } }; }
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) throws IOException { this.abortLock.lock(); try { if (this.aborted) { throw new IOException("Request already aborted"); } this.connRequest = null; this.releaseTrigger = releaseTrigger; } finally { this.abortLock.unlock(); } }
public void abort() { ClientConnectionRequest localRequest; ConnectionReleaseTrigger localTrigger; this.abortLock.lock(); try { if (this.aborted) { return; } this.aborted = true; localRequest = connRequest; localTrigger = releaseTrigger; } finally { this.abortLock.unlock(); } // Trigger the callbacks outside of the lock, to prevent // deadlocks in the scenario where the callbacks have // their own locks that may be used while calling // setReleaseTrigger or setConnectionRequest. if (localRequest != null) { localRequest.abortRequest(); } if (localTrigger != null) { try { localTrigger.abortConnection(); } catch (IOException ex) { // ignore } } }
/** * Sets the {@link ConnectionReleaseTrigger} callback that can * be used to abort an active connection. * Typically, this will be the {@link ManagedClientConnection} itself. * If the request is already aborted, throws an {@link IOException}. */ void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
/** * Sets the {@link ConnectionReleaseTrigger} callback that can * be used to abort an active connection. * Typically, this will be the * {@link org.apache.http.conn.ManagedClientConnection} itself. * If the request is already aborted, throws an {@link IOException}. */ void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;