Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue that made TableClient.listEntities() and TableServiceClient.listTables() throw a ClassCastException when passing a non-null value for timeout. #22511

Merged
merged 3 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/tables/azure-data-tables/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug fixes
- Fixed issue where HTTP headers set in a `ClientOptions` object passed to a client builder would not be set on a client instantiated by said builder.
- Fixed an issue where a `connectionString` with an account name and key would override a `sasToken`'s authentication settings in client builders.
- Fixed an issue that made `TableClient.listEntities()` and `TableServiceClient.listTables()` throw a `ClassCastException` when passing a non-null value for `timeout`.

## 12.0.0 (2021-06-11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import reactor.core.scheduler.Schedulers;

import java.net.URI;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -68,6 +69,7 @@
import static com.azure.core.util.CoreUtils.isNullOrEmpty;
import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;
import static com.azure.data.tables.implementation.TableUtils.applyOptionalTimeout;
import static com.azure.data.tables.implementation.TableUtils.swallowExceptionForStatusCode;
import static com.azure.data.tables.implementation.TableUtils.toTableServiceError;

Expand Down Expand Up @@ -718,10 +720,10 @@ public PagedFlux<TableEntity> listEntities(ListEntitiesOptions options) {
token -> withContext(context -> listEntitiesNextPage(token, context, options, TableEntity.class)));
}

PagedFlux<TableEntity> listEntities(ListEntitiesOptions options, Context context) {
PagedFlux<TableEntity> listEntities(ListEntitiesOptions options, Context context, Duration timeout) {
return new PagedFlux<>(
() -> listEntitiesFirstPage(context, options, TableEntity.class),
token -> listEntitiesNextPage(token, context, options, TableEntity.class));
() -> applyOptionalTimeout(listEntitiesFirstPage(context, options, TableEntity.class), timeout),
token -> applyOptionalTimeout(listEntitiesNextPage(token, context, options, TableEntity.class), timeout));
}

private <T extends TableEntity> Mono<PagedResponse<T>> listEntitiesFirstPage(Context context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.time.Duration;
import java.util.List;

import static com.azure.data.tables.implementation.TableUtils.applyOptionalTimeout;
import static com.azure.data.tables.implementation.TableUtils.blockWithOptionalTimeout;

/**
Expand Down Expand Up @@ -466,7 +465,7 @@ public PagedIterable<TableEntity> listEntities() {
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<TableEntity> listEntities(ListEntitiesOptions options, Duration timeout, Context context) {
return new PagedIterable<>(applyOptionalTimeout(client.listEntities(options, context), timeout));
return new PagedIterable<>(client.listEntities(options, context, timeout));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@
import reactor.core.publisher.Mono;

import java.net.URI;
import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;
import static com.azure.data.tables.implementation.TableUtils.applyOptionalTimeout;
import static com.azure.data.tables.implementation.TableUtils.swallowExceptionForStatusCode;

/**
Expand Down Expand Up @@ -391,10 +393,10 @@ public PagedFlux<TableItem> listTables(ListTablesOptions options) {
token -> withContext(context -> listTablesNextPage(token, context, options)));
}

PagedFlux<TableItem> listTables(ListTablesOptions options, Context context) {
PagedFlux<TableItem> listTables(ListTablesOptions options, Context context, Duration timeout) {
return new PagedFlux<>(
() -> listTablesFirstPage(context, options),
token -> listTablesNextPage(token, context, options));
() -> applyOptionalTimeout(listTablesFirstPage(context, options), timeout),
token -> applyOptionalTimeout(listTablesNextPage(token, context, options), timeout));
}

private Mono<PagedResponse<TableItem>> listTablesFirstPage(Context context, ListTablesOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.time.Duration;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.data.tables.implementation.TableUtils.applyOptionalTimeout;
import static com.azure.data.tables.implementation.TableUtils.blockWithOptionalTimeout;

/**
Expand Down Expand Up @@ -301,7 +300,7 @@ public PagedIterable<TableItem> listTables() {
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<TableItem> listTables(ListTablesOptions options, Duration timeout, Context context) {
return new PagedIterable<>(applyOptionalTimeout(client.listTables(options, context), timeout));
return new PagedIterable<>(client.listTables(options, context, timeout));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ public static <T> Flux<T> applyOptionalTimeout(Flux<T> publisher, Duration timeo
return timeout == null ? publisher : publisher.timeout(timeout);
}

/**
* Applies a timeout to a {@link PagedFlux publisher} if the given timeout is not null.
*
* @param publisher {@link PagedFlux} to apply optional timeout to.
* @param timeout Optional timeout.
* @param <T> Return type of the {@link PagedFlux}.
* @return {@link PagedFlux} with an applied timeout, if any.
*/
public static <T> PagedFlux<T> applyOptionalTimeout(PagedFlux<T> publisher, Duration timeout) {
return timeout == null ? publisher : (PagedFlux<T>) publisher.timeout(timeout);
}

/**
* Blocks an asynchronous response with an optional timeout.
*
Expand Down