diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index 0d60388a11425..f298aa6ee05bc 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -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) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index f514dbb5aee02..1135ef8e226bd 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -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; @@ -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; @@ -718,10 +720,10 @@ public PagedFlux listEntities(ListEntitiesOptions options) { token -> withContext(context -> listEntitiesNextPage(token, context, options, TableEntity.class))); } - PagedFlux listEntities(ListEntitiesOptions options, Context context) { + PagedFlux 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 Mono> listEntitiesFirstPage(Context context, diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index acf152ded049f..1ed5be2fcd6d1 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -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; /** @@ -466,7 +465,7 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(applyOptionalTimeout(client.listEntities(options, context), timeout)); + return new PagedIterable<>(client.listEntities(options, context, timeout)); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java index 4a4c505fd0701..4c1637af87ecb 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java @@ -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; /** @@ -391,10 +393,10 @@ public PagedFlux listTables(ListTablesOptions options) { token -> withContext(context -> listTablesNextPage(token, context, options))); } - PagedFlux listTables(ListTablesOptions options, Context context) { + PagedFlux 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> listTablesFirstPage(Context context, ListTablesOptions options) { diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index b25d8b80c63b3..48ee3e29c3b55 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -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; /** @@ -301,7 +300,7 @@ public PagedIterable listTables() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(applyOptionalTimeout(client.listTables(options, context), timeout)); + return new PagedIterable<>(client.listTables(options, context, timeout)); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 9ee9a7da101a0..f98603f5318f6 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -4,7 +4,6 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.CoreUtils; @@ -122,18 +121,6 @@ public static Flux applyOptionalTimeout(Flux 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 Return type of the {@link PagedFlux}. - * @return {@link PagedFlux} with an applied timeout, if any. - */ - public static PagedFlux applyOptionalTimeout(PagedFlux publisher, Duration timeout) { - return timeout == null ? publisher : (PagedFlux) publisher.timeout(timeout); - } - /** * Blocks an asynchronous response with an optional timeout. *