Skip to content

Commit

Permalink
Use SharedExecutorService in more locations (#42468)
Browse files Browse the repository at this point in the history
Use SharedExecutorService in more locations
  • Loading branch information
alzimmermsft authored and billwert committed Jan 10, 2025
1 parent 78851f4 commit 72074c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.azure.core.util.ClientOptions;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.SharedExecutorService;
import com.azure.core.util.UserAgentUtil;
import com.azure.core.util.builder.ClientBuilderUtil;
import com.azure.core.util.logging.ClientLogger;
Expand Down Expand Up @@ -269,6 +270,8 @@ ConfidentialClientApplication getConfidentialClient(boolean enableCae) {

if (options.getExecutorService() != null) {
applicationBuilder.executorService(options.getExecutorService());
} else {
applicationBuilder.executorService(SharedExecutorService.getInstance());
}

TokenCachePersistenceOptions tokenCachePersistenceOptions = options.getTokenCacheOptions();
Expand Down Expand Up @@ -330,6 +333,8 @@ PublicClientApplication getPublicClient(boolean sharedTokenCacheCredential, bool

if (options.getExecutorService() != null) {
builder.executorService(options.getExecutorService());
} else {
builder.executorService(SharedExecutorService.getInstance());
}

if (enableCae) {
Expand Down Expand Up @@ -446,6 +451,8 @@ ConfidentialClientApplication getManagedIdentityConfidentialClient() {

if (options.getExecutorService() != null) {
applicationBuilder.executorService(options.getExecutorService());
} else {
applicationBuilder.executorService(SharedExecutorService.getInstance());
}

return applicationBuilder.build();
Expand Down Expand Up @@ -483,6 +490,8 @@ ManagedIdentityApplication getManagedIdentityMsalApplication() {

if (options.getExecutorService() != null) {
miBuilder.executorService(options.getExecutorService());
} else {
miBuilder.executorService(SharedExecutorService.getInstance());
}

return miBuilder.build();
Expand Down Expand Up @@ -524,6 +533,8 @@ ConfidentialClientApplication getWorkloadIdentityConfidentialClient() {

if (options.getExecutorService() != null) {
applicationBuilder.executorService(options.getExecutorService());
} else {
applicationBuilder.executorService(SharedExecutorService.getInstance());
}

return applicationBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public void flush(boolean awaitLock, boolean isClose, Duration timeout, Context
private void flushLoop(boolean isClosed, Duration timeout, Context context) {
if (timeout != null && !timeout.isNegative() && !timeout.isZero()) {
final AtomicReference<List<TryTrackingIndexAction<T>>> batchActions = new AtomicReference<>();
Future<?> future
= SharedExecutorService.getInstance().submit(() -> flushLoopHelper(isClosed, context, batchActions));
Future<?> future = SharedExecutorService.getInstance()
.submit(() -> flushLoopHelper(isClosed, context, batchActions));

try {
CoreUtils.getResultWithTimeout(future, timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,8 @@ public Response<TableClient> createTableIfNotExistsWithResponse(String tableName
Context context) {
Supplier<Response<TableClient>> callable = () -> createTableIfNotExistsWithResponse(tableName, context);
Response<TableClient> returnedResponse = callWithOptionalTimeout(callable, timeout, logger, true);
return returnedResponse.getValue() == null
? new SimpleResponse<>(returnedResponse.getRequest(), returnedResponse.getStatusCode(),
returnedResponse.getHeaders(), getTableClient(tableName))
: returnedResponse;
return returnedResponse.getValue() == null ? new SimpleResponse<>(returnedResponse.getRequest(),
returnedResponse.getStatusCode(), returnedResponse.getHeaders(), getTableClient(tableName)) : returnedResponse;
}

Response<TableClient> createTableIfNotExistsWithResponse(String tableName, Context context) {
Expand Down

0 comments on commit 72074c5

Please sign in to comment.