private static OkHttpClient client() {
		return COREUTILS_CONTEXT.getClient(OkHttpClient.class, "coreutils-fiber", () -> {
			final OkHttpClient client = new FiberOkHttpClient();
			try {
				// load default configuration
				final Config config = new Configurer().loadConfig(null, "coreutils");
				final long tmp = config.getBytes("coreutils.clients.http2.cache-size");
				final long cacheSize = CACHE_SIZE_RANGE.contains(tmp) ? tmp : CACHE_SIZE_RANGE.lowerEndpoint();
				// create the cache directory				
				final File cacheDir = createTempDirectory("coreutils-okhttp-cache-", asFileAttribute(fromString("rwx------"))).toFile();
				final Http2ClientShutdownListener shutdownListener = new Http2ClientShutdownListener(cacheDir);
				COREUTILS_CONTEXT.addShutdownListener(shutdownListener, Http2ClientShutdownListener.class, "coreutils-fiber");
				final Cache cache = new Cache(cacheDir, cacheSize);					
				client.setCache(cache);				
			} catch (IOException e) {
				LOGGER.error("Failed to create directory cache", e);
			}
			return client;
		});
	}
private static OkHttpClient client ( ) { return COREUTILS_CONTEXT . getClient ( OkHttpClient . class , "coreutils-fiber" , ( ) -> { final OkHttpClient client = new FiberOkHttpClient ( ) ; try { final Config config = new Configurer ( ) . loadConfig ( null , "coreutils" ) ; final long tmp = config . getBytes ( "coreutils.clients.http2.cache-size" ) ; final long cacheSize = CACHE_SIZE_RANGE . contains ( tmp ) ? tmp : CACHE_SIZE_RANGE . lowerEndpoint ( ) ; final File cacheDir = createTempDirectory ( "coreutils-okhttp-cache-" , asFileAttribute ( fromString ( "rwx------" ) ) ) . toFile ( ) ; final Http2ClientShutdownListener shutdownListener = new Http2ClientShutdownListener ( cacheDir ) ; COREUTILS_CONTEXT . addShutdownListener ( shutdownListener , Http2ClientShutdownListener . class , "coreutils-fiber" ) ; final Cache cache = new Cache ( cacheDir , cacheSize ) ; client . setCache ( cache ) ; } catch ( IOException e ) { LOGGER . error ( "Failed to create directory cache" , e ) ; } return client ; } ) ; }
Creates a {@link OkHttpClient} instance and configures it with a cache. The same instance is used across the application to
benefit from a common cache storage and to prevent cache corruption. The cache directory is created private to the user who
runs the application and its content is deleted when the JVM starts its shutting down sequence.
@return A {@link OkHttpClient} instance that can be used everywhere in the application.