From 6e86a45272247b9ec3d16cdf595a99e6ebd47640 Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Mon, 4 Dec 2023 14:02:44 -0800 Subject: [PATCH] Remove unnecessary warnings in administration client (#37915) * Removing extraneous warning logs. * Add CHANGELOG entry. --- .../azure-messaging-servicebus/CHANGELOG.md | 2 ++ .../AdministrationModelConverter.java | 14 ++++---------- .../ServiceBusManagementSerializer.java | 8 +++----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md b/sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md index de82fa0517cec..e3571d83ff873 100644 --- a/sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Removes extraneous log messages when deserializing topics or subscriptions. ([32325](https://github.com/Azure/azure-sdk-for-java/issues/32325)) + ### Other Changes ## 7.15.0-beta.5 (2023-11-22) diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/AdministrationModelConverter.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/AdministrationModelConverter.java index eaca793a23c61..6f44f3d59fdaa 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/AdministrationModelConverter.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/AdministrationModelConverter.java @@ -432,11 +432,8 @@ private T deserialize(Object object, Class clazz) { Response deserializeQueue(Response response) { final QueueDescriptionEntryImpl entry = deserialize(response.getValue(), QueueDescriptionEntryImpl.class); - // This was an empty response (ie. 204). - if (entry == null) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); - } else if (entry.getContent() == null) { - logger.info("entry.getContent() is null. The entity may not exist. {}", entry); + // This was an empty response (ie. 204) or the entity does not exist. + if (entry == null || entry.getContent() == null) { return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); } else if (entry.getContent().getQueueDescription() == null) { final TopicDescriptionEntryImpl entryTopic = deserialize(response.getValue(), TopicDescriptionEntryImpl.class); @@ -455,11 +452,8 @@ Response deserializeQueue(Response response) { Response deserializeTopic(Response response) { final TopicDescriptionEntryImpl entry = deserialize(response.getValue(), TopicDescriptionEntryImpl.class); - // This was an empty response (ie. 204). - if (entry == null) { - return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); - } else if (entry.getContent() == null) { - logger.warning("entry.getContent() is null. There should have been content returned. Entry: {}", entry); + // This was an empty response (i.e. 204) or the entity does not exist. + if (entry == null || entry.getContent() == null) { return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); } else if (entry.getContent().getTopicDescription() == null) { final QueueDescriptionEntryImpl entryQueue = deserialize(response.getValue(), QueueDescriptionEntryImpl.class); diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/implementation/ServiceBusManagementSerializer.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/implementation/ServiceBusManagementSerializer.java index d49a826c34823..bf42ecd497376 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/implementation/ServiceBusManagementSerializer.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/implementation/ServiceBusManagementSerializer.java @@ -70,23 +70,21 @@ public String serialize(Object object, SerializerEncoding encoding) throws IOExc // This hack is here because value of custom property within RuleFilter should have a namespace like // xmlns:d6p1="http://www.w3.org/2001/XMLSchema" ns0:type="d6p1:string". + // It is possible that there is no "Value" to set in the rule. if (CreateRuleBodyImpl.class.equals(clazz)) { final Matcher filterValue = FILTER_VALUE_PATTERN.matcher(replaced); if (filterValue.find()) { replaced = filterValue.replaceAll(RULE_VALUE_ATTRIBUTE_XML); - } else { - LOGGER.warning("Could not find filter name pattern '{}' in {}.", FILTER_VALUE_PATTERN.pattern(), - contents); } } // This hack is here because RuleFilter and RuleAction type="Foo" should have a namespace like n0:type="Foo". + // It is possible that there is no RuleFilter or RuleAction type. (i.e. creating a subscription with its + // default rule.) final Matcher filterType = FILTER_ACTION_PATTERN.matcher(replaced); if (filterType.find()) { return filterType.replaceAll("<$1 xmlns:ns0=\"http://www.w3.org/2001/XMLSchema-instance\" ns0:type="); } else { - LOGGER.warning("Could not find filter name pattern '{}' in {}.", FILTER_ACTION_PATTERN.pattern(), - contents); return replaced; } }