Skip to content

Commit

Permalink
Delete ExecutorService, because it's not used any more. (Azure#15537)
Browse files Browse the repository at this point in the history
Co-authored-by: Rujun Chen <rujche@microsoft.com>
  • Loading branch information
Rujun Chen and rujche authored Sep 24, 2020
1 parent 91cba02 commit 7a30cfa
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -193,9 +190,7 @@ public IAuthenticationResult acquireTokenForGraphApi(String idToken, String tena
final IClientCredential clientCredential = ClientCredentialFactory.createFromSecret(clientSecret);
final UserAssertion assertion = new UserAssertion(idToken);
IAuthenticationResult result = null;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
final ConfidentialClientApplication application = ConfidentialClientApplication
.builder(clientId, clientCredential)
.authority(serviceEndpoints.getAadSigninUri() + tenantId + "/")
Expand All @@ -204,8 +199,7 @@ public IAuthenticationResult acquireTokenForGraphApi(String idToken, String tena
final Set<String> scopes = new HashSet<>();
scopes.add(graphApiVersionIsV2 ? MICROSOFT_GRAPH_SCOPE : AAD_GRAPH_API_SCOPE);
final OnBehalfOfParameters onBehalfOfParameters = OnBehalfOfParameters.builder(scopes, assertion).build();
final CompletableFuture<IAuthenticationResult> future = application.acquireToken(onBehalfOfParameters);
result = future.get();
result = application.acquireToken(onBehalfOfParameters).get();
} catch (ExecutionException | InterruptedException | MalformedURLException e) {
// Handle conditional access policy
final Throwable cause = e.getCause();
Expand All @@ -216,10 +210,6 @@ public IAuthenticationResult acquireTokenForGraphApi(String idToken, String tena
}
}
LOGGER.error("acquire on behalf of token for graph api error", e);
} finally {
if (service != null) {
service.shutdown();
}
}
if (result == null) {
throw new ServiceUnavailableException("unable to acquire on-behalf-of token for client " + clientId);
Expand Down

0 comments on commit 7a30cfa

Please sign in to comment.