Source:
<T> T clientSetup(Function<HttpPipeline, T> clientBuilder) { final String endpoint = interceptorManager.isPlaybackMode() ? "http://localhost:8080" : System.getenv("AZURE_KEYVAULT_ENDPOINT"); TokenCredential credential; HttpClient httpClient; String tenantId = System.getenv("AZURE_TENANT_ID"); String clientId = System.getenv("AZURE_CLIENT_ID"); String clientSecret = System.getenv("AZURE_CLIENT_SECRET"); if (!interceptorManager.isPlaybackMode()) { assertNotNull(tenantId); assertNotNull(clientId); assertNotNull(clientSecret); } if (interceptorManager.isPlaybackMode()) { credential = resource -> Mono.just(new AccessToken("Some fake token", OffsetDateTime.now(ZoneOffset.UTC).plus(Duration.ofMinutes(30)))); } else { credential = new DefaultAzureCredentialBuilder().build(); } final List<HttpPipelinePolicy> policies = new ArrayList<>(); policies.add(new UserAgentPolicy(null, AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); policies.add(new BearerTokenAuthenticationPolicy(credential, CryptographyAsyncClient.KEY_VAULT_SCOPE)); policies.addAll(policies); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); if (interceptorManager.isPlaybackMode()) { httpClient = interceptorManager.getPlaybackClient(); policies.add(interceptorManager.getRecordPolicy()); } else { httpClient = new NettyAsyncHttpClientBuilder().wiretap(true).build(); policies.add(interceptorManager.getRecordPolicy()); } HttpPipeline pipeline = new HttpPipelineBuilder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .build(); T client; client = clientBuilder.apply(pipeline); return Objects.requireNonNull(client); }

Target:
<T> T clientSetup(Function<HttpPipeline, T> clientBuilder) { final String endpoint = interceptorManager.isPlaybackMode() ? "http://localhost:8080" : System.getenv("AZURE_KEYVAULT_ENDPOINT"); TokenCredential credential; HttpClient httpClient; String tenantId = System.getenv("AZURE_TENANT_ID"); String clientId = System.getenv("AZURE_CLIENT_ID"); String clientSecret = System.getenv("AZURE_CLIENT_SECRET"); if (!interceptorManager.isPlaybackMode()) { assertNotNull(tenantId); assertNotNull(clientId); assertNotNull(clientSecret); } if (interceptorManager.isPlaybackMode()) { credential = resource -> Mono.just(new AccessToken("Some fake token", OffsetDateTime.now(ZoneOffset.UTC).plus(Duration.ofMinutes(30)))); } else { credential = new DefaultAzureCredentialBuilder().build(); } final List<HttpPipelinePolicy> policies = new ArrayList<>(); policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); policies.add(new BearerTokenAuthenticationPolicy(credential, CryptographyAsyncClient.KEY_VAULT_SCOPE)); policies.addAll(policies); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); if (interceptorManager.isPlaybackMode()) { httpClient = interceptorManager.getPlaybackClient(); policies.add(interceptorManager.getRecordPolicy()); } else { httpClient = new NettyAsyncHttpClientBuilder().wiretap(true).build(); policies.add(interceptorManager.getRecordPolicy()); } HttpPipeline pipeline = new HttpPipelineBuilder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .build(); T client; client = clientBuilder.apply(pipeline); return Objects.requireNonNull(client); }