@Override public boolean isDestroyed() { return client.isClosed(); } }
protected void closeRuntime(boolean async) { if (!options.runtime().isClosed()) { if (!options.runtimeShared()) { if (async) { // AHC is broken when calling closeAsynchronously. // https://github.com/AsyncHttpClient/async-http-client/issues/290 final ExecutorService e = Executors.newSingleThreadExecutor(); e.submit(new Runnable() { @Override public void run() { options.runtime().close(); e.shutdown(); } }); } else { options.runtime().close(); } } else { logger.warn("Cannot close underlying AsyncHttpClient because it is shared. Make sure you close it manually."); } } }
protected void closeRuntime(boolean async) { if (!options.runtime().isClosed()) { if (!options.runtimeShared()) { if (async) { // AHC is broken when calling closeAsynchronously. // https://github.com/AsyncHttpClient/async-http-client/issues/290 final ExecutorService e = Executors.newSingleThreadExecutor(); e.submit(new Runnable() { @Override public void run() { options.runtime().close(); e.shutdown(); } }); } else { options.runtime().close(); } } else { logger.warn("Cannot close underlying AsyncHttpClient because it is shared. Make sure you close it manually."); } } }
public static Socket create(Options options, Class<? extends Socket> socket) { AsyncHttpClient asyncHttpClient = options.runtime(); if (asyncHttpClient == null || asyncHttpClient.isClosed()) { asyncHttpClient = ClientUtil.createDefaultAsyncHttpClient(options); options.runtime(asyncHttpClient); } return getSocket(options, socket); }
public static Socket create(Options options, Class<? extends Socket> socket) { AsyncHttpClient asyncHttpClient = options.runtime(); if (asyncHttpClient == null || asyncHttpClient.isClosed()) { asyncHttpClient = ClientUtil.createDefaultAsyncHttpClient(options); options.runtime(asyncHttpClient); } return getSocket(options, socket); }
public synchronized void executeRequest(final File file, final AsyncCompletionHandler<Response> completionHandler) { if (isClosed.get()) { return; } if (client == null || client.isClosed()) { client = createClient(); } final Request request = createPostRequest(file); try { client.executeRequest(request, completionHandler); } catch (Exception e) { // Recycle the client on IOException and RuntimeExceptions client.close(); client = createClient(); completionHandler.onThrowable(e); } }
public SerializedSocket(SerializedOptions options) { super(options); if (options.runtime() == null || options.runtime().isClosed()) { asyncHttpClient = ClientUtil.createDefaultAsyncHttpClient(options); options.runtime(asyncHttpClient); } this.serializedFireStage = options.serializedFireStage(); if (serializedFireStage == null) { serializedFireStage = new DefaultSerializedFireStage(); } this.serializedFireStage.setSocket(this); }
public SerializedSocket(SerializedOptions options) { super(options); if (options.runtime() == null || options.runtime().isClosed()) { asyncHttpClient = ClientUtil.createDefaultAsyncHttpClient(options); options.runtime(asyncHttpClient); } this.serializedFireStage = options.serializedFireStage(); if (serializedFireStage == null) { serializedFireStage = new DefaultSerializedFireStage(); } this.serializedFireStage.setSocket(this); }