From dd406b137535b691d11a6c59192c157712af4463 Mon Sep 17 00:00:00 2001 From: Vijaya Gopal Yarramneni Date: Wed, 26 May 2021 16:25:24 -0700 Subject: [PATCH] Fixing a bug that causes, in rare cases, completable futures to never complete in managemet client. Parsing xml description sometime can throw unexpected runtime exceptions and when that happens, those exceptions were not handled. --- eng/spotbugs-aggregate-report/pom.xml | 2 +- eng/versioning/version_data.txt | 2 +- .../microsoft-azure-servicebus/README.md | 2 +- .../microsoft-azure-servicebus/pom.xml | 2 +- .../management/ManagementClientAsync.java | 48 ++++++++++++------- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/eng/spotbugs-aggregate-report/pom.xml b/eng/spotbugs-aggregate-report/pom.xml index 76255bfab6b03..696b4acfeb9ae 100644 --- a/eng/spotbugs-aggregate-report/pom.xml +++ b/eng/spotbugs-aggregate-report/pom.xml @@ -140,7 +140,7 @@ com.microsoft.azure azure-servicebus - 3.7.0-beta.1 + 3.6.4 diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index b6891c2ea8d52..49f7f4a4c9575 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -34,7 +34,7 @@ com.microsoft.azure:azure-keyvault-cryptography;1.2.4;1.3.0-beta.1 com.microsoft.azure:azure-keyvault-extensions;1.2.4;1.3.0-beta.1 com.microsoft.azure:azure-keyvault-test;1.2.3;1.2.4 com.microsoft.azure:azure-keyvault-webkey;1.2.4;1.3.0-beta.1 -com.microsoft.azure:azure-servicebus;3.6.3;3.7.0-beta.1 +com.microsoft.azure:azure-servicebus;3.6.3;3.6.4 com.microsoft.azure:azure-storage;8.6.5;8.6.5 com.microsoft.azure:azure-storage-blob;11.0.2;11.0.2 com.microsoft.azure.msi_auth_token_provider:azure-authentication-msi-token-provider;1.1.0-beta.1;1.1.0-beta.1 diff --git a/sdk/servicebus/microsoft-azure-servicebus/README.md b/sdk/servicebus/microsoft-azure-servicebus/README.md index 640c8e764fd3f..eb641290067e0 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/README.md +++ b/sdk/servicebus/microsoft-azure-servicebus/README.md @@ -21,7 +21,7 @@ The package can be downloaded from [Maven](https://search.maven.org/artifact/com com.microsoft.azure azure-servicebus - 3.6.3 + 3.6.4 ``` [//]: # ({x-version-update-end}) diff --git a/sdk/servicebus/microsoft-azure-servicebus/pom.xml b/sdk/servicebus/microsoft-azure-servicebus/pom.xml index 1453597960f81..9bbca35e6ed86 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/pom.xml +++ b/sdk/servicebus/microsoft-azure-servicebus/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.microsoft.azure azure-servicebus - 3.7.0-beta.1 + 3.6.4 Microsoft Azure SDK for Service Bus Java library for Azure Service Bus. Please note, a newer package com.azure:azure-messaging-servicebus for Azure Service Bus is available as of December 2020. While this package will continue to receive critical bug fixes, we strongly encourage you to upgrade. Read the migration guide at https://aka.ms/azsdk/java/migrate/sb for more details. diff --git a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java index baf0c83033fbf..36057d0e69ba3 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java +++ b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java @@ -111,7 +111,7 @@ public CompletableFuture getNamespaceInfoAsync() { } else { try { nsInfoFuture.complete(NamespaceInfoSerializer.parseFromContent(content)); - } catch (ServiceBusException e) { + } catch (Exception e) { nsInfoFuture.completeExceptionally(e); } } @@ -138,7 +138,7 @@ public CompletableFuture getQueueAsync(String path) { } else { try { qdFuture.complete(QueueDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { qdFuture.completeExceptionally(e); } } @@ -165,7 +165,7 @@ public CompletableFuture getQueueRuntimeInfoAsync(String path) } else { try { qdFuture.complete(QueueRuntimeInfoSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { qdFuture.completeExceptionally(e); } } @@ -192,7 +192,7 @@ public CompletableFuture getTopicAsync(String path) { } else { try { tdFuture.complete(TopicDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { tdFuture.completeExceptionally(e); } } @@ -219,7 +219,7 @@ public CompletableFuture getTopicRuntimeInfoAsync(String path) } else { try { tdFuture.complete(TopicRuntimeInfoSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { tdFuture.completeExceptionally(e); } } @@ -249,7 +249,7 @@ public CompletableFuture getSubscriptionAsync(String to } else { try { sdFuture.complete(SubscriptionDescriptionSerializer.parseFromContent(topicPath, content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { sdFuture.completeExceptionally(e); } } @@ -279,7 +279,7 @@ public CompletableFuture getSubscriptionRuntimeInfoAsyn } else { try { sdFuture.complete(SubscriptionRuntimeInfoSerializer.parseFromContent(topicPath, content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { sdFuture.completeExceptionally(e); } } @@ -311,7 +311,7 @@ public CompletableFuture getRuleAsync(String topicPath, String } else { try { rdFuture.complete(RuleDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { rdFuture.completeExceptionally(e); } } @@ -352,7 +352,11 @@ public CompletableFuture> getQueuesAsync(int count, int s if (ex != null) { qdFuture.completeExceptionally(ex); } else { - qdFuture.complete(QueueDescriptionSerializer.parseCollectionFromContent(content)); + try { + qdFuture.complete(QueueDescriptionSerializer.parseCollectionFromContent(content)); + } catch (Exception e) { + qdFuture.completeExceptionally(e); + } } return null; }, MessagingFactory.INTERNAL_THREAD_POOL); @@ -391,7 +395,11 @@ public CompletableFuture> getTopicsAsync(int count, int s if (ex != null) { tdFuture.completeExceptionally(ex); } else { - tdFuture.complete(TopicDescriptionSerializer.parseCollectionFromContent(content)); + try { + tdFuture.complete(TopicDescriptionSerializer.parseCollectionFromContent(content)); + } catch (Exception e) { + tdFuture.completeExceptionally(e); + } } return null; }, MessagingFactory.INTERNAL_THREAD_POOL); @@ -434,7 +442,11 @@ public CompletableFuture> getSubscriptionsAsync(St if (ex != null) { sdFuture.completeExceptionally(ex); } else { - sdFuture.complete(SubscriptionDescriptionSerializer.parseCollectionFromContent(topicName, content)); + try { + sdFuture.complete(SubscriptionDescriptionSerializer.parseCollectionFromContent(topicName, content)); + } catch (Exception e) { + sdFuture.completeExceptionally(e); + } } return null; }, MessagingFactory.INTERNAL_THREAD_POOL); @@ -483,7 +495,11 @@ public CompletableFuture> getRulesAsync(String topicName, if (ex != null) { rulesFuture.completeExceptionally(ex); } else { - rulesFuture.complete(RuleDescriptionSerializer.parseCollectionFromContent(content)); + try { + rulesFuture.complete(RuleDescriptionSerializer.parseCollectionFromContent(content)); + } catch (Exception e) { + rulesFuture.completeExceptionally(e); + } } return null; }, MessagingFactory.INTERNAL_THREAD_POOL); @@ -563,7 +579,7 @@ private CompletableFuture putQueueAsync(QueueDescription queue } else { try { responseFuture.complete(QueueDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { responseFuture.completeExceptionally(e); } } @@ -627,7 +643,7 @@ private CompletableFuture putTopicAsync(TopicDescription topic } else { try { responseFuture.complete(TopicDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { responseFuture.completeExceptionally(e); } } @@ -706,7 +722,7 @@ private CompletableFuture putSubscriptionAsync(Subscrip } else { try { responseFuture.complete(SubscriptionDescriptionSerializer.parseFromContent(subscriptionDescription.getTopicPath(), content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { responseFuture.completeExceptionally(e); } } @@ -766,7 +782,7 @@ private CompletableFuture putRuleAsync(String topicName, String } else { try { responseFuture.complete(RuleDescriptionSerializer.parseFromContent(content)); - } catch (MessagingEntityNotFoundException e) { + } catch (Exception e) { responseFuture.completeExceptionally(e); } }