        public AsyncHttpClientConfig build() {
            if (reaper == null) {
                reaper = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread(r, "AsyncHttpClient-Reaper");
                        t.setDaemon(true);
                        return t;
                    }
                });
            }
            if (applicationThreadPool == null) {
                managedApplicationThreadPool = true;
                int count = Runtime.getRuntime().availableProcessors();
                applicationThreadPool =
                        Executors.newFixedThreadPool(count, new ThreadFactory() {
                            final AtomicInteger counter = new AtomicInteger();
                            public Thread newThread(Runnable r) {
                                Thread t = new Thread(r,
                                                      "AsyncHttpClient-Callback-" + counter.incrementAndGet());
                                t.setDaemon(true);
                                return t;
                            }
                        });
            }
            if (applicationThreadPool.isShutdown()) {
                throw new IllegalStateException("ExecutorServices closed");
            }
            if (proxyServerSelector == null && useProxySelector) {
                proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
            }
            if (proxyServerSelector == null && useProxyProperties) {
                proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());
            }
            if (proxyServerSelector == null) {
                proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;
            }
            return new AsyncHttpClientConfig(defaultMaxTotalConnections,
                    defaultMaxConnectionPerHost,
                    defaultConnectionTimeOutInMs,
                    defaultWebsocketIdleTimeoutInMs,
                    defaultIdleConnectionInPoolTimeoutInMs,
                    defaultIdleConnectionTimeoutInMs,
                    defaultRequestTimeoutInMs,
                    defaultMaxConnectionLifeTimeInMs,
                    redirectEnabled,
                    maxDefaultRedirects,
                    compressionEnabled,
                    userAgent,
                    allowPoolingConnection,
                    reaper,
                    applicationThreadPool,
                    proxyServerSelector,
                    sslContext,
                    sslEngineFactory,
                    providerConfig,
                    connectionsPool,
                    realm,
                    requestFilters,
                    responseFilters,
                    ioExceptionFilters,
                    requestCompressionLevel,
                    maxRequestRetry,
                    allowSslConnectionPool,
                    useRawUrl,
                    removeQueryParamOnRedirect,
                    hostnameVerifier,
                    ioThreadMultiplier,
                    strict302Handling,
                    useRelativeURIsWithSSLProxies,
                    spdyEnabled,
                    spdyInitialWindowSize,
                    spdyMaxConcurrentStreams,
                    rfc6265CookieEncoding,
                    asyncConnectMode,
                    managedApplicationThreadPool);
        }

        public AsyncHttpClientConfig build() {
            if (reaper == null) {
                reaper = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread(r, "AsyncHttpClient-Reaper");
                        t.setDaemon(true);
                        return t;
                    }
                });
            }
            if (applicationThreadPool == null) {
                managedApplicationThreadPool = true;
                applicationThreadPool =
                        Executors.newCachedThreadPool(new ThreadFactory() {
                            final AtomicInteger counter = new AtomicInteger();
                            public Thread newThread(Runnable r) {
                                Thread t = new Thread(r,
                                                      "AsyncHttpClient-Callback-" + counter.incrementAndGet());
                                t.setDaemon(true);
                                return t;
                            }
                        });
            }
            if (applicationThreadPool.isShutdown()) {
                throw new IllegalStateException("ExecutorServices closed");
            }
            if (proxyServerSelector == null && useProxySelector) {
                proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();
            }
            if (proxyServerSelector == null && useProxyProperties) {
                proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());
            }
            if (proxyServerSelector == null) {
                proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;
            }
            return new AsyncHttpClientConfig(defaultMaxTotalConnections,
                    defaultMaxConnectionPerHost,
                    defaultConnectionTimeOutInMs,
                    defaultWebsocketIdleTimeoutInMs,
                    defaultIdleConnectionInPoolTimeoutInMs,
                    defaultIdleConnectionTimeoutInMs,
                    defaultRequestTimeoutInMs,
                    defaultMaxConnectionLifeTimeInMs,
                    redirectEnabled,
                    maxDefaultRedirects,
                    compressionEnabled,
                    userAgent,
                    allowPoolingConnection,
                    reaper,
                    applicationThreadPool,
                    proxyServerSelector,
                    sslContext,
                    sslEngineFactory,
                    providerConfig,
                    connectionsPool,
                    realm,
                    requestFilters,
                    responseFilters,
                    ioExceptionFilters,
                    requestCompressionLevel,
                    maxRequestRetry,
                    allowSslConnectionPool,
                    useRawUrl,
                    removeQueryParamOnRedirect,
                    hostnameVerifier,
                    ioThreadMultiplier,
                    strict302Handling,
                    useRelativeURIsWithSSLProxies,
                    spdyEnabled,
                    spdyInitialWindowSize,
                    spdyMaxConcurrentStreams,
                    rfc6265CookieEncoding,
                    asyncConnectMode,
                    managedApplicationThreadPool);
        }
