Source:
private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) { if (publicClientApplication != null) { return publicClientApplication; } else if (clientId == null) { return null; } else { String authorityUrl = options.getAuthorityHost().replaceAll("/+$", "") + "/organizations/" + tenantId; PublicClientApplication.Builder publicClientApplicationBuilder = PublicClientApplication.builder(clientId); try { publicClientApplicationBuilder = publicClientApplicationBuilder.authority(authorityUrl); } catch (MalformedURLException e) { throw logger.logExceptionAsWarning(new IllegalStateException(e)); } HttpPipeline httpPipeline = options.getHttpPipeline(); if (httpPipeline != null) { httpPipelineAdapter = new HttpPipelineAdapter(httpPipeline); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } else { HttpClient httpClient = options.getHttpClient(); if (httpClient != null) { httpPipelineAdapter = new HttpPipelineAdapter(setupPipeline(httpClient)); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } else if (options.getProxyOptions() != null) { publicClientApplicationBuilder.proxy(proxyOptionsToJavaNetProxy(options.getProxyOptions())); } else { httpPipelineAdapter = new HttpPipelineAdapter(setupPipeline(HttpClient.createDefault())); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } } if (options.getExecutorService() != null) { publicClientApplicationBuilder.executorService(options.getExecutorService()); } if (options.isSharedTokenCacheEnabled()) { try { publicClientApplicationBuilder.setTokenCacheAccessAspect( new PersistenceTokenCacheAccessAspect(options.getPersistenceSettings())); } catch (Throwable t) { if (sharedTokenCacheCredential) { throw logger.logExceptionAsError(new CredentialUnavailableException( "Shared token cache is unavailable in this environment.", t)); } else { throw logger.logExceptionAsError(new ClientAuthenticationException( "Shared token cache is unavailable in this environment.", null, t)); } } } this.publicClientApplication = publicClientApplicationBuilder.build(); return this.publicClientApplication; } }

Target:
private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) { if (publicClientApplication != null) { return publicClientApplication; } else if (clientId == null) { throw logger.logExceptionAsError(new IllegalArgumentException( "A non-null value for client ID must be provided for user authentication.")); } else { String authorityUrl = options.getAuthorityHost().replaceAll("/+$", "") + "/" + tenantId; PublicClientApplication.Builder publicClientApplicationBuilder = PublicClientApplication.builder(clientId); try { publicClientApplicationBuilder = publicClientApplicationBuilder.authority(authorityUrl); } catch (MalformedURLException e) { throw logger.logExceptionAsWarning(new IllegalStateException(e)); } HttpPipeline httpPipeline = options.getHttpPipeline(); if (httpPipeline != null) { httpPipelineAdapter = new HttpPipelineAdapter(httpPipeline); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } else { HttpClient httpClient = options.getHttpClient(); if (httpClient != null) { httpPipelineAdapter = new HttpPipelineAdapter(setupPipeline(httpClient)); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } else if (options.getProxyOptions() != null) { publicClientApplicationBuilder.proxy(proxyOptionsToJavaNetProxy(options.getProxyOptions())); } else { httpPipelineAdapter = new HttpPipelineAdapter(setupPipeline(HttpClient.createDefault())); publicClientApplicationBuilder.httpClient(httpPipelineAdapter); } } if (options.getExecutorService() != null) { publicClientApplicationBuilder.executorService(options.getExecutorService()); } if (options.isSharedTokenCacheEnabled()) { try { publicClientApplicationBuilder.setTokenCacheAccessAspect( new PersistenceTokenCacheAccessAspect(options.getPersistenceSettings())); } catch (Throwable t) { String message = "Shared token cache is unavailable in this environment."; if (sharedTokenCacheCredential) { throw logger.logExceptionAsError(new CredentialUnavailableException(message, t)); } else { throw logger.logExceptionAsError(new ClientAuthenticationException(message, null, t)); } } } this.publicClientApplication = publicClientApplicationBuilder.build(); return this.publicClientApplication; } }