From 23260e7c4e0ccc0aba429c7cfee6a842de91689e Mon Sep 17 00:00:00 2001 From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com> Date: Tue, 22 Jun 2021 13:34:52 -0700 Subject: [PATCH] Fixed Inappropriate Logging and String.format Usage (#22450) Fix Improper Usage of ClientLogger and String Format --- .../checks/FluentMethodNameCheck.java | 3 +- .../ConfigurationSettingJsonDeserializer.java | 6 +- .../opentelemetry/OpenTelemetryTracer.java | 2 +- .../core/http/policy/ProtocolPolicy.java | 2 +- .../core/util/serializer/JacksonAdapter.java | 2 +- .../azure/cosmos/implementation/Utils.java | 2 +- .../directconnectivity/AddressResolver.java | 4 +- .../cosmos/rx/OrderbyDocumentQueryTest.java | 2 +- .../core/DigitalTwinsAsyncClient.java | 2 +- .../EventDataBatchIntegrationTest.java | 4 +- .../EventProcessorClientBuilderTest.java | 10 +- .../eventhubs/IntegrationTestBase.java | 3 +- .../identity/ManagedIdentityCredential.java | 4 +- .../KeyVaultAccessControlAsyncClient.java | 10 +- .../certificates/CertificateAsyncClient.java | 10 +- .../CertificateClientJavaDocCodeSnippets.java | 142 +++++++++--------- .../keyvault/keys/KeyAsyncClient.java | 2 +- .../keyvault/keys/HelloWorldAsync.java | 12 +- .../keyvault/secrets/SecretAsyncClient.java | 2 +- .../CertificateOperationIdentifier.java | 9 +- .../test/CertificateOperationsTest.java | 2 +- .../authentication/AzureAdTokenProvider.java | 2 +- .../ListIncidentRootCausesAsyncSample.java | 2 +- .../ListIncidentRootCausesSample.java | 4 +- .../MetricFeedbackAsyncSample.java | 2 +- .../metricsadvisor/MetricFeedbackSample.java | 2 +- ...AdvisorAsyncClientJavaDocCodeSnippets.java | 8 +- ...tricsAdvisorClientJavaDocCodeSnippets.java | 8 +- ...malyDetectionConfigurationAsyncSample.java | 4 +- .../AnomalyDetectionConfigurationSample.java | 4 +- .../DatasourceCredentialSample.java | 2 +- ...trationAsyncClientJavaDocCodeSnippets.java | 8 +- ...omalyAlertConfigOperationsAsyncSample.java | 6 +- ...icsAnomalyAlertConfigOperationsSample.java | 6 +- .../implementation/FileModelFetcher.java | 2 +- .../implementation/HttpModelFetcher.java | 2 +- .../implementation/StatusStrings.java | 2 +- .../exporter/AzureMonitorRedirectPolicy.java | 2 +- .../implementation/util/FieldBuilder.java | 2 +- .../servicebus/ServiceBusProcessorClient.java | 2 +- .../servicebus/IntegrationTestBase.java | 3 +- .../primitives/CoreMessageSender.java | 12 +- .../StorageConnectionStringTest.java | 3 +- .../synapse/spark/HelloWorldAsync.java | 2 +- .../TablesJacksonSerializer.java | 2 +- 45 files changed, 161 insertions(+), 166 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/FluentMethodNameCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/FluentMethodNameCheck.java index 0a855e77d2b9a..4cf94877f4edc 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/FluentMethodNameCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/FluentMethodNameCheck.java @@ -74,7 +74,8 @@ public void visitToken(DetailAST token) { // logs error if the @Fluent method has 'throws' at the method declaration. if (token.findFirstToken(TokenTypes.LITERAL_THROWS) != null) { log(token, String.format( - "Fluent Method ''%s'' must not be declared to throw any checked exceptions")); + "Fluent Method ''%s'' must not be declared to throw any checked exceptions.", + token.findFirstToken(TokenTypes.IDENT).getText())); } break; default: diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingJsonDeserializer.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingJsonDeserializer.java index bf1f5fdb4c376..7d7c3a9174b71 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingJsonDeserializer.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingJsonDeserializer.java @@ -97,9 +97,9 @@ private static ConfigurationSetting read(JsonNode node) { return readSecretReferenceConfigurationSetting(node, baseSetting); } } catch (Exception exception) { - LOGGER.info(String.format( - "The setting is neither a 'FeatureFlagConfigurationSetting' nor 'SecretReferenceConfigurationSetting'" - + ", return the setting as 'ConfigurationSetting', error is ", exception)); + LOGGER.info("The setting is neither a 'FeatureFlagConfigurationSetting' nor " + + "'SecretReferenceConfigurationSetting', return the setting as 'ConfigurationSetting'. " + + "Error: ", exception); } return baseSetting; } diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java index 787f80aa8d185..77e1a0480cfce 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java @@ -203,7 +203,7 @@ public void addEvent(String eventName, Map traceEventAttributes, Span currentSpan = Span.current(); if (currentSpan == null) { - logger.info("Failed to find a starting span to associate the %s with.", eventName); + logger.info("Failed to find a starting span to associate the {} with.", eventName); return; } diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/ProtocolPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/ProtocolPolicy.java index 8e1d1bc49a12b..494096b166e23 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/ProtocolPolicy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/ProtocolPolicy.java @@ -41,7 +41,7 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN context.getHttpRequest().setUrl(urlBuilder.setScheme(protocol).toUrl()); } catch (MalformedURLException e) { return Mono.error(new RuntimeException( - String.format("Failed to set the HTTP request protocol to %d.", protocol), e)); + String.format("Failed to set the HTTP request protocol to %s.", protocol), e)); } } return next.process(); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JacksonAdapter.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JacksonAdapter.java index 01bd2e654ea7d..aa7989464d79e 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JacksonAdapter.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JacksonAdapter.java @@ -500,7 +500,7 @@ private boolean usePublicSetter(Object deserializedHeaders, ClientLogger logger) Method setterMethod = deserializedHeaders.getClass().getDeclaredMethod(potentialSetterName, Map.class); if (Modifier.isPublic(setterMethod.getModifiers())) { setterMethod.invoke(deserializedHeaders, values); - logger.verbose("User setter %s on class %s to set header collection.", potentialSetterName, + logger.verbose("User setter {} on class {} to set header collection.", potentialSetterName, deserializedHeaders.getClass().getSimpleName()); return true; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java index 5a8c9c71c9723..ee7f54130b598 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java @@ -607,7 +607,7 @@ public static T parse(String itemResponseBodyAsString, Class itemClassTyp return getSimpleObjectMapper().readValue(itemResponseBodyAsString, itemClassType); } catch (IOException e) { throw new IllegalStateException( - String.format("Failed to parse string [%s] to POJO.", itemResponseBodyAsString, e)); + String.format("Failed to parse string [%s] to POJO.", itemResponseBodyAsString), e); } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java index 9a0814ef120a6..be9f9c8e4c79b 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressResolver.java @@ -140,7 +140,7 @@ private static boolean isSameCollection(PartitionKeyRange initiallyResolved, Par * * @param request Request in progress * @param targetRange Target partition key range determined by address resolver - * @*/ + * */ private void throwIfTargetChanged(RxDocumentServiceRequest request, PartitionKeyRange targetRange) { // If new range is child of previous range, we don't need to throw any exceptions // as LSNs are continued on child ranges. @@ -148,7 +148,7 @@ private void throwIfTargetChanged(RxDocumentServiceRequest request, PartitionKey !isSameCollection(request.requestContext.resolvedPartitionKeyRange, targetRange)) { if (!request.getIsNameBased()) { String message = String.format( - "Target should not change for non name based requests. Previous target {}, Current {}", + "Target should not change for non name based requests. Previous target %s, Current %s", request.requestContext.resolvedPartitionKeyRange, targetRange); assert false : message; logger.warn(message); diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java index aa238170de01a..7c65e8be27b8e 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java @@ -246,7 +246,7 @@ public void queryOrderByMixedTypes(String sortOrder) throws Exception { // Ensure its a cross partition query assertThat(partitionKeyRanges.size()).isGreaterThan(1); // We are inserting documents with int, float, string, array, object and missing propMixed. - String query = String.format("SELECT * FROM r ORDER BY r.propMixed ", sortOrder); + String query = "SELECT * FROM r ORDER BY r.propMixed "; CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); List sourceIds = createdDocuments.stream() .map(Resource::getId) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 68563d51c18a4..b1afaa0865322 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -857,7 +857,7 @@ Mono>> createModelsWithResponse(Iterabl modelsPayload.add(mapper.readValue(model, Object.class)); } catch (JsonProcessingException e) { - logger.error("Could not parse the model payload [%s]: %s", model, e); + logger.error("Could not parse the model payload [{}]: {}", model, e); return Mono.error(e); } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventDataBatchIntegrationTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventDataBatchIntegrationTest.java index fa8afad99b1bc..a5529acde308a 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventDataBatchIntegrationTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventDataBatchIntegrationTest.java @@ -150,8 +150,8 @@ public void sendBatchPartitionKeyValidate() throws InterruptedException { logger.info("Event[{}] matched. Countdown: {}", event.getSequenceNumber(), countDownLatch.getCount()); countDownLatch.countDown(); } else { - logger.warning(String.format("Event[%s] matched partition key, but not GUID. Expected: %s. Actual: %s", - event.getSequenceNumber(), messageValue, event.getProperties().get(MESSAGE_ID))); + logger.warning("Event[{}] matched partition key, but not GUID. Expected: {}. Actual: {}", + event.getSequenceNumber(), messageValue, event.getProperties().get(MESSAGE_ID)); } }, error -> { Assertions.fail("An error should not have occurred:" + error.toString()); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorClientBuilderTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorClientBuilderTest.java index c7e217dc56c71..bca845b9b881d 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorClientBuilderTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorClientBuilderTest.java @@ -51,7 +51,7 @@ public void testEventProcessorBuilderMissingProperties() { + "sequence number of event = " + eventContext.getEventData().getSequenceNumber()); }) .processError(errorContext -> { - System.out.printf("Error occurred in partition processor for partition {}, {}", + System.out.printf("Error occurred in partition processor for partition %s, %s%n", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable()); }) @@ -69,7 +69,7 @@ public void testEventProcessorBuilderWithProcessEvent() { + "sequence number of event = " + eventContext.getEventData().getSequenceNumber()); }) .processError(errorContext -> { - System.out.printf("Error occurred in partition processor for partition %s, %s", + System.out.printf("Error occurred in partition processor for partition %s, %s%n", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable()); }) @@ -98,7 +98,7 @@ public void testEventProcessorBuilderWithBothSingleAndBatchConsumers() { }); }, 5, Duration.ofSeconds(1)) .processError(errorContext -> { - System.out.printf("Error occurred in partition processor for partition {}, {}", + System.out.printf("Error occurred in partition processor for partition %s, %s%n", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable()); }) @@ -113,7 +113,7 @@ public void testEventProcessorBuilderWithNoProcessEventConsumer() { .checkpointStore(new SampleCheckpointStore()) .consumerGroup("consumer-group") .processError(errorContext -> { - System.out.printf("Error occurred in partition processor for partition {}, {}", + System.out.printf("Error occurred in partition processor for partition %s, %s%n", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable()); }) @@ -134,7 +134,7 @@ public void testEventProcessorBuilderWithProcessEventBatch() { }); }, 5, Duration.ofSeconds(1)) .processError(errorContext -> { - System.out.printf("Error occurred in partition processor for partition %s, %s", + System.out.printf("Error occurred in partition processor for partition %s, %s%n", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable()); }) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/IntegrationTestBase.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/IntegrationTestBase.java index 17c136924eb3f..3fb17c4ad4ee7 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/IntegrationTestBase.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/IntegrationTestBase.java @@ -293,8 +293,7 @@ protected void dispose(Closeable... closeables) { try { closeable.close(); } catch (IOException error) { - logger.error(String.format("[%s]: %s didn't close properly.", testName, - closeable.getClass().getSimpleName()), error); + logger.error("[{}]: {} didn't close properly.", testName, closeable.getClass().getSimpleName(), error); } } } diff --git a/sdk/identity/azure-identity/src/main/java/com/azure/identity/ManagedIdentityCredential.java b/sdk/identity/azure-identity/src/main/java/com/azure/identity/ManagedIdentityCredential.java index 405693bf5d4ed..d5129fb369c2a 100644 --- a/sdk/identity/azure-identity/src/main/java/com/azure/identity/ManagedIdentityCredential.java +++ b/sdk/identity/azure-identity/src/main/java/com/azure/identity/ManagedIdentityCredential.java @@ -75,8 +75,8 @@ public Mono getToken(TokenRequestContext request) { + "The Target Azure platform could not be determined from environment variables."))); } return managedIdentityServiceCredential.authenticate(request) - .doOnSuccess((t -> logger.info(String.format("Azure Identity => Managed Identity environment: %s", - managedIdentityServiceCredential.getEnvironment())))) + .doOnSuccess(t -> logger.info("Azure Identity => Managed Identity environment: {}", + managedIdentityServiceCredential.getEnvironment())) .doOnNext(token -> LoggingUtil.logTokenSuccess(logger, request)) .doOnError(error -> LoggingUtil.logTokenError(logger, request, error)); } diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java index 828ca1c883d55..21d77ca75b7a9 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java @@ -207,9 +207,8 @@ Mono> listRoleDefinitionsFirstPage(String context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing role definitions for roleScope - {}", roleScope)) .doOnSuccess(response -> logger.verbose("Listed role definitions for roleScope - {}", roleScope)) - .doOnError(error -> - logger.warning(String.format("Failed to list role definitions for roleScope - %s", roleScope), - error)) + .doOnError(error -> logger.warning("Failed to list role definitions for roleScope - {}", roleScope, + error)) .onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException) .map(KeyVaultAccessControlAsyncClient::transformRoleDefinitionsPagedResponse); } catch (RuntimeException e) { @@ -633,9 +632,8 @@ Mono> listRoleAssignmentsFirstPage(String context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing role assignments for roleScope - {}", roleScope)) .doOnSuccess(response -> logger.verbose("Listed role assignments for roleScope - {}", roleScope)) - .doOnError(error -> - logger.warning(String.format("Failed to list role assignments for roleScope - %s", roleScope), - error)) + .doOnError(error -> logger.warning("Failed to list role assignments for roleScope - {}", roleScope, + error)) .onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException) .map(KeyVaultAccessControlAsyncClient::transformRoleAssignmentsPagedResponse); } catch (RuntimeException e) { diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java index 702fdbd59323d..5910e5ced6606 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java @@ -1040,7 +1040,7 @@ private Mono> listCertificateVersionsFirstP context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing certificate versions - {}", certificateName)) .doOnSuccess(response -> logger.verbose("Listed certificate versions - {}", certificateName)) - .doOnError(error -> logger.warning(String.format("Failed to list certificate versions - {}", certificateName), error)); + .doOnError(error -> logger.warning("Failed to list certificate versions - {}", certificateName, error)); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -1454,7 +1454,7 @@ private Mono> listPropertiesOfIssuersFirstPage(C context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing certificate issuers - {}")) .doOnSuccess(response -> logger.verbose("Listed certificate issuers - {}")) - .doOnError(error -> logger.warning(String.format("Failed to list certificate issuers - {}"), error)); + .doOnError(error -> logger.warning("Failed to list certificate issuers - {}", error)); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -1580,7 +1580,7 @@ private Mono> setCertificateContactsWithRespon context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing certificate contacts - {}")) .doOnSuccess(response -> logger.verbose("Listed certificate contacts - {}")) - .doOnError(error -> logger.warning(String.format("Failed to list certificate contacts - {}"), error)); + .doOnError(error -> logger.warning("Failed to list certificate contacts - {}", error)); } /** @@ -1615,7 +1615,7 @@ private Mono> listCertificateContactsFirstPage context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing certificate contacts - {}")) .doOnSuccess(response -> logger.verbose("Listed certificate contacts - {}")) - .doOnError(error -> logger.warning(String.format("Failed to list certificate contacts - {}"), error)); + .doOnError(error -> logger.warning("Failed to list certificate contacts - {}", error)); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -1652,7 +1652,7 @@ private Mono> deleteCertificateContactsWithRes context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Deleting certificate contacts - {}")) .doOnSuccess(response -> logger.verbose("Deleted certificate contacts - {}")) - .doOnError(error -> logger.warning(String.format("Failed to delete certificate contacts - {}"), error)); + .doOnError(error -> logger.warning("Failed to delete certificate contacts - {}", error)); } /** diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java index 786e0b3ad1b31..7692c3ea3481e 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java @@ -26,7 +26,6 @@ import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -44,6 +43,7 @@ public final class CertificateClientJavaDocCodeSnippets { /** * Implementation for.CertificateClient + * * @return sync CertificateClient */ private CertificateClient getCertificateClient() { @@ -65,19 +65,18 @@ public void getCertificatePolicyCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicy#string CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName"); - System.out.printf("Received policy with subject name %s", policy.getSubject()); + System.out.printf("Received policy with subject name %s%n", policy.getSubject()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicy#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicyWithResponse#string Response returnedPolicyWithResponse = certificateClient.getCertificatePolicyWithResponse( "certificateName", new Context(key1, value1)); - System.out.printf("Received policy with subject name %s", + System.out.printf("Received policy with subject name %s%n", returnedPolicyWithResponse.getValue().getSubject()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicyWithResponse#string } - /** * Method to insert code snippets for {@link CertificateClient#getCertificate(String)} */ @@ -85,7 +84,7 @@ public void getCertificateWithResponseCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#String KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("certificateName"); - System.out.printf("Received certificate with name %s and version %s and secret id", + System.out.printf("Received certificate with name %s and version %s and secret id %s%n", certificate.getProperties().getName(), certificate.getProperties().getVersion(), certificate.getSecretId()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#String @@ -93,7 +92,7 @@ public void getCertificateWithResponseCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateWithResponse#String-Context Response certificateWithResponse = certificateClient .getCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Received certificate with name %s and version %s and secret id", + System.out.printf("Received certificate with name %s and version %s and secret id %s%n", certificateWithResponse.getValue().getProperties().getName(), certificateWithResponse.getValue().getProperties().getVersion(), certificate.getSecretId()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateWithResponse#String-Context @@ -102,7 +101,7 @@ public void getCertificateWithResponseCodeSnippets() { Response returnedCertificateWithResponse = certificateClient .getCertificateVersionWithResponse("certificateName", "certificateVersion", new Context(key1, value1)); - System.out.printf("Received certificate with name %s and version %s and secret id", + System.out.printf("Received certificate with name %s and version %s and secret id %s%n", returnedCertificateWithResponse.getValue().getProperties().getName(), returnedCertificateWithResponse.getValue().getProperties().getVersion(), returnedCertificateWithResponse.getValue().getSecretId()); @@ -111,7 +110,7 @@ public void getCertificateWithResponseCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersion#String-String KeyVaultCertificate returnedCertificate = certificateClient.getCertificateVersion("certificateName", "certificateVersion"); - System.out.printf("Received certificate with name %s and version %s and secret id", + System.out.printf("Received certificate with name %s and version %s and secret id %s%n", returnedCertificate.getProperties().getName(), returnedCertificate.getProperties().getVersion(), returnedCertificate.getSecretId()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersion#String-String @@ -120,16 +119,15 @@ public void getCertificateWithResponseCodeSnippets() { for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { KeyVaultCertificate certificateWithAllProperties = certificateClient .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s", + System.out.printf("Received certificate with name %s and secret id %s%n", certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); } // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#CertificateProperties } /** - * Method to insert code snippets for - * {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy, Boolean, Map)} and - * {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy)}. + * Method to insert code snippets for {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy, + * Boolean, Map)} and {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy)}. */ public void createCertificateCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); @@ -140,7 +138,7 @@ public void createCertificateCodeSnippets() { .beginCreateCertificate("certificateName", certificatePolicyPkcsSelf, true, new HashMap<>()); certificateSyncPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); KeyVaultCertificate createdCertificate = certificateSyncPoller.getFinalResult(); - System.out.printf("Certificate created with name %s", createdCertificate.getName()); + System.out.printf("Certificate created with name %s%n", createdCertificate.getName()); // END: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy @@ -150,7 +148,7 @@ public void createCertificateCodeSnippets() { .beginCreateCertificate("certificateName", certPolicy); certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); KeyVaultCertificate cert = certPoller.getFinalResult(); - System.out.printf("Certificate created with name %s", cert.getName()); + System.out.printf("Certificate created with name %s%n", cert.getName()); // END: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy } @@ -164,7 +162,7 @@ public void getCertificateOperation() { .getCertificateOperation("certificateName"); getCertPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); KeyVaultCertificate cert = getCertPoller.getFinalResult(); - System.out.printf("Certificate created with name %s", cert.getName()); + System.out.printf("Certificate created with name %s%n", cert.getName()); // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateOperation#String } @@ -177,21 +175,21 @@ public void createCertificateIssuerCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.createIssuer#CertificateIssuer CertificateIssuer issuerToCreate = new CertificateIssuer("myissuer", "myProvider") .setAccountId("testAccount") - .setAdministratorContacts(Arrays.asList(new AdministratorContact().setFirstName("test").setLastName("name") - .setEmail("test@example.com"))); + .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") + .setLastName("name").setEmail("test@example.com"))); CertificateIssuer returnedIssuer = certificateClient.createIssuer(issuerToCreate); - System.out.printf("Created Issuer with name %s provider %s", returnedIssuer.getName(), + System.out.printf("Created Issuer with name %s provider %s%n", returnedIssuer.getName(), returnedIssuer.getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.createIssuer#CertificateIssuer // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.createIssuerWithResponse#CertificateIssuer-Context CertificateIssuer issuer = new CertificateIssuer("issuerName", "myProvider") .setAccountId("testAccount") - .setAdministratorContacts(Arrays.asList(new AdministratorContact().setFirstName("test").setLastName("name") - .setEmail("test@example.com"))); + .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") + .setLastName("name").setEmail("test@example.com"))); Response issuerResponse = certificateClient.createIssuerWithResponse(issuer, new Context(key1, value1)); - System.out.printf("Created Issuer with name %s provider %s", issuerResponse.getValue().getName(), + System.out.printf("Created Issuer with name %s provider %s%n", issuerResponse.getValue().getName(), issuerResponse.getValue().getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.createIssuerWithResponse#CertificateIssuer-Context } @@ -203,14 +201,14 @@ public void getCertificateIssuerCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getIssuer#string CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); - System.out.printf("Retrieved issuer with name %s and prodier %s", returnedIssuer.getName(), + System.out.printf("Retrieved issuer with name %s and provider %s%n", returnedIssuer.getName(), returnedIssuer.getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.getIssuer#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getIssuerWithResponse#string-context Response issuerResponse = certificateClient.getIssuerWithResponse("issuerName", new Context(key1, value1)); - System.out.printf("Retrieved issuer with name %s and prodier %s", issuerResponse.getValue().getName(), + System.out.printf("Retrieved issuer with name %s and provider %s%n", issuerResponse.getValue().getName(), issuerResponse.getValue().getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.getIssuerWithResponse#string-context } @@ -225,7 +223,7 @@ public void updateCertificateCodeSnippets() { // Update certificate enabled status certificate.getProperties().setEnabled(false); KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); - System.out.printf("Updated Certificate with name %s and enabled status %s", + System.out.printf("Updated Certificate with name %s and enabled status %s%n", updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled()); // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificateProperties#CertificateProperties @@ -235,7 +233,7 @@ public void updateCertificateCodeSnippets() { certificateToUpdate.getProperties().setEnabled(false); Response updatedCertificateResponse = certificateClient. updateCertificatePropertiesWithResponse(certificateToUpdate.getProperties(), new Context(key1, value1)); - System.out.printf("Updated Certificate with name %s and enabled status %s", + System.out.printf("Updated Certificate with name %s and enabled status %s%n", updatedCertificateResponse.getValue().getProperties().getName(), updatedCertificateResponse.getValue().getProperties().isEnabled()); // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePropertiesWithResponse#CertificateProperties-Context @@ -250,7 +248,7 @@ public void updateCertificateIssuerCodeSnippets() { CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); returnedIssuer.setAccountId("newAccountId"); CertificateIssuer updatedIssuer = certificateClient.updateIssuer(returnedIssuer); - System.out.printf("Updated issuer with name %s, provider %s and account Id %s", updatedIssuer.getName(), + System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuer.getName(), updatedIssuer.getProvider(), updatedIssuer.getAccountId()); // END: com.azure.security.keyvault.certificates.CertificateClient.updateIssuer#CertificateIssuer @@ -259,7 +257,7 @@ public void updateCertificateIssuerCodeSnippets() { returnedIssuer.setAccountId("newAccountId"); Response updatedIssuerWithResponse = certificateClient.updateIssuerWithResponse(issuer, new Context(key1, value1)); - System.out.printf("Updated issuer with name %s, provider %s and account Id %s", + System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuerWithResponse.getValue().getName(), updatedIssuerWithResponse.getValue().getProvider(), updatedIssuerWithResponse.getValue().getAccountId()); @@ -277,7 +275,7 @@ public void updateCertificatePolicyCodeSnippets() { certificatePolicy.setCertificateTransparent(true); CertificatePolicy updatedCertPolicy = certificateClient.updateCertificatePolicy("certificateName", certificatePolicy); - System.out.printf("Updated Certificate Policy transparency status %s", + System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicy.isCertificateTransparent()); // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicy#string @@ -288,7 +286,7 @@ public void updateCertificatePolicyCodeSnippets() { Response updatedCertPolicyWithResponse = certificateClient .updateCertificatePolicyWithResponse("certificateName", certificatePolicyToUpdate, new Context(key1, value1)); - System.out.printf("Updated Certificate Policy transparency status %s", updatedCertPolicyWithResponse + System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicyWithResponse .getValue().isCertificateTransparent()); // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicyWithResponse#string } @@ -303,7 +301,7 @@ public void deleteCertificateCodeSnippets() { certificateClient.beginDeleteCertificate("certificateName"); // Deleted Certificate is accessible as soon as polling beings. PollResponse deleteCertPollResponse = deleteCertPoller.poll(); - System.out.printf("Deleted certificate with name %s and recovery id %s", + System.out.printf("Deleted certificate with name %s and recovery id %s%n", deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId()); deleteCertPoller.waitForCompletion(); // END: com.azure.security.keyvault.certificates.CertificateClient.beginDeleteCertificate#String @@ -316,14 +314,14 @@ public void deleteCertificateIssuefrCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuerWithResponse#string-context CertificateIssuer deletedIssuer = certificateClient.deleteIssuer("certificateName"); - System.out.printf("Deleted certificate issuer with name %s and provider id %s", deletedIssuer.getName(), + System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuer.getName(), deletedIssuer.getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuerWithResponse#string-context // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuer#string Response deletedIssuerWithResponse = certificateClient. deleteIssuerWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Deleted certificate issuer with name %s and provider id %s", + System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuerWithResponse.getValue().getName(), deletedIssuerWithResponse.getValue().getProvider()); // END: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuer#string @@ -336,21 +334,22 @@ public void getDeletedCertificateCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificate#string DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate("certificateName"); - System.out.printf("Deleted certificate with name %s and recovery id %s", deletedCertificate.getName(), + System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificate.getName(), deletedCertificate.getRecoveryId()); // END: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificate#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificateWithResponse#String-Context Response deletedCertificateWithResponse = certificateClient .getDeletedCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Deleted certificate with name %s and recovery id %s", + System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificateWithResponse.getValue().getName(), deletedCertificateWithResponse.getValue().getRecoveryId()); // END: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificateWithResponse#String-Context } /** - * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, Context)} + * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, + * Context)} */ public void purgeDeletedCertificateCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); @@ -360,7 +359,8 @@ public void purgeDeletedCertificateCodeSnippets() { } /** - * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, Context)} + * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, + * Context)} */ public void purgeDeletedCertificateWithResponseCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); @@ -368,7 +368,7 @@ public void purgeDeletedCertificateWithResponseCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificateWithResponse#string-Context Response purgeResponse = certificateClient.purgeDeletedCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Purged Deleted certificate with status %d %n", purgeResponse.getStatusCode()); + System.out.printf("Purged Deleted certificate with status %d%n", purgeResponse.getStatusCode()); // END: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificateWithResponse#string-Context } @@ -382,7 +382,7 @@ public void recoverDeletedCertificateCodeSnippets() { .beginRecoverDeletedCertificate("deletedCertificateName"); // Recovered certificate is accessible as soon as polling beings PollResponse recoverDeletedCertPollResponse = recoverDeletedCertPoller.poll(); - System.out.printf(" Recovered Deleted certificate with name %s and id %s", + System.out.printf(" Recovered Deleted certificate with name %s and id %s%n", recoverDeletedCertPollResponse.getValue().getProperties().getName(), recoverDeletedCertPollResponse.getValue().getProperties().getId()); recoverDeletedCertPoller.waitForCompletion(); @@ -396,13 +396,13 @@ public void backupCertificateCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.backupCertificate#string byte[] certificateBackup = certificateClient.backupCertificate("certificateName"); - System.out.printf("Backed up certificate with back up blob length %d", certificateBackup.length); + System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackup.length); // END: com.azure.security.keyvault.certificates.CertificateClient.backupCertificate#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.backupCertificateWithResponse#String-Context Response certificateBackupWithResponse = certificateClient .backupCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Backed up certificate with back up blob length %d", + System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackupWithResponse.getValue().length); // END: com.azure.security.keyvault.certificates.CertificateClient.backupCertificateWithResponse#String-Context } @@ -415,7 +415,7 @@ public void restoreCertificateCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificate#byte byte[] certificateBackupBlob = {}; KeyVaultCertificate certificate = certificateClient.restoreCertificateBackup(certificateBackupBlob); - System.out.printf(" Restored certificate with name %s and id %s", + System.out.printf(" Restored certificate with name %s and id %s%n", certificate.getProperties().getName(), certificate.getProperties().getId()); // END: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificate#byte @@ -423,7 +423,7 @@ public void restoreCertificateCodeSnippets() { byte[] certificateBackupBlobArray = {}; Response certificateResponse = certificateClient .restoreCertificateBackupWithResponse(certificateBackupBlobArray, new Context(key1, value1)); - System.out.printf(" Restored certificate with name %s and id %s", + System.out.printf(" Restored certificate with name %s and id %s%n", certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getProperties().getId()); // END: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificateWithResponse#byte-Context @@ -438,7 +438,7 @@ public void listCertificatesCodeSnippets() { for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { KeyVaultCertificate certificateWithAllProperties = certificateClient .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s", + System.out.printf("Received certificate with name %s and secret id %s%n", certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); } @@ -449,7 +449,7 @@ public void listCertificatesCodeSnippets() { .listPropertiesOfCertificates(true, new Context(key1, value1))) { KeyVaultCertificate certificateWithAllProperties = certificateClient .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s", + System.out.printf("Received certificate with name %s and secret id %s%n", certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); } @@ -464,7 +464,7 @@ public void listCertificateIssuersCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers()) { CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); - System.out.printf("Received issuer with name %s and provider %s", retrievedIssuer.getName(), + System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), retrievedIssuer.getProvider()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers @@ -472,7 +472,7 @@ public void listCertificateIssuersCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers#context for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers(new Context(key1, value1))) { CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); - System.out.printf("Received issuer with name %s and provider %s", retrievedIssuer.getName(), + System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), retrievedIssuer.getProvider()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers#context @@ -485,14 +485,14 @@ public void listDeletedCertificatesCodeSnippets() { CertificateClient certificateClient = getCertificateClient(); // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates for (DeletedCertificate deletedCertificate : certificateClient.listDeletedCertificates()) { - System.out.printf("Deleted certificate's recovery Id %s", deletedCertificate.getRecoveryId()); + System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates#context for (DeletedCertificate deletedCertificate : certificateClient .listDeletedCertificates(true, new Context(key1, value1))) { - System.out.printf("Deleted certificate's recovery Id %s", deletedCertificate.getRecoveryId()); + System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates#context } @@ -505,22 +505,22 @@ public void listCertificateVersionsCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions for (CertificateProperties certificateProperties : certificateClient .listPropertiesOfCertificateVersions("certificateName")) { - KeyVaultCertificate certificateWithAllProperites = certificateClient + KeyVaultCertificate certificateWithAllProperties = certificateClient .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate's version with name %s, version %s and secret id %s", - certificateWithAllProperites.getProperties().getName(), - certificateWithAllProperites.getProperties().getVersion(), certificateWithAllProperites.getSecretId()); + System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", + certificateWithAllProperties.getProperties().getName(), + certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions#context for (CertificateProperties certificateProperties : certificateClient .listPropertiesOfCertificateVersions("certificateName")) { - KeyVaultCertificate certificateWithAllProperites = certificateClient + KeyVaultCertificate certificateWithAllProperties = certificateClient .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate's version with name %s, version %s and secret id %s", - certificateWithAllProperites.getProperties().getName(), - certificateWithAllProperites.getProperties().getVersion(), certificateWithAllProperites.getSecretId()); + System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", + certificateWithAllProperties.getProperties().getName(), + certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions#context } @@ -533,7 +533,7 @@ public void contactsOperationsCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) { - System.out.printf("Added contact with name %s and email %s to key vault", contact.getName(), + System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts @@ -542,35 +542,35 @@ public void contactsOperationsCodeSnippets() { CertificateContact sampleContact = new CertificateContact().setName("user").setEmail("useremail@example.com"); for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(sampleContact), new Context(key1, value1))) { - System.out.printf("Added contact with name %s and email %s to key vault", contact.getName(), + System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts-context // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listContacts for (CertificateContact contact : certificateClient.listContacts()) { - System.out.printf("Added contact with name %s and email %s to key vault", contact.getName(), + System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listContacts // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listContacts#context for (CertificateContact contact : certificateClient.listContacts(new Context(key1, value1))) { - System.out.printf("Added contact with name %s and email %s to key vault", contact.getName(), + System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.listContacts#context // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts for (CertificateContact contact : certificateClient.deleteContacts()) { - System.out.printf("Deleted contact with name %s and email %s from key vault", contact.getName(), + System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts#context for (CertificateContact contact : certificateClient.deleteContacts(new Context(key1, value1))) { - System.out.printf("Deleted contact with name %s and email %s from key vault", contact.getName(), + System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), contact.getEmail()); } // END: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts#context @@ -585,26 +585,26 @@ public void certificateOperationCodeSnippets() { // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperationWithResponse#string CertificateOperation deletedCertificateOperation = certificateClient .deleteCertificateOperation("certificateName"); - System.out.printf("Deleted Certificate Operation's last status %s", deletedCertificateOperation.getStatus()); + System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperation.getStatus()); // END: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperationWithResponse#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperation#string Response deletedCertificateOperationWithResponse = certificateClient .deleteCertificateOperationWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Deleted Certificate Operation's last status %s", + System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperationWithResponse.getValue().getStatus()); // END: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperation#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperation#string CertificateOperation certificateOperation = certificateClient .cancelCertificateOperation("certificateName"); - System.out.printf("Certificate Operation status %s", certificateOperation.getStatus()); + System.out.printf("Certificate Operation status %s%n", certificateOperation.getStatus()); // END: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperation#string // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperationWithResponse#string Response certificateOperationWithResponse = certificateClient .cancelCertificateOperationWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Certificate Operation status %s", certificateOperationWithResponse.getValue().getStatus()); + System.out.printf("Certificate Operation status %s%n", certificateOperationWithResponse.getValue().getStatus()); // END: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperationWithResponse#string } @@ -619,7 +619,7 @@ public void mergeCertificateCodeSnippets() { new MergeCertificateOptions("certificateName", x509CertificatesToMerge) .setEnabled(false); KeyVaultCertificate mergedCertificate = certificateClient.mergeCertificate(config); - System.out.printf("Received Certificate with name %s and key id %s", + System.out.printf("Received Certificate with name %s and key id %s%n", mergedCertificate.getProperties().getName(), mergedCertificate.getKeyId()); // END: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificate#config @@ -630,7 +630,7 @@ public void mergeCertificateCodeSnippets() { .setEnabled(false); Response mergedCertificateWithResponse = certificateClient.mergeCertificateWithResponse(mergeConfig, new Context(key2, value2)); - System.out.printf("Received Certificate with name %s and key id %s", + System.out.printf("Received Certificate with name %s and key id %s%n", mergedCertificateWithResponse.getValue().getProperties().getName(), mergedCertificateWithResponse.getValue().getKeyId()); // END: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificateWithResponse#config @@ -646,17 +646,17 @@ public void importCertificate() { ImportCertificateOptions config = new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); KeyVaultCertificate importedCertificate = certificateClient.importCertificate(config); - System.out.printf("Received Certificate with name %s and key id %s", + System.out.printf("Received Certificate with name %s and key id %s%n", importedCertificate.getProperties().getName(), importedCertificate.getKeyId()); // END: com.azure.security.keyvault.certificates.CertificateClient.importCertificate#options // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.importCertificateWithResponse#options byte[] certToImport = new byte[100]; - ImportCertificateOptions importCertificateOptions = + ImportCertificateOptions importCertificateOptions = new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); Response importedCertificateWithResponse = certificateClient.importCertificateWithResponse(importCertificateOptions, new Context(key2, value2)); - System.out.printf("Received Certificate with name %s and key id %s", + System.out.printf("Received Certificate with name %s and key id %s%n", importedCertificateWithResponse.getValue().getProperties().getName(), importedCertificateWithResponse.getValue().getKeyId()); // END: com.azure.security.keyvault.certificates.CertificateClient.importCertificateWithResponse#options diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java index fd449a38e640f..36a53c9c2e22f 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java @@ -1340,7 +1340,7 @@ private Mono> listKeyVersionsFirstPage(String name, CONTENT_TYPE_HEADER_VALUE, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing key versions - {}", name)) .doOnSuccess(response -> logger.verbose("Listed key versions - {}", name)) - .doOnError(error -> logger.warning(String.format("Failed to list key versions - %s", name), error)); + .doOnError(error -> logger.warning("Failed to list key versions - {}", name, error)); } catch (RuntimeException ex) { return monoError(logger, ex); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/HelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/HelloWorldAsync.java index 1cc6b849f5b9e..6d7b8c1d762f2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/HelloWorldAsync.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/HelloWorldAsync.java @@ -38,14 +38,14 @@ public static void main(String[] args) throws InterruptedException { .setKeySize(2048)).block(); // Let's validate create key operation succeeded using the status code information in the response. - System.out.printf("Create Key operation succeeded with status code %s \n", createKeyResponse.getStatusCode()); - System.out.printf("Key is created with name %s and type %s \n", createKeyResponse.getValue().getName(), createKeyResponse.getValue().getKeyType()); + System.out.printf("Create Key operation succeeded with status code %s%n", createKeyResponse.getStatusCode()); + System.out.printf("Key is created with name %s and type %s%n", createKeyResponse.getValue().getName(), createKeyResponse.getValue().getKeyType()); Thread.sleep(2000); // Let's Get the Cloud Rsa Key from the key vault. keyAsyncClient.getKey("CloudRsaKey").subscribe(keyResponse -> - System.out.printf("Key returned with name %s and type %s \n", keyResponse.getName(), keyResponse.getKeyType())); + System.out.printf("Key returned with name %s and type %s%n", keyResponse.getName(), keyResponse.getKeyType())); Thread.sleep(2000); @@ -57,7 +57,7 @@ public static void main(String[] args) throws InterruptedException { //Update the expiry time of the key. key.getProperties().setExpiresOn(key.getProperties().getExpiresOn().plusYears(1)); keyAsyncClient.updateKeyProperties(key.getProperties()).subscribe(updatedKeyResponse -> - System.out.printf("Key's updated expiry time %s \n", updatedKeyResponse.getProperties().getExpiresOn().toString())); + System.out.printf("Key's updated expiry time %s%n", updatedKeyResponse.getProperties().getExpiresOn().toString())); }); Thread.sleep(2000); @@ -68,7 +68,7 @@ public static void main(String[] args) throws InterruptedException { .setExpiresOn(OffsetDateTime.now().plusYears(1)) .setKeySize(4096)) .subscribe(keyResponse -> - System.out.printf("Key is created with name %s and type %s \n", keyResponse.getName(), keyResponse.getKeyType())); + System.out.printf("Key is created with name %s and type %s%n", keyResponse.getName(), keyResponse.getKeyType())); Thread.sleep(2000); @@ -85,7 +85,7 @@ public static void main(String[] args) throws InterruptedException { // If the keyvault is soft-delete enabled, then for permanent deletion deleted keys need to be purged. keyAsyncClient.purgeDeletedKeyWithResponse("CloudRsaKey").subscribe(purgeResponse -> - System.out.printf("Cloud Rsa key purge status response %n \n", purgeResponse.getStatusCode())); + System.out.printf("Cloud Rsa key purge status response %d%n", purgeResponse.getStatusCode())); //To ensure key is purged on server side. Thread.sleep(15000); diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java index 31cccf6055159..8ab8444ff8304 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretAsyncClient.java @@ -940,7 +940,7 @@ private Mono> listSecretVersionsFirstPage(String CONTENT_TYPE_HEADER_VALUE, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.verbose("Listing secret versions - {}", name)) .doOnSuccess(response -> logger.verbose("Listed secret versions - {}", name)) - .doOnError(error -> logger.warning(String.format("Failed to list secret versions - {}", name), error)); + .doOnError(error -> logger.warning("Failed to list secret versions - {}", name, error)); } catch (RuntimeException ex) { return monoError(logger, ex); } diff --git a/sdk/keyvault/microsoft-azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java b/sdk/keyvault/microsoft-azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java index 97f0aaf84a142..71850008e2e25 100644 --- a/sdk/keyvault/microsoft-azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java +++ b/sdk/keyvault/microsoft-azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java @@ -12,7 +12,7 @@ public final class CertificateOperationIdentifier extends ObjectIdentifier { /** - * Verifies whether the identifier belongs to a key vault certificate operation. + * Verifies whether the identifier belongs to a key vault certificate operation. * @param identifier the key vault certificate operation identifier. * @return true if the identifier belongs to a key vault certificate operation. False otherwise. */ @@ -54,14 +54,13 @@ public CertificateOperationIdentifier(String vault, String name, String version) } /** - * Constructor. - * @param identifier the key vault certificate operation identifier. + * Constructor. + * @param identifier the key vault certificate operation identifier. */ public CertificateOperationIdentifier(String identifier) { super("certificates", identifier); if (!version().equals("pending")) { - throw new IllegalArgumentException( - String.format("Invalid CertificateOperationIdentifier: {0}", identifier)); + throw new IllegalArgumentException(String.format("Invalid CertificateOperationIdentifier: %s", identifier)); } } } diff --git a/sdk/keyvault/microsoft-azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/sdk/keyvault/microsoft-azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index d4515df564bdc..528a5833252ba 100644 --- a/sdk/keyvault/microsoft-azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/sdk/keyvault/microsoft-azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -933,7 +933,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation } throw new Exception(String.format( - "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", + "Polling on pending certificate returned an unexpected result. Error code = %s, Error message = %s", pendingCertificateOperation.error().code(), pendingCertificateOperation.error().message())); } diff --git a/sdk/mediaservices/microsoft-azure-media/src/main/java/com/microsoft/windowsazure/services/media/authentication/AzureAdTokenProvider.java b/sdk/mediaservices/microsoft-azure-media/src/main/java/com/microsoft/windowsazure/services/media/authentication/AzureAdTokenProvider.java index 200b5722ed764..63e87e1e2125d 100644 --- a/sdk/mediaservices/microsoft-azure-media/src/main/java/com/microsoft/windowsazure/services/media/authentication/AzureAdTokenProvider.java +++ b/sdk/mediaservices/microsoft-azure-media/src/main/java/com/microsoft/windowsazure/services/media/authentication/AzureAdTokenProvider.java @@ -86,7 +86,7 @@ private Future getToken() { default: throw new NotImplementedException( String.format( - "Token Credential type %1 is not supported.", + "Token Credential type %s is not supported.", this.tokenCredentials.getCredentialType())); } } diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesAsyncSample.java index 1403fdb5bc9b9..bd9d45536a4e3 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesAsyncSample.java @@ -28,7 +28,7 @@ public static void main(String[] args) { System.out.printf("Series Key: %s%n", incidentRootCause.getSeriesKey().asMap()); System.out.printf("Confidence for the detected incident root cause %.2f%n", incidentRootCause.getContributionScore()); - System.out.printf("Trace the path for the incident root cause : %s%n"); + System.out.println("Trace the path for the incident root cause :"); incidentRootCause.getPaths().forEach(System.out::println); }).blockLast(); /* diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesSample.java index f4a0f4fb164dd..077a8b2e6536d 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/ListIncidentRootCausesSample.java @@ -25,11 +25,11 @@ public static void main(String[] args) { advisorClient.listIncidentRootCauses(detectionConfigurationId, incidentId) .forEach(incidentRootCause -> { System.out.printf("Description: %s%n", incidentRootCause.getDescription()); - System.out.printf("Series Key: %s%n"); + System.out.printf("Series Key: %s%n", incidentRootCause.getSeriesKey()); System.out.println(incidentRootCause.getSeriesKey().asMap()); System.out.printf("Confidence for the detected incident root cause : %.2f%n", incidentRootCause.getContributionScore()); - System.out.printf("Trace the path for the incident root cause: %s%n"); + System.out.println("Trace the path for the incident root cause:"); incidentRootCause.getPaths().forEach(System.out::println); }); } diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java index be85df753317b..3f11effc70012 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackAsyncSample.java @@ -107,7 +107,7 @@ public static void main(String[] args) { = (MetricPeriodFeedback) feedbackItem; System.out.printf("Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Metric feedback period value: %f%n", + System.out.printf("Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(feedbackItem.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java index b76fa09f9f758..705f4a156e8e0 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricFeedbackSample.java @@ -90,7 +90,7 @@ public static void main(String[] args) { = (MetricPeriodFeedback) feedbackItem; System.out.printf("Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Metric feedback period value: %f%n", + System.out.printf("Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(feedbackItem.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java index 4dfd96bf9e7bb..575a0550d3524 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClientJavaDocCodeSnippets.java @@ -519,7 +519,7 @@ public void getMetricFeedback() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", createMetricPeriodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", createMetricPeriodFeedback.getPeriodValue()); } }); @@ -545,7 +545,7 @@ public void getMetricFeedbackWithResponse() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", createMetricPeriodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", createMetricPeriodFeedback.getPeriodValue()); } }); @@ -569,7 +569,7 @@ public void listMetricFeedbacks() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback @@ -614,7 +614,7 @@ public void listMetricFeedbacksWithOptions() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorClientJavaDocCodeSnippets.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorClientJavaDocCodeSnippets.java index d55095b80f05e..1e5dc6ae2e25e 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorClientJavaDocCodeSnippets.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/MetricsAdvisorClientJavaDocCodeSnippets.java @@ -599,7 +599,7 @@ public void getMetricFeedback() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", createMetricPeriodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", createMetricPeriodFeedback.getPeriodValue()); } // END: com.azure.ai.metricsadvisor.MetricsAdvisorClient.getFeedback#String @@ -624,7 +624,7 @@ public void getMetricFeedbackWithResponse() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", createMetricPeriodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", createMetricPeriodFeedback.getPeriodValue()); } // END: com.azure.ai.metricsadvisor.MetricsAdvisorClient.getFeedbackWithResponse#String-Context @@ -647,7 +647,7 @@ public void listMetricFeedbacks() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback @@ -692,7 +692,7 @@ public void listMetricFeedbacksWithOptions() { = (MetricPeriodFeedback) metricFeedback; System.out.printf("Data Feed Metric feedback type: %s%n", periodFeedback.getPeriodType().toString()); - System.out.printf("Data Feed Metric feedback period value: %f%n", + System.out.printf("Data Feed Metric feedback period value: %d%n", periodFeedback.getPeriodValue()); } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) { MetricAnomalyFeedback metricAnomalyFeedback diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationAsyncSample.java index a42e07a882c09..186311a1332c3 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationAsyncSample.java @@ -205,7 +205,7 @@ private static void printDetectionConfiguration(AnomalyDetectionConfiguration de DimensionKey seriesKey = seriesDetectionCondition.getSeriesKey(); final String seriesKeyStr = Arrays.toString(seriesKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Key:%n", seriesKeyStr); + System.out.printf("- Series Key: %s%n", seriesKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesDetectionCondition.getConditionOperator()); @@ -260,7 +260,7 @@ private static void printDetectionConfiguration(AnomalyDetectionConfiguration de DimensionKey seriesGroupKey = seriesGroupDetectionCondition.getSeriesGroupKey(); final String seriesGroupKeyStr = Arrays.toString(seriesGroupKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Group Key:%n", seriesGroupKeyStr); + System.out.printf("- Series Group Key: %s%n", seriesGroupKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesGroupDetectionCondition.getConditionOperator()); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationSample.java index bf2d266b2968d..529736b5e2959 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/AnomalyDetectionConfigurationSample.java @@ -174,7 +174,7 @@ private static void printDetectionConfiguration(AnomalyDetectionConfiguration de DimensionKey seriesKey = seriesDetectionCondition.getSeriesKey(); final String seriesKeyStr = Arrays.toString(seriesKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Key:%n", seriesKeyStr); + System.out.printf("- Series Key: %s%n", seriesKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesDetectionCondition.getConditionOperator()); @@ -229,7 +229,7 @@ private static void printDetectionConfiguration(AnomalyDetectionConfiguration de DimensionKey seriesGroupKey = seriesGroupDetectionCondition.getSeriesGroupKey(); final String seriesGroupKeyStr = Arrays.toString(seriesGroupKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Group Key:%n", seriesGroupKeyStr); + System.out.printf("- Series Group Key: %s%n", seriesGroupKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesGroupDetectionCondition.getConditionOperator()); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatasourceCredentialSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatasourceCredentialSample.java index 6b47ce7566d08..eaa44faf094f5 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatasourceCredentialSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/DatasourceCredentialSample.java @@ -39,7 +39,7 @@ public static void main(String[] args) { .createDatasourceCredential(datasourceCredential); - System.out.printf("Created Datasource credential entity: %s"); + System.out.printf("Created Datasource credential entity: %s%n", createdDatasourceCredentialEntity.getName()); // Retrieve the datasource credential entity that just created. DatasourceCredentialEntity fetchDatasourceCredEntity diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAdvisorAdministrationAsyncClientJavaDocCodeSnippets.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAdvisorAdministrationAsyncClientJavaDocCodeSnippets.java index 801236204a655..d25977d13e100 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAdvisorAdministrationAsyncClientJavaDocCodeSnippets.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAdvisorAdministrationAsyncClientJavaDocCodeSnippets.java @@ -791,7 +791,7 @@ public void getDetectionConfiguration() { DimensionKey seriesKey = seriesDetectionCondition.getSeriesKey(); final String seriesKeyStr = Arrays.toString(seriesKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Key:%n", seriesKeyStr); + System.out.printf("- Series Key: %s%n", seriesKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesDetectionCondition.getConditionOperator()); @@ -846,7 +846,7 @@ public void getDetectionConfiguration() { DimensionKey seriesGroupKey = seriesGroupDetectionCondition.getSeriesGroupKey(); final String seriesGroupKeyStr = Arrays.toString(seriesGroupKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Group Key:%n", seriesGroupKeyStr); + System.out.printf("- Series Group Key: %s%n", seriesGroupKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesGroupDetectionCondition.getConditionOperator()); @@ -971,7 +971,7 @@ public void getDetectionConfigurationWithResponse() { DimensionKey seriesKey = seriesDetectionCondition.getSeriesKey(); final String seriesKeyStr = Arrays.toString(seriesKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Key:%n", seriesKeyStr); + System.out.printf("- Series Key: %s%n", seriesKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesDetectionCondition.getConditionOperator()); @@ -1026,7 +1026,7 @@ public void getDetectionConfigurationWithResponse() { DimensionKey seriesGroupKey = seriesGroupDetectionCondition.getSeriesGroupKey(); final String seriesGroupKeyStr = Arrays.toString(seriesGroupKey.asMap().entrySet().stream().toArray()); - System.out.printf("- Series Group Key:%n", seriesGroupKeyStr); + System.out.printf("- Series Group Key: %s%n", seriesGroupKeyStr); System.out.printf(" - Use %s operator for multiple detection conditions:%n", seriesGroupDetectionCondition.getConditionOperator()); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsAsyncSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsAsyncSample.java index 4efd3e3f4f5e0..77fbdb3c198ae 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsAsyncSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsAsyncSample.java @@ -77,10 +77,10 @@ public static void main(String[] args) { forEach(metricAnomalyAlertConfiguration -> { System.out.printf("Anomaly Alert detection configuration Id: %s%n", metricAnomalyAlertConfiguration.getDetectionConfigurationId()); - System.out.printf("Anomaly Alert configuration negation value", + System.out.printf("Anomaly Alert configuration negation value: %b%n", metricAnomalyAlertConfiguration.isNegationOperationEnabled()); - System.out.printf("Anomaly Alert configuration scope type", - metricAnomalyAlertConfiguration.getAlertScope().getScopeType().toString()); + System.out.printf("Anomaly Alert configuration scope type: %s%n", + metricAnomalyAlertConfiguration.getAlertScope().getScopeType()); }); }); }); diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsSample.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsSample.java index 49e2bce3b1718..4cc699e37a9aa 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsSample.java +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples/java/com/azure/ai/metricsadvisor/administration/MetricsAnomalyAlertConfigOperationsSample.java @@ -69,10 +69,10 @@ public static void main(String[] args) { forEach(metricAnomalyAlertConfiguration -> { System.out.printf("Anomaly Alert detection configuration Id: %s%n", metricAnomalyAlertConfiguration.getDetectionConfigurationId()); - System.out.printf("Anomaly Alert configuration negation value", + System.out.printf("Anomaly Alert configuration negation value: %b%n", metricAnomalyAlertConfiguration.isNegationOperationEnabled()); - System.out.printf("Anomaly Alert configuration scope type", - metricAnomalyAlertConfiguration.getAlertScope().getScopeType().toString()); + System.out.printf("Anomaly Alert configuration scope type: %s%n", + metricAnomalyAlertConfiguration.getAlertScope().getScopeType()); }); // Update the anomaly alert config. diff --git a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/FileModelFetcher.java b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/FileModelFetcher.java index a138503e668c0..a8182568421d6 100644 --- a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/FileModelFetcher.java +++ b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/FileModelFetcher.java @@ -58,7 +58,7 @@ public Mono fetchAsync(String dtmi, URI repositoryUri, ModelDepende Path path = Paths.get(new File(tryContentPath).getPath()); - logger.info(String.format(StatusStrings.FETCHING_MODEL_CONTENT, path.toString())); + logger.info(StatusStrings.FETCHING_MODEL_CONTENT, path); if (Files.exists(path)) { try { diff --git a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/HttpModelFetcher.java b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/HttpModelFetcher.java index 98f055e9270dd..6a36fd9cacf84 100644 --- a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/HttpModelFetcher.java +++ b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/HttpModelFetcher.java @@ -45,7 +45,7 @@ public Mono fetchAsync(String dtmi, URI repositoryUri, ModelDepende String tryContentPath = work.poll(); - logger.info(String.format(StatusStrings.FETCHING_MODEL_CONTENT, tryContentPath)); + logger.info(StatusStrings.FETCHING_MODEL_CONTENT, tryContentPath); return evaluatePath(tryContentPath, context) .onErrorResume(error -> { diff --git a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/StatusStrings.java b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/StatusStrings.java index e6c870954d1ac..64e3ae3d95580 100644 --- a/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/StatusStrings.java +++ b/sdk/modelsrepository/azure-iot-modelsrepository/src/main/java/com/azure/iot/modelsrepository/implementation/StatusStrings.java @@ -8,7 +8,7 @@ public class StatusStrings { public static final String INVALID_DTMI_FORMAT_S = "Invalid DTMI format \"%s\"."; public static final String PROCESSING_DTMIS = "Processing DTMI \"%s\". "; public static final String DISCOVERED_DEPENDENCIES = "Discovered dependencies \"%s\"."; - public static final String FETCHING_MODEL_CONTENT = "Attempting to fetch model content from \"%s\"."; + public static final String FETCHING_MODEL_CONTENT = "Attempting to fetch model content from \"{}\"."; public static final String ERROR_FETCHING_MODEL_CONTENT = "Model file \"%s\" not found or not accessible in target repository."; public static final String INCORRECT_DTMI_CASING = "Fetched model has incorrect DTMI casing. Expected \"%s\", parsed \"%s\"."; } diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorRedirectPolicy.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorRedirectPolicy.java index 0c99833d3fac7..695f96b999dcb 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorRedirectPolicy.java +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorRedirectPolicy.java @@ -65,7 +65,7 @@ private Mono attemptRetry(final HttpPipelineCallContext context, */ private boolean shouldRetryWithRedirect(int statusCode, int tryCount) { if (tryCount >= MAX_REDIRECT_RETRIES) { - logger.verbose("Max redirect retries limit reached:%d.", MAX_REDIRECT_RETRIES); + logger.verbose("Max redirect retries limit reached: {}.", MAX_REDIRECT_RETRIES); return false; } return statusCode == HttpURLConnection.HTTP_MOVED_TEMP diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/FieldBuilder.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/FieldBuilder.java index 4d185f6e2a517..27f7ad15e6020 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/FieldBuilder.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/FieldBuilder.java @@ -108,7 +108,7 @@ public static List build(Class modelClass, FieldBuilderOptio private static List build(Class currentClass, Stack> classChain, MemberNameConverter serializer) { if (classChain.contains(currentClass)) { - LOGGER.warning(String.format("There is circular dependencies %s, %s", classChain, currentClass)); + LOGGER.warning("There is circular dependencies {}, {}", classChain, currentClass); return null; } if (classChain.size() > MAX_DEPTH) { diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusProcessorClient.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusProcessorClient.java index c9055cba6135d..24d6a246ec501 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusProcessorClient.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusProcessorClient.java @@ -280,7 +280,7 @@ private void endProcessTracingSpan(Context processSpanContext, Signal sign try { close.close(); } catch (Exception exception) { - logger.error("endTracingSpan().close() failed with an error %s", exception); + logger.error("endTracingSpan().close() failed with an error {}", exception); } } else { diff --git a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/IntegrationTestBase.java b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/IntegrationTestBase.java index fc191238fb2d7..04e4a072b912c 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/IntegrationTestBase.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/IntegrationTestBase.java @@ -359,8 +359,7 @@ protected void dispose(AutoCloseable... closeables) { try { closeable.close(); } catch (Exception error) { - logger.error(String.format("[%s]: %s didn't close properly.", testName, - closeable.getClass().getSimpleName()), error); + logger.error("[{}]: {} didn't close properly.", testName, closeable.getClass().getSimpleName(), error); } } diff --git a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/CoreMessageSender.java b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/CoreMessageSender.java index cc30f01cf438b..02b31a0a0cc14 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/CoreMessageSender.java +++ b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/CoreMessageSender.java @@ -326,16 +326,16 @@ public CompletableFuture sendAsync(final Iterable messages, Trans // proton-j doesn't support multiple dataSections to be part of AmqpMessage // here's the alternate approach provided by them: https://github.com/apache/qpid-proton/pull/54 Message batchMessage = Proton.message(); - + // Set partition identifier properties of the first message on batch message batchMessage.setMessageAnnotations(firstMessage.getMessageAnnotations()); if (StringUtil.isNullOrWhiteSpace((String)firstMessage.getMessageId())) { batchMessage.setMessageId(firstMessage.getMessageId()); } - + if (StringUtil.isNullOrWhiteSpace(firstMessage.getGroupId())) { batchMessage.setGroupId(firstMessage.getGroupId()); - } + } byte[] bytes = null; int byteArrayOffset = 0; @@ -599,7 +599,7 @@ private void createSendLink(SenderLinkSettings linkSettings) { return; } - + final Session session = connection.session(); session.setOutgoingWindow(Integer.MAX_VALUE); session.open(); @@ -656,7 +656,7 @@ private void initializeLinkOpen(TimeoutTracker timeout) { CoreMessageSender.this.lastKnownErrorReportedAt.isAfter(Instant.now().minusSeconds(ClientConstants.SERVER_BUSY_BASE_SLEEP_TIME_IN_SECS)) ? CoreMessageSender.this.lastKnownLinkError : null); TRACE_LOGGER.info(operationTimedout.getMessage()); ExceptionUtil.completeExceptionally(CoreMessageSender.this.linkFirstOpen, operationTimedout, CoreMessageSender.this, true); - + CoreMessageSender.this.setClosing(); CoreMessageSender.this.closeInternals(false); CoreMessageSender.this.setClosed(); @@ -859,7 +859,7 @@ private void throwSenderTimeout(CompletableFuture pendingSendWork boolean isClientSideTimeout = (cause == null || !(cause instanceof ServiceBusException)); ServiceBusException exception = isClientSideTimeout - ? new TimeoutException(String.format(Locale.US, "%s %s %s.", CoreMessageSender.SEND_TIMED_OUT, " at ", ZonedDateTime.now(), cause)) + ? new TimeoutException(String.format(Locale.US, "%s %s %s.", CoreMessageSender.SEND_TIMED_OUT, " at ", ZonedDateTime.now()), cause) : (ServiceBusException) cause; TRACE_LOGGER.info("Send timed out", exception); diff --git a/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/connectionstring/StorageConnectionStringTest.java b/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/connectionstring/StorageConnectionStringTest.java index 7302d19733aad..3af7d989a49c4 100644 --- a/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/connectionstring/StorageConnectionStringTest.java +++ b/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/connectionstring/StorageConnectionStringTest.java @@ -341,8 +341,7 @@ public void sasTokenAllowedWithAccountName() { blobEndpointStr, fileEndpointStr, SAS_TOKEN, - ACCOUNT_NAME_VALUE, - ACCOUNT_KEY_VALUE); + ACCOUNT_NAME_VALUE); StorageConnectionString.create(connectionString, logger); } diff --git a/sdk/synapse/azure-analytics-synapse-spark/src/samples/java/com/azure/analytics/synapse/spark/HelloWorldAsync.java b/sdk/synapse/azure-analytics-synapse-spark/src/samples/java/com/azure/analytics/synapse/spark/HelloWorldAsync.java index a06756411259e..245b2858b2b4f 100644 --- a/sdk/synapse/azure-analytics-synapse-spark/src/samples/java/com/azure/analytics/synapse/spark/HelloWorldAsync.java +++ b/sdk/synapse/azure-analytics-synapse-spark/src/samples/java/com/azure/analytics/synapse/spark/HelloWorldAsync.java @@ -44,7 +44,7 @@ public static void main(String[] args) throws IllegalArgumentException, Interrup .setExecutorCores(4) .setExecutorCount(2); - batchClient.createSparkBatchJob(options).subscribe(job -> System.out.printf("Job ID: %f\n", job.getId())); + batchClient.createSparkBatchJob(options).subscribe(job -> System.out.printf("Job ID: %d%n", job.getId())); // Wait for operation completion Thread.sleep(30000); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesJacksonSerializer.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesJacksonSerializer.java index 8818b8cd98263..a7811f8574371 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesJacksonSerializer.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesJacksonSerializer.java @@ -175,7 +175,7 @@ private Object getEntityFieldAsObject(JsonNode parentNode, String fieldName) thr String typeString = typeNode.asText(); EntityDataModelType type = EntityDataModelType.fromString(typeString); if (type == null) { - logger.warning(String.format("'%s' value has unknown OData type %s", fieldName, typeString)); + logger.warning("'{}' value has unknown OData type {}", fieldName, typeString); return serializer().treeToValue(valueNode, Object.class); }