Skip to content

Commit 3f90501

Browse files
authored
[Tables] Adjust catch level to exception (Azure#44063)
* Adjust catch level to exception * Moving test to a class that doesn't extend TestProxyTestBase * Fixing analyze issues * Fixing analyze issues
1 parent ae43260 commit 3f90501

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public static <T> Response<T> callWithOptionalTimeout(Supplier<Response<T>> call
344344
ClientLogger logger, boolean skip409Logging) {
345345
try {
346346
return callHandler(callable, timeout, logger);
347-
} catch (Throwable thrown) {
347+
} catch (Exception thrown) {
348348
Throwable exception = mapThrowableToTableServiceException(thrown);
349349
if (exception instanceof TableServiceException) {
350350
TableServiceException e = (TableServiceException) exception;

sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientBuilderTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import com.azure.core.test.utils.MockTokenCredential;
1818
import com.azure.core.util.ClientOptions;
1919
import com.azure.core.util.Header;
20+
import com.azure.core.util.logging.ClientLogger;
21+
import com.azure.data.tables.implementation.TableUtils;
2022
import org.junit.jupiter.api.BeforeEach;
2123
import org.junit.jupiter.api.Test;
2224
import reactor.core.publisher.Mono;
@@ -269,6 +271,15 @@ public void multipleFormsOfAuthenticationPresent() {
269271
.buildAsyncClient());
270272
}
271273

274+
@Test
275+
void nonRuntimeExceptionsDontGetCasted() {
276+
assertThrows(Error.class, () -> {
277+
TableUtils.callWithOptionalTimeout(() -> {
278+
throw new NoClassDefFoundError("This is an error");
279+
}, null, new ClientLogger(TableClientTest.class));
280+
});
281+
}
282+
272283
@Test
273284
public void bothRetryOptionsAndRetryPolicyPresent() {
274285
assertThrows(IllegalStateException.class,

sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@
4747
import java.util.Map;
4848
import java.util.UUID;
4949

50-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
51-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
52-
import static org.junit.jupiter.api.Assertions.assertEquals;
53-
import static org.junit.jupiter.api.Assertions.assertNotNull;
54-
import static org.junit.jupiter.api.Assertions.assertNull;
55-
import static org.junit.jupiter.api.Assertions.assertTrue;
56-
import static org.junit.jupiter.api.Assertions.fail;
50+
import static org.junit.jupiter.api.Assertions.*;
5751

5852
/**
5953
* Tests {@link TableClient}.

0 commit comments

Comments
 (0)