From 0a27f411516864ee183f571f581668ced4a23507 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Tue, 26 Nov 2019 11:46:46 -0800 Subject: [PATCH 1/8] Remove hard-coded version and name from clients --- .github/CODEOWNERS | 1 + eng/jacoco-test-coverage/pom.xml | 8 +- eng/spotbugs-aggregate-report/pom.xml | 13 +- eng/versioning/external_dependencies.txt | 209 ++++++ eng/versioning/update_versions.py | 33 +- eng/versioning/utils.py | 11 +- eng/versioning/version_client.txt | 10 +- eng/versioning/version_client_java_files.txt | 3 - eng/versioning/version_data.txt | 14 +- parent/pom.xml | 616 +----------------- pom.client.xml | 67 +- pom.data.xml | 50 +- pom.xml | 21 +- .../azure-data-appconfiguration/CHANGELOG.md | 7 +- .../azure-data-appconfiguration/pom.xml | 15 +- .../ConfigurationClientBuilder.java | 14 +- sdk/appconfiguration/tests.yml | 1 - .../pom.xml | 21 +- .../pom.xml | 14 +- sdk/batch/microsoft-azure-batch/pom.xml | 12 +- .../ms-azure-cs-autosuggest/pom.xml | 7 +- .../ms-azure-cs-computervision/pom.xml | 7 +- .../ms-azure-cs-contentmoderator/pom.xml | 7 +- .../ms-azure-cs-customimagesearch/pom.xml | 7 +- .../ms-azure-cs-customsearch/pom.xml | 7 +- .../pom.xml | 7 +- .../ms-azure-cs-customvision-training/pom.xml | 7 +- .../ms-azure-cs-entitysearch/pom.xml | 7 +- .../ms-azure-cs-faceapi/pom.xml | 7 +- .../ms-azure-cs-imagesearch/pom.xml | 7 +- .../ms-azure-cs-luis-authoring/pom.xml | 7 +- .../ms-azure-cs-luis-runtime/pom.xml | 7 +- .../ms-azure-cs-newssearch/pom.xml | 7 +- .../ms-azure-cs-spellcheck/pom.xml | 7 +- .../ms-azure-cs-textanalytics/pom.xml | 7 +- .../ms-azure-cs-videosearch/pom.xml | 7 +- .../ms-azure-cs-visualsearch/pom.xml | 7 +- .../ms-azure-cs-websearch/pom.xml | 7 +- sdk/core/azure-core-amqp/pom.xml | 12 +- sdk/core/azure-core-http-netty/pom.xml | 34 +- sdk/core/azure-core-http-okhttp/pom.xml | 11 +- sdk/core/azure-core-management/pom.xml | 9 +- sdk/core/azure-core-test/pom.xml | 17 +- .../azure-core-tracing-opencensus/pom.xml | 9 +- .../azure-core-tracing-opentelemetry/pom.xml | 10 +- sdk/core/azure-core/pom.xml | 30 +- .../BearerTokenAuthenticationPolicy.java | 3 + .../core/http/policy/UserAgentPolicy.java | 3 - .../azure/core/http/rest/PagedFluxBase.java | 4 +- .../core/http/rest/PagedIterableBase.java | 14 +- .../java/com/azure/core/util/CoreUtils.java | 15 +- .../com/azure/core/util/IterableStream.java | 10 +- .../core/credential/CredentialsTests.java | 30 +- .../core/http/rest/PagedIterableTest.java | 300 ++++++--- .../com/azure/core/util/CoreUtilsTests.java | 13 +- .../microsoft-azure-cosmos-benchmark/pom.xml | 29 +- .../microsoft-azure-cosmos-examples/pom.xml | 16 +- sdk/cosmos/microsoft-azure-cosmos/pom.xml | 35 +- .../data/cosmos/internal/HttpConstants.java | 2 +- sdk/cosmos/pom.xml | 79 +-- .../microsoft-azure-eventgrid/pom.xml | 16 +- .../pom.xml | 7 +- .../blob/BlobCheckpointStore.java | 16 +- .../blob/BlobCheckpointStoreSample.java | 6 +- .../BlobEventProcessorClientStoreTest.java | 8 +- .../azure-messaging-eventhubs/README.md | 219 ++++--- .../azure-messaging-eventhubs/pom.xml | 10 +- .../messaging/eventhubs/CheckpointStore.java | 5 +- .../eventhubs/EventHubClientBuilder.java | 15 + .../EventHubConsumerAsyncClient.java | 4 +- .../eventhubs/EventHubConsumerClient.java | 4 +- .../EventHubProducerAsyncClient.java | 6 +- .../eventhubs/EventHubProducerClient.java | 6 +- .../eventhubs/EventHubProperties.java | 34 +- .../EventProcessorClientBuilder.java | 5 +- .../eventhubs/PartitionBasedLoadBalancer.java | 36 +- .../eventhubs/models/EventContext.java | 3 +- .../{ConsumeEvent.java => ConsumeEvents.java} | 2 +- ...EventsFromKnownSequenceNumberPosition.java | 112 ++-- ...ConsumerAsyncClientJavaDocCodeSamples.java | 3 +- .../eventhubs/GetEventHubMetadata.java | 54 +- .../eventhubs/InMemoryCheckpointStore.java | 7 +- .../eventhubs/PublishEventDataBatch.java | 68 -- .../PublishEventsToSpecificPartition.java | 54 +- .../PublishEventsWithAzureIdentity.java | 100 +++ .../PublishEventsWithCustomMetadata.java | 89 +-- .../PublishEventsWithPartitionKey.java | 74 ++- .../PublishEventsWithSizeLimitedBatches.java | 102 +++ ...EventHubClientMetadataIntegrationTest.java | 7 +- ...HubProducerAsyncClientIntegrationTest.java | 26 +- ...EventHubProducerClientIntegrationTest.java | 19 + .../eventhubs/EventHubPropertiesTest.java | 39 +- .../eventhubs/IntegrationTestBase.java | 4 +- .../PartitionBasedLoadBalancerTest.java | 8 +- .../microsoft-azure-eventhubs-eph/pom.xml | 10 +- .../pom.xml | 10 +- .../microsoft-azure-eventhubs/pom.xml | 15 +- sdk/identity/azure-identity/pom.xml | 18 +- .../pom.xml | 9 +- .../AzureKeyVaultConfiguration.java | 12 - .../CertificateClientBuilder.java | 17 +- .../azure-key-vault-certificates.properties | 2 + .../main/resources/kvErrorStrings.properties | 1 + .../azure-security-keyvault-keys/pom.xml | 12 +- .../keyvault/keys/KeyClientBuilder.java | 7 +- .../CryptographyClientBuilder.java | 10 +- .../AzureKeyVaultConfiguration.java | 12 - .../resources/azure-key-vault-keys.properties | 2 + .../keyvault/keys/KeyClientTestBase.java | 41 +- .../CryptographyClientTestBase.java | 39 +- .../azure-security-keyvault-secrets/pom.xml | 12 +- .../secrets/AzureKeyVaultConfiguration.java | 12 - .../keyvault/secrets/SecretClientBuilder.java | 8 +- .../azure-key-vault-secrets.properties | 2 + .../secrets/SecretClientTestBase.java | 30 +- .../microsoft-azure-keyvault-complete/pom.xml | 2 +- .../microsoft-azure-keyvault-core/pom.xml | 6 +- .../pom.xml | 9 +- .../pom.xml | 15 +- .../microsoft-azure-keyvault-test/pom.xml | 14 +- .../microsoft-azure-keyvault-webkey/pom.xml | 10 +- sdk/keyvault/microsoft-azure-keyvault/pom.xml | 16 +- .../microsoft-azure-loganalytics/pom.xml | 22 +- .../microsoft-azure-media/pom.xml | 38 +- .../microsoft-azure-servicebus/pom.xml | 12 +- sdk/storage/azure-storage-blob-batch/pom.xml | 29 +- .../azure-storage-blob-cryptography/pom.xml | 38 +- sdk/storage/azure-storage-blob/pom.xml | 29 +- sdk/storage/azure-storage-common/pom.xml | 13 +- .../azure-storage-file-datalake/pom.xml | 26 +- sdk/storage/azure-storage-file-share/pom.xml | 26 +- .../azure-storage-queue-cryptography/pom.xml | 21 +- sdk/storage/azure-storage-queue/pom.xml | 24 +- .../microsoft-azure-storage-blob/pom.xml | 14 +- sdk/template/azure-sdk-template/pom.xml | 5 +- 135 files changed, 2083 insertions(+), 1686 deletions(-) create mode 100644 eng/versioning/external_dependencies.txt rename sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/{ConsumeEvent.java => ConsumeEvents.java} (99%) delete mode 100644 sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventDataBatch.java create mode 100644 sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithAzureIdentity.java create mode 100644 sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithSizeLimitedBatches.java delete mode 100644 sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java create mode 100644 sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties delete mode 100644 sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java create mode 100644 sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties delete mode 100644 sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java create mode 100644 sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8953a8cc4c6f..5a1caa588043 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -32,6 +32,7 @@ /eng/code-quality-reports/ @mssfang @JonathanGiles /eng/jacoco-test-coverage/ @srnagar @JonathanGiles /eng/spotbugs-aggregate-report/ @srnagar @JonathanGiles +/parent/ @JimSuplizio /**/tests.yml @danieljurek /**/ci.yml @mitchdenny diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index 98d5197c16d8..d252c556578e 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -10,7 +10,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../pom.client.xml @@ -39,7 +39,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -49,7 +49,7 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 com.azure @@ -154,7 +154,7 @@ org.jacoco jacoco-maven-plugin - ${jacoco-maven-plugin.version} + 0.8.4 prepare-package diff --git a/eng/spotbugs-aggregate-report/pom.xml b/eng/spotbugs-aggregate-report/pom.xml index 5fa530140399..4d616ae4e111 100644 --- a/eng/spotbugs-aggregate-report/pom.xml +++ b/eng/spotbugs-aggregate-report/pom.xml @@ -6,7 +6,7 @@ azure-client-sdk-parent com.azure - 1.6.0 + 1.7.0 ../../pom.client.xml 4.0.0 @@ -25,6 +25,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 add-client-source @@ -82,6 +83,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 add-data-source @@ -114,6 +116,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 -maxLineLength 120 @@ -141,7 +144,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -151,7 +154,7 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 com.azure @@ -249,7 +252,7 @@ com.google.code.findbugs jsr305 - 3.0.2 + 3.0.2 provided @@ -324,7 +327,7 @@ com.microsoft.azure azure-servicebus - 3.1.1 + 3.1.4 diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt new file mode 100644 index 000000000000..05afa0fa9c4e --- /dev/null +++ b/eng/versioning/external_dependencies.txt @@ -0,0 +1,209 @@ +# Format; +# groupId:artifactId;dependency-version +com.fasterxml.jackson.core:jackson-annotations;2.10.0 +com.fasterxml.jackson.core:jackson-core;2.10.0 +com.fasterxml.jackson.core:jackson-databind;2.10.0 +com.fasterxml.jackson.dataformat:jackson-dataformat-xml;2.10.0 +com.fasterxml.jackson.datatype:jackson-datatype-jsr310;2.10.0 +com.fasterxml.uuid:java-uuid-generator;3.2.0 +com.github.spotbugs:spotbugs;4.0.0-beta3 +com.github.spotbugs:spotbugs-maven-plugin;3.1.12.2 +com.google.code.gson:gson;2.8.5 +com.google.guava:guava;24.1.1-jre +com.microsoft.azure:azure-annotations;1.7.0 +com.microsoft.azure:azure-arm-client-runtime;1.6.15 +com.microsoft.azure:azure-client-authentication;1.6.15 +com.microsoft.azure:azure-client-runtime;1.6.15 +com.microsoft.azure:azure-core;0.9.8 +com.microsoft.azure:azure-keyvault-cryptography;1.2.2 +com.microsoft.azure:azure-mgmt-keyvault;1.11.1 +com.microsoft.azure:client-runtime;1.6.15 +com.microsoft.azure:qpid-proton-j-extensions;1.2.1 +com.microsoft.azure:spotbugs-maven-plugin;1.2.1 +com.microsoft.rest:client-runtime;1.6.15 +com.microsoft.rest.v2:client-runtime;2.1.1 +com.squareup.okhttp3:okhttp;4.2.2 +commons-codec:commons-codec;1.13 +io.micrometer:micrometer-core;1.2.0 +io.micrometer:micrometer-registry-azure-monitor;1.2.0 +io.micrometer:micrometer-registry-graphite;1.2.0 +io.netty:netty-buffer;4.1.42.Final +io.netty:netty-codec-http;4.1.42.Final +io.netty:netty-handler;4.1.42.Final +io.netty:netty-handler-proxy;4.1.42.Final +io.netty:netty-tcnative;2.0.26.Final +io.netty:netty-tcnative-boringssl-static;2.0.26.Final +io.opencensus:opencensus-api;0.24.0 +io.opencensus:opencensus-impl;0.24.0 +io.projectreactor.netty:reactor-netty;0.9.0.RELEASE +io.projectreactor:reactor-core;3.3.0.RELEASE +io.reactivex:rxjava;1.2.4 +org.apache.httpcomponents:httpclient;4.3.6 +org.apache.logging.log4j:log4j-api;2.11.1 +org.apache.logging.log4j:log4j-core;2.11.1 +org.apache.qpid:proton-j;0.33.2 +org.asynchttpclient:async-http-client;2.10.4 +org.codehaus.groovy:groovy-eclipse-batch;2.5.8-01 +org.codehaus.groovy:groovy-eclipse-compiler;3.4.0-01 +org.powermock:powermock-api-mockito2;2.0.2 +org.powermock:powermock-module-junit4;2.0.2 +org.slf4j:slf4j-api;1.7.28 +org.slf4j:slf4j-log4j12;1.7.0 +org.slf4j:slf4j-simple;1.7.25 + +## Test dependency versions +cglib:cglib-nodep;3.2.7 +com.github.tomakehurst:wiremock-standalone;2.24.1 +com.microsoft.azure:adal4j;1.6.4 +com.microsoft.azure:azure-mgmt-graph-rbac;1.3.0 +com.microsoft.azure:azure-mgmt-keyvault;1.11.1 +com.microsoft.azure:azure-mgmt-resources;1.3.0 +com.microsoft.azure:azure-mgmt-storage;1.3.0 +com.microsoft.azure:azure-storage;8.0.0 +com.microsoft.azure:msal4j;0.5.0-preview +io.opentelemetry:opentelemetry-api;0.2.0 +io.opentelemetry:opentelemetry-sdk;0.2.0 +io.projectreactor:reactor-test;3.3.0.RELEASE +junit:junit;4.13-beta-3 +log4j:log4j;1.2.17 +org.assertj:assertj-core;3.11.1 +org.bouncycastle:bcprov-jdk15on;1.60 +org.eclipse.jetty:jetty-http;9.4.11.v20180605 +org.eclipse.jetty:jetty-server;9.4.11.v20180605 +org.hamcrest:hamcrest-all;1.3 +org.hamcrest:hamcrest-library;2.2 +# https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea +# use 5.4.2 now since Version 5.5.2 as of 11.2019 fails to discover tests +# https://youtrack.jetbrains.com/issue/IDEA-223700 +# org.junit:junit-bom;5.4.2 is a pom file that will add its dependencyManagement section to parent pom's which +# effectively means that each dependency needs to be listed here. +org.junit.jupiter:junit-jupiter;5.4.2 +org.junit.jupiter:junit-jupiter-api;5.4.2 +org.junit.jupiter:junit-jupiter-engine;5.4.2 +org.junit.jupiter:junit-jupiter-migrationsupport;5.4.2 +org.junit.jupiter:junit-jupiter-params;5.4.2 +org.junit.platform:junit-platform-commons;1.4.2 +org.junit.platform:junit-platform-console;1.4.2 +org.junit.platform:junit-platform-engine;1.4.2 +org.junit.platform:junit-platform-launcher;1.4.2 +org.junit.platform:junit-platform-reporting;1.4.2 +org.junit.platform:junit-platform-runner;1.4.2 +org.junit.platform:junit-platform-suite-api;1.4.2 +org.junit.platform:junit-platform-testkit;1.4.2 +org.junit.vintage:junit-vintage-engine;5.4.2 +org.openjdk.jmh:jmh-core;1.22 +org.openjdk.jmh:jmh-generator-annprocess;1.22 +org.spockframework:spock-core;1.3-groovy-2.5 +org.testng:testng;6.14.3 +uk.org.lidalia:slf4j-test;1.2.0 + +## Maven Tools versions +com.azure:sdk-build-tools;1.0.0 +com.beust:jcommander;1.58 +com.google.code.findbugs:jsr305;3.0.2 +com.nimbusds:nimbus-jose-jwt;6.0.1 +com.nimbusds:oauth2-oidc-sdk;6.14 +com.puppycrawl.tools:checkstyle;8.24 +commons-io:commons-io;2.5 +commons-validator:commons-validator;1.6 +io.dropwizard.metrics:metrics-core;4.0.5 +io.dropwizard.metrics:metrics-graphite;4.0.5 +io.dropwizard.metrics:metrics-jvm;4.0.5 +io.reactivex.rxjava2:rxjava;2.2.4 +net.java.dev.jna:jna-platform;5.4.0 +org.apache.commons:commons-collections4;4.2 +org.apache.commons:commons-lang3;3.8.1 +org.apache.commons:commons-text;1.6 +org.apache.maven.plugins:maven-antrun-plugin;1.8 +org.apache.maven.plugins:maven-assembly-plugin;2.2 +org.apache.maven.plugins:maven-checkstyle-plugin;3.1.0 +org.apache.maven.plugins:maven-clean-plugin;3.0.0 +org.apache.maven.plugins:maven-compiler-plugin;3.8.1 +org.apache.maven.plugins:maven-eclipse-plugin;2.8 +org.apache.maven.plugins:maven-failsafe-plugin;2.22.0 +org.apache.maven.plugins:maven-help-plugin;2.1.1 +org.apache.maven.plugins:maven-jar-plugin;3.1.2 +org.apache.maven.plugins:maven-javadoc-plugin;3.1.1 +org.apache.maven.plugins:maven-jxr-plugin;3.0.0 +org.apache.maven.plugins:maven-project-info-reports-plugin;3.0.0 +org.apache.maven.plugins:maven-release-plugin;2.5.3 +org.apache.maven.plugins:maven-resources-plugin;2.4.3 +org.apache.maven.plugins:maven-site-plugin;3.7.1 +org.apache.maven.plugins:maven-source-plugin;3.0.1 +org.apache.maven.plugins:maven-surefire-plugin;3.0.0-M3 +org.apidesign.javadoc:codesnippet-doclet;0.32 +org.codehaus.mojo:build-helper-maven-plugin;3.0.0 +org.codehaus.mojo:exec-maven-plugin;1.2.1 +org.codehaus.mojo:properties-maven-plugin;1.0.0 +org.codehaus.mojo:xml-maven-plugin;1.0 +org.eclipse.jetty:jetty-maven-plugin;9.3.22.v20171030 +org.eclipse.m2e:lifecycle-mapping;1.0.0 +org.jacoco:jacoco-maven-plugin;0.8.4 +org.jacoco:org.jacoco.agent;0.8.4 +org.mockito:mockito-core;3.0.0 +org.nanohttpd:nanohttpd;2.3.1 + +# External Dependency Exceptions +# This section is for external dependencies whose versions were different than +# what was defined in the parent pom. +# Format; +# _groupId:artifactId;dependency-version + +# This is a unique dependency as it is the only test-jar dependency in the +# data track. It's also using a SNAPSHOT version which should be disallowed but there is +# going to be some investigation necessary to find, at the very least, a newer version +# which is, hopefully, not a SNAPSHOT. +# sdk\batch\microsoft-azure-batch\pom.xml +# sdk\keyvault\microsoft-azure-keyvault\pom.xml +# sdk\keyvault\microsoft-azure-keyvault-extensions\pom.xml +# sdk\keyvault\microsoft-azure-keyvault-test\pom.xml +test_jar_com.microsoft.azure:azure-mgmt-resources;1.3.1-SNAPSHOT + +# sdk\applicationinsights\microsoft-azure-applicationinsights-query\pom.xml +applicationinsights_com.microsoft.azure:azure-arm-client-runtime;1.6.3 +applicationinsights_com.microsoft.azure:azure-client-runtime;1.6.3 +applicationinsights_com.microsoft.azure:azure-client-authentication;1.6.3 + +# everything under sdk\cosmos +cosmos_org.mockito:mockito-core;1.10.19 +cosmos_com.google.guava:guava;27.0.1-jre +cosmos_io.dropwizard.metrics:metrics-core;4.1.0 +cosmos_io.dropwizard.metrics:metrics-jvm;4.1.0 +cosmos_io.dropwizard.metrics:metrics-graphite;4.1.0 + +# sdk\eventgrid\microsoft-azure-eventgrid\pom.xml +eventgrid_com.microsoft.azure:azure-client-runtime;1.5.0 +eventgrid_com.microsoft.azure:azure-client-authentication;1.5.0 +eventgrid_commons-io:commons-io;2.6 + +# sdk\eventhubs\microsoft-azure-eventhubs-eph\pom.xml +# sdk\eventhubs\microsoft-azure-eventhubs-extensions\pom.xml +eventhubs_com.microsoft.azure:msal4j;0.4.0-preview + +# sdk\keyvault\microsoft-azure-keyvault-extensions\pom.xml +keyvault_org.mockito:mockito-core;1.10.19 +# sdk\keyvault\microsoft-azure-keyvault-test\pom.xml +keyvault_com.microsoft.azure:azure-storage;4.4.0 + +# sdk\loganalytics\microsoft-azure-loganalytics\pom.xml +loganalytics_com.microsoft.azure:azure-arm-client-runtime;1.6.3 +loganalytics_com.microsoft.azure:azure-client-authentication;1.6.3 +loganalytics_com.microsoft.azure:azure-client-runtime;1.6.3 + +# sdk\mediaservices\microsoft-azure-media\pom.xml which hasn't been released for 2 years +# all of these unique references below are listed here because they're old, some are over 10 years old +media_javax.xml.bind:jaxb-api;2.2.7 +media_javax.inject:javax.inject;1 +media_javax.mail:mail;1.4.5 +media_com.sun.jersey:jersey-client;1.19 +media_com.sun.jersey:jersey-json;1.19 +media_commons-logging:commons-logging;1.1.1 +media_io.jsonwebtoken:jjwt;0.5.1 +media_org.mockito:mockito-all;1.9.0 +media_com.microsoft.azure:adal4j;1.2.0 + +# sdk\servicebus\microsoft-azure-servicebus\pom.xml +servicebus_com.microsoft.azure:azure-client-authentication;1.6.7 + +# sdk\storage\azure-storage-blob-cryptography\pom.xml +storage_com.microsoft.azure:azure-storage;8.4.0 \ No newline at end of file diff --git a/eng/versioning/update_versions.py b/eng/versioning/update_versions.py index 93b24f9c5a29..97c917a1cd2e 100644 --- a/eng/versioning/update_versions.py +++ b/eng/versioning/update_versions.py @@ -2,7 +2,7 @@ # Licensed under the MIT License. # Use case: Update all the versions in README.md and pom.xml files based on -# the versions in versions_[client|data|management].txt/dependencies_[client|data|management].txt +# the versions in versions_[client|data|management].txt, external_dependencies.txt # # python eng/versioning/update_versions.py --update-type [library|external_dependency|all] -build-type [client|data|management] # For example: To update the library versions for the client track without touching the README files @@ -14,6 +14,14 @@ # For example: To update all versions for the client track for a given pom file # python eng/versioning/update_versions.py --ut all --bt client --tf \pom.xml # +# Use case: Update the external_dependencies +# +# python utilities/update_versions.py --update-type [library|external_dependency|all] -build-type [client|data|management] --target-file pom-file-to-update +# For example: To update all versions for the client track for a given pom file. While the skip readme flag isn't entirely +# necessary here, since our README.md files don't contain externaly dependency versions, there's no point in scanning files +# that shouldn't require changes. +# python eng/versioning/update_versions.py --ut external_dependency --sr +# # The script must be run at the root of azure-sdk-for-java. import argparse @@ -24,6 +32,7 @@ import time from utils import BuildType from utils import CodeModule +from utils import external_dependency_version_regex from utils import UpdateType from utils import version_regex_str_no_anchor from utils import version_update_start_marker @@ -65,14 +74,24 @@ def update_versions(version_map, target_file): if version_type == 'current': try: new_version = module.current + newline = re.sub(version_regex_str_no_anchor, new_version, line) except AttributeError: raise ValueError('Module: {0} does not have a current version.\nFile={1}\nLine={2}'.format(module_name, target_file, line)) elif version_type == 'dependency': - new_version = module.dependency + try: + new_version = module.dependency + newline = re.sub(version_regex_str_no_anchor, new_version, line) + except AttributeError: + raise ValueError('Module: {0} does not have a dependency version.\nFile={1}\nLine={2}'.format(module_name, target_file, line)) + elif version_type == 'external_dependency': + try: + new_version = module.external_dependency + newline = re.sub(external_dependency_version_regex, new_version, line) + except AttributeError: + raise ValueError('Module: {0} does not have an external dependency version.\nFile={1}\nLine={2}'.format(module_name, target_file, line)) else: raise ValueError('Invalid version type: {} for module: {}.\nFile={}\nLine={}'.format(version_type, module_name, target_file, line)) - newline = re.sub(version_regex_str_no_anchor, new_version, line) newlines.append(newline) file_changed = True else: @@ -112,7 +131,7 @@ def update_versions_all(update_type, build_type, target_file, skip_readme): load_version_map_from_file(version_file, version_map) if update_type == UpdateType.external_dependency or update_type == UpdateType.all: - dependency_file = os.path.normpath('eng/versioning/external_dependency_' + build_type.name + '.txt') + dependency_file = os.path.normpath('eng/versioning/external_dependencies.txt') print('external_dependency_file=' + dependency_file) load_version_map_from_file(dependency_file, version_map) @@ -132,7 +151,7 @@ def update_versions_all(update_type, build_type, target_file, skip_readme): # https://github.com/Azure/azure-sdk-for-java/issues/3141 has been fixed. # version_*_java_files.txt # BEGIN:Versions_in_java_files - if not target_file: + if not target_file and BuildType.none != build_type: # the good thing here is that the java files only contain library versions, not # external versions version_java_file = os.path.normpath('eng/versioning/version_' + build_type.name + '_java_files.txt') @@ -150,14 +169,12 @@ def update_versions_all(update_type, build_type, target_file, skip_readme): def main(): parser = argparse.ArgumentParser(description='Replace version numbers in poms and READMEs.') parser.add_argument('--update-type', '--ut', type=UpdateType, choices=list(UpdateType)) - parser.add_argument('--build-type', '--bt', type=BuildType, choices=list(BuildType)) + parser.add_argument('--build-type', '--bt', nargs='?', type=BuildType, choices=list(BuildType), default=BuildType.none) parser.add_argument('--skip-readme', '--sr', action='store_true', help='Skip updating of readme files if argument is present' ) parser.add_argument('--target-file', '--tf', nargs='?', help='File to update (optional) - all files in the current directory and subdirectories are scanned if omitted') args = parser.parse_args() if args.build_type == BuildType.management: raise ValueError('{} is not currently supported.'.format(BuildType.management.name)) - if args.update_type == UpdateType.external_dependency or args.update_type == UpdateType.all: - raise ValueError('{} is not currently supported.'.format(UpdateType.external_dependency.name)) start_time = time.time() update_versions_all(args.update_type, args.build_type, args.target_file, args.skip_readme) elapsed_time = time.time() - start_time diff --git a/eng/versioning/utils.py b/eng/versioning/utils.py index 056f323dd6f5..6ffc5defc18b 100644 --- a/eng/versioning/utils.py +++ b/eng/versioning/utils.py @@ -18,6 +18,10 @@ # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string version_regex_str_no_anchor = r'(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' +# External dependency versions do not have to match semver format and the semver regular expressions +# will partially match and produce some hilarious results. +external_dependency_version_regex = r'(?<=).+?(?=)' + # This is the original regular expression for semver. This differs from the # previous one in that start of line and end of line anchors are left in place. # This is the regex that would be used to ensure the entire string matches @@ -39,6 +43,7 @@ class BuildType(Enum): client = 'client' data = 'data' management = 'management' + none = 'none' # in the case where only external dependencies is being updated # defining string is necessary to get ArgumentParser's help output to produce # human readable values of BuildType @@ -54,11 +59,13 @@ def __init__(self, module_str): items = module_str.split(';') if len(items) == 2: self.name = items[0] - self.dependency = items[1].strip() + self.external_dependency = items[1].strip() + self.update_type = UpdateType.external_dependency elif len(items) == 3: self.name = items[0] self.dependency = items[1] self.current = items[2].strip() + self.update_type = UpdateType.library else: raise ValueError('unable to parse module string: ' + module_str) @@ -68,7 +75,7 @@ def __str__(self): try: return self.name + ': Dependency version=' + self.dependency + ': Current version=' + self.current except AttributeError: - return self.name + ': External Dependency version=' + self.dependency + return self.name + ': External Dependency version=' + self.external_dependency # return the CodeModule string formatted for a version file def string_for_version_file(self): diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index c8b4959b9ece..52d0793b5158 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -1,11 +1,11 @@ # Format; # groupId:artifactId;dependency-version;current-version -com.azure:azure-sdk-parent;1.5.0;1.5.0 -com.azure:azure-client-sdk-parent;1.6.0;1.6.0 -com.azure:azure-core;1.1.0-beta.1;1.1.0-beta.1 +com.azure:azure-sdk-parent;1.6.0;1.6.0 +com.azure:azure-client-sdk-parent;1.7.0;1.7.0 +com.azure:azure-core;1.1.0;1.1.0 com.azure:azure-core-amqp;1.0.0-beta.8;1.0.0-beta.8 -com.azure:azure-core-http-netty;1.1.0-beta.1;1.1.0-beta.1 +com.azure:azure-core-http-netty;1.1.0;1.1.0 com.azure:azure-core-http-okhttp;1.1.0-beta.1;1.1.0-beta.1 com.azure:azure-core-management;1.0.0-beta.8;1.0.0-beta.8 com.azure:azure-core-test;1.1.0-beta.1;1.1.0-beta.1 @@ -26,4 +26,4 @@ com.azure:azure-storage-file-datalake;12.0.0-beta.7;12.0.0-beta.7 com.azure:azure-storage-queue;12.1.0-beta.1;12.1.0-beta.1 com.azure:azure-storage-queue-cryptography;12.0.0-beta.6;12.0.0-beta.6 com.azure:azure-core-tracing-opencensus;1.0.0-beta.5;1.0.0-beta.5 -com.azure:azure-core-tracing-opetelemetry;1.0.0-beta.1;1.0.0-beta.1 +com.azure:azure-core-tracing-opentelemetry;1.0.0-beta.1;1.0.0-beta.1 diff --git a/eng/versioning/version_client_java_files.txt b/eng/versioning/version_client_java_files.txt index b59b8ee005c9..d0756c071b03 100644 --- a/eng/versioning/version_client_java_files.txt +++ b/eng/versioning/version_client_java_files.txt @@ -4,9 +4,6 @@ # The file format here should be the relative path from the root of the azure-sdk-for-java sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ClientConstants.java -sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java -sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java -sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index eaa65d3c7ba7..8fb7297eb281 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -2,7 +2,7 @@ # groupId:artifactId;dependency-version;current-version # Note: com.azure:azure-sdk-parent is in version_client.txt -com.azure:azure-data-sdk-parent;1.2.0;1.2.0 +com.azure:azure-data-sdk-parent;1.3.0;1.3.0 com.microsoft.azure:azure-batch;7.1.0-beta.1;7.1.0-beta.1 com.microsoft.azure:azure-applicationinsights-query;1.0.0-beta-2;1.0.0-beta-2 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-spellcheck;1.1.0-beta.1;1.1.0-beta.1 @@ -23,21 +23,21 @@ com.microsoft.azure.cognitiveservices:azure-cognitiveservices-contentmoderator;1 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-prediction;1.1.0-beta.3;1.1.0-beta.3 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-training;1.1.0-beta.3;1.1.0-beta.3 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-faceapi;1.1.0-beta.1;1.1.0-beta.1 -com.microsoft.azure:azure-cosmos-parent;3.3.1;3.4.0 -com.microsoft.azure:azure-cosmos;3.3.1;3.4.0 -com.microsoft.azure:azure-cosmos-benchmark;3.3.1;3.4.0 -com.microsoft.azure:azure-cosmos-examples;3.3.1;3.4.0 +com.microsoft.azure:azure-cosmos-parent;3.4.0;3.5.0 +com.microsoft.azure:azure-cosmos;3.4.0;3.5.0 +com.microsoft.azure:azure-cosmos-benchmark;3.4.0;3.4.0 +com.microsoft.azure:azure-cosmos-examples;3.4.0;3.4.0 com.microsoft.azure:azure-eventhubs;3.1.0;3.1.0 com.microsoft.azure:azure-eventhubs-eph;3.1.0;3.1.0 com.microsoft.azure:azure-eventhubs-extensions;3.1.0;3.1.0 com.microsoft.azure:azure-keyvault;1.2.3;1.2.3 com.microsoft.azure:azure-keyvault-complete;1.2.3;1.2.3 com.microsoft.azure:azure-keyvault-core;1.2.3;1.2.3 -com.microsoft.azure:azure-keyvault-cryptography;1.2.2;1.2.3 +com.microsoft.azure:azure-keyvault-cryptography;1.2.3;1.2.3 com.microsoft.azure:azure-keyvault-extensions;1.2.3;1.2.3 com.microsoft.azure:azure-keyvault-test;1.2.3;1.2.3 com.microsoft.azure:azure-keyvault-webkey;1.2.3;1.2.3 -com.microsoft.azure:azure-servicebus;3.1.3;3.1.3 +com.microsoft.azure:azure-servicebus;3.1.4;3.1.4 com.microsoft.azure:azure-storage-blob;11.0.2;11.0.2 com.microsoft.azure.msi_auth_token_provider:azure-authentication-msi-token-provider;1.1.0-beta.1;1.1.0-beta.1 com.microsoft.azure:azure-eventgrid;1.4.0-beta.1;1.4.0-beta.1 diff --git a/parent/pom.xml b/parent/pom.xml index ed16c32b9aa1..dce4691580ac 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -6,7 +6,7 @@ com.azure azure-sdk-parent pom - 1.5.0 + 1.6.0 Microsoft Azure SDK for Java Parent Parent POM for Microsoft Azure SDK for Java @@ -16,13 +16,6 @@ http://microsoft.com - - com.microsoft.maven - java-8-parent - 8.0.2 - - - The MIT License (MIT) @@ -97,587 +90,8 @@ https://azuresdkartifacts.blob.core.windows.net/azure-sdk-for-java https://github.com/Azure/azure-sdk-for-java/issues - - - 2.10.0 - 2.10.0 - 1.6.15 - 1.13 - 4.0.0-beta3 - 3.1.12.2 - 0.33.2 - 1.2.1 - 2.11.1 - 3.4.0-01 - 2.5.8-01 - 2.1.1 - 1.7.28 - 1.7.0 - 3.3.0.RELEASE - 0.9.0.RELEASE - 4.1.42.Final - 2.0.26.Final - 4.2.2 - 2.10.4 - 0.24.0 - 1.2.4 - 24.1.1-jre - 1.7.0 - 4.5.0.201609210915-r - 3.3 - 1.14.0 - 0.32 - 6.14 - 4.0.5 - 2.2.4 - 2.5 - 3.8.1 - 1.6 - 1.6 - 4.2 - 1.58 - 2.3.1 - 3.0.2 - 5.4.0 - - - 1.6.4 - 0.5.0-preview - 1.60 - 1.11.1 - 1.3.0 - 1.3.1-SNAPSHOT - 1.3.0 - 1.3.0 - 8.0.0 - 1.3-groovy-2.5 - 3.2.7 - 1.2.0 - 3.3.0.RELEASE - 2.24.1 - 9.4.11.v20180605 - 9.4.11.v20180605 - 4.13-beta-3 - - 5.4.2 - 1.5.2 - 1.2.17 - 6.14.3 - 3.11.1 - 1.3 - 2.2 - - - 1.0.2 - 1.0.0 - 3.1.1 - 2.5.3 - 3.8.1 - 9.3.22.v20171030 - 1.0.0 - 2.4.3 - 3.0.0 - 1.0.0 - 2.22.0 - 2.4.1 - 3.0.0 - 3.1.2 - 1.0 - 3.7.1 - 3.0.0 - 1.8 - 3.1.0 - 8.24 - 3.0.0 - 1.7.4 - 0.8.4 - 1.2.1 - 2.8 - 2.2 - 3.0.0-M3 - - - - - com.microsoft.azure - azure-client-runtime - ${client-runtime.version} - - - - com.microsoft.azure - azure-arm-client-runtime - ${client-runtime.version} - - - - com.microsoft.azure - adal4j - ${adal4j.version} - - - - com.microsoft.azure - msal4j - ${msal4j.version} - - - - com.microsoft.azure - azure-annotations - ${azure-annotations.version} - - - - - com.microsoft.rest - client-runtime - ${client-runtime.version} - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind.version} - - - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - - com.fasterxml.uuid - java-uuid-generator - ${java-uuid-generator.version} - - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson.version} - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - - - - - org.apache.qpid - proton-j - ${proton-j-version} - - - - com.microsoft.azure - qpid-proton-j-extensions - ${qpid-proton-j-extensions-version} - - - - - - commons-codec - commons-codec - ${commons-codec.version} - - - - commons-validator - commons-validator - ${commons-validator.version} - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - - org.apache.commons - commons-text - ${commons-text.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - org.apache.logging.log4j - log4j-api - ${log4j-api.version} - - - - com.microsoft.rest.v2 - client-runtime - ${client-runtime.version.v2} - - - - org.slf4j - slf4j-api - ${slf4j-api.version} - - - - org.slf4j - slf4j-log4j12 - ${slf4j-log4j12.version} - - - - io.projectreactor - reactor-core - ${reactor-core.version} - - - io.projectreactor.netty - reactor-netty - ${reactor-netty.version} - - - io.netty - netty-codec-http - ${netty.version} - - - io.netty - netty-handler - ${netty.version} - - - io.netty - netty-handler-proxy - ${netty.version} - - - io.netty - netty-buffer - ${netty.version} - - - - io.netty - netty-tcnative-boringssl-static - ${netty-tcnative-boringssl-static.version} - - - - org.nanohttpd - nanohttpd - ${nanohttpd.version} - - - net.java.dev.jna - jna-platform - ${jna-platform.version} - - - com.squareup.okhttp3 - okhttp - ${okhttp.version} - - - - junit - junit - ${junit.version} - - - - - org.junit - junit-bom - ${junit-jupiter.version} - pom - - - - - org.hamcrest - hamcrest-library - ${hamcrest-library.version} - test - - - - org.asynchttpclient - async-http-client - ${async-http-client.version} - - - - io.opencensus - opencensus-api - ${opencensus.version} - - - - io.reactivex - rxjava - ${rxjava.version} - - - - io.reactivex.rxjava2 - rxjava - ${rxjava2.version} - - - - io.dropwizard.metrics - metrics-core - ${metrics.version} - - - - io.dropwizard.metrics - metrics-jvm - ${metrics.version} - - - - io.dropwizard.metrics - metrics-graphite - ${metrics.version} - - - - com.beust - jcommander - ${jcommander.version} - - - - com.google.guava - guava - ${guava.version} - - - - log4j - log4j - ${log4j.version} - - - - org.eclipse.jgit - org.eclipse.jgit - ${jgit.version} - - - org.apache.httpcomponents - httpclient - - - - - - commons-net - commons-net - ${commons-net.version} - - - - com.nimbusds - oauth2-oidc-sdk - ${oauth2-oidc-sdk.version} - - - - org.codehaus.groovy - groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} - - - - - com.microsoft.azure - azure-mgmt-storage - ${azure-mgmt-storage.version} - test - - - - org.hamcrest - hamcrest-all - ${hamcrest.version} - test - - - - com.microsoft.azure - azure-mgmt-graph-rbac - ${azure-mgmt-graph-rbac.version} - test - - - - org.testng - testng - ${testng.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - com.microsoft.azure - azure-mgmt-resources - ${azure-mgmt-resources-test.version} - test-jar - test - - - - com.microsoft.azure - azure-client-authentication - ${client-runtime.version} - test - - - - com.microsoft.azure - azure-arm-client-runtime - ${client-runtime.version} - test-jar - test - - - - org.bouncycastle - bcprov-jdk15on - ${bcprov-jdk15on.version} - - - - com.microsoft.azure - azure-mgmt-keyvault - ${azure-mgmt-keyvault.version} - test - - - - com.microsoft.azure - azure-mgmt-resources - ${azure-mgmt-resources.version} - test - - - - com.microsoft.azure - azure-storage - ${azure-storage.version} - - - - commons-io - commons-io - ${commons-io.version} - - - - org.spockframework - spock-core - test - ${spock-core.version} - - - - cglib - cglib-nodep - ${cglib-nodep.version} - test - - - - org.slf4j - slf4j-simple - ${slf4j.version} - test - - - - io.projectreactor - reactor-test - ${reactor-test.version} - - - - uk.org.lidalia - slf4j-test - ${slf4j-test.version} - test - - - - com.github.tomakehurst - wiremock-standalone - ${wiremock-standalone.version} - test - - - - org.eclipse.jetty - jetty-http - ${jetty-http.version} - test - - - - org.eclipse.jetty - jetty-server - ${jetty-server.version} - test - - - - org.mockito - mockito-core - ${mockito-core.version} - test - - - - org.powermock - powermock-module-junit4 - 2.0.2 - test - - - - org.powermock - powermock-api-mockito2 - 2.0.2 - test - - - - @@ -685,7 +99,7 @@ org.codehaus.mojo build-helper-maven-plugin - ${build-helper-maven-plugin.version} + 3.0.0 compile-samples-source @@ -706,35 +120,35 @@ org.apache.maven.plugins maven-assembly-plugin - ${maven-assembly-plugin.version} + 2.2 org.apache.maven.plugins maven-eclipse-plugin - ${maven-eclipse-plugin.version} + 2.8 org.codehaus.mojo exec-maven-plugin - ${maven-exec-plugin.version} + 1.2.1 org.apache.maven.plugins maven-resources-plugin - ${maven-resources-plugin.version} + 2.4.3 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 ${surefireArgLine} @@ -764,14 +178,14 @@ org.apache.maven.plugins maven-release-plugin - ${maven-release-plugin.version} + 2.5.3 org.apache.maven.plugins maven-clean-plugin - ${maven-clean-plugin.version} + 3.0.0 true @@ -794,7 +208,7 @@ org.eclipse.m2e lifecycle-mapping - ${lifecycle-mapping.version} + 1.0.0 @@ -820,7 +234,7 @@ org.apache.maven.plugins maven-failsafe-plugin - ${maven-failsafe-plugin.version} + 2.22.0 @@ -835,7 +249,7 @@ org.eclipse.jetty jetty-maven-plugin - ${jetty-maven-plugin.version} + 9.3.22.v20171030 0 11079 @@ -849,14 +263,14 @@ org.apache.maven.plugins maven-jar-plugin - ${maven-jar-plugin.version} + 3.1.2 org.apache.maven.plugins maven-site-plugin - ${maven-site-plugin.version} + 3.7.1 false @@ -866,7 +280,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - ${maven-project-info-reports-plugin.version} + 3.0.0 diff --git a/pom.client.xml b/pom.client.xml index 5eb2ba7cf69c..b5284abab88f 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -7,7 +7,7 @@ com.azure azure-client-sdk-parent pom - 1.6.0 + 1.7.0 Microsoft Azure SDK for Java - Client Libraries Parent POM for Microsoft Azure SDK for Java @@ -20,7 +20,7 @@ com.azure azure-sdk-parent - 1.5.0 + 1.6.0 ./parent/pom.xml @@ -111,7 +111,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 true true @@ -122,17 +122,17 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} + 3.1.0 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 com.puppycrawl.tools checkstyle - ${checkstyle.version} + 8.24 @@ -162,17 +162,17 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 com.github.spotbugs spotbugs - ${spotbugs.version} + 4.0.0-beta3 @@ -198,7 +198,7 @@ org.codehaus.mojo xml-maven-plugin - ${xml-maven-plugin.version} + 1.0 verify @@ -228,7 +228,7 @@ com.github.spotbugs spotbugs - ${spotbugs.version} + 4.0.0-beta3 @@ -237,6 +237,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 ${packageOutputDirectory} @@ -246,6 +247,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 attach-javadocs @@ -266,6 +268,7 @@ org.apache.maven.plugins maven-source-plugin + 3.0.1 attach-sources @@ -281,8 +284,9 @@ + org.apache.maven.plugins maven-antrun-plugin - ${maven-antrun-plugin.version} + 1.8 copy @@ -301,7 +305,7 @@ org.jacoco jacoco-maven-plugin - ${jacoco-maven-plugin.version} + 0.8.4 default-instrument @@ -334,6 +338,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 @@ -342,6 +347,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 1.8 Azure SDK for Java Reference Documentation @@ -446,7 +452,7 @@ org.apidesign.javadoc codesnippet-doclet - ${codesnippet4javadoc.version} + 0.32 -maxLineLength 120 @@ -465,17 +471,17 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 com.github.spotbugs spotbugs - ${spotbugs.version} + 4.0.0-beta3 @@ -492,6 +498,7 @@ org.apache.maven.plugins maven-checkstyle-plugin + 3.1.0 true true @@ -501,7 +508,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 false @@ -517,7 +524,7 @@ org.jacoco org.jacoco.agent runtime - ${jacoco-maven-plugin.version} + 0.8.4 test @@ -527,7 +534,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} + 3.1.0 eng/code-quality-reports/src/main/resources/checkstyle/checkstyle.xml eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -560,7 +567,7 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 max Low @@ -575,7 +582,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 non-aggregate @@ -622,7 +629,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 + 3.0.0 @@ -664,7 +671,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -701,7 +708,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 module-info.java @@ -716,7 +723,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 module-info.java @@ -744,7 +751,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 11 @@ -801,7 +808,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -858,6 +865,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 false @@ -930,6 +938,7 @@ org.codehaus.mojo exec-maven-plugin + 1.2.1 generate-overview-from-readme @@ -955,7 +964,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 ${project.basedir}/readme_overview.html diff --git a/pom.data.xml b/pom.data.xml index f8a302976724..9a21d076e3e5 100644 --- a/pom.data.xml +++ b/pom.data.xml @@ -6,7 +6,7 @@ com.azure azure-data-sdk-parent pom - 1.2.0 + 1.3.0 Microsoft Azure SDK for Java - Data Plane Libraries Parent POM for Microsoft Azure SDK for Java @@ -19,7 +19,7 @@ com.azure azure-sdk-parent - 1.3.0 + 1.6.0 ./parent/pom.xml @@ -70,17 +70,17 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} + 3.1.0 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 com.puppycrawl.tools checkstyle - ${checkstyle.version} + 8.24 @@ -111,12 +111,12 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 @@ -143,7 +143,7 @@ org.codehaus.mojo xml-maven-plugin - ${xml-maven-plugin.version} + 1.0 verify @@ -171,7 +171,7 @@ com.github.spotbugs spotbugs - ${spotbugs.version} + 4.0.0-beta3 @@ -180,6 +180,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 ${packageOutputDirectory} @@ -189,6 +190,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 attach-javadocs @@ -206,6 +208,7 @@ org.apache.maven.plugins maven-source-plugin + 3.0.1 attach-sources @@ -221,15 +224,16 @@ + org.apache.maven.plugins maven-antrun-plugin - ${maven-antrun-plugin.version} + 1.8 copy package - + @@ -243,6 +247,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 @@ -251,6 +256,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 8 Azure SDK for Java Reference Documentation @@ -298,12 +304,12 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 @@ -326,7 +332,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.0.0 + 3.0.0 aggregate @@ -340,7 +346,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} + 3.1.0 checkstyle/checkstyle.xml checkstyle/checkstyle-suppressions.xml @@ -374,7 +380,7 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.maven.version} + 3.1.12.2 non-aggregate @@ -394,7 +400,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 non-aggregate @@ -414,7 +420,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 + 3.0.0 @@ -459,7 +465,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -484,7 +490,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 11 11 @@ -511,6 +517,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 --no-module-directories @@ -559,6 +566,7 @@ org.codehaus.mojo exec-maven-plugin + 1.2.1 generate-overview-from-readme @@ -584,7 +592,7 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc.version} + 3.1.1 ${project.basedir}/readme_overview.html diff --git a/pom.xml b/pom.xml index ce6f7cd56ad1..a242321a00eb 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.azure azure-sdk-parent - 1.1.0 + 1.6.0 1.6.0 ./parent/pom.xml @@ -69,16 +69,17 @@ org.apache.maven.plugins maven-checkstyle-plugin + 3.1.0 com.azure sdk-build-tools - ${sdk-build-tools.version} + 1.0.0 com.puppycrawl.tools checkstyle - ${checkstyle.version} + 8.24 @@ -109,6 +110,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 ${packageOutputDirectory} @@ -118,6 +120,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 attach-javadocs @@ -135,6 +138,7 @@ org.apache.maven.plugins maven-source-plugin + 3.0.1 attach-sources @@ -150,15 +154,16 @@ + org.apache.maven.plugins maven-antrun-plugin - ${maven-antrun-plugin.version} + 1.8 copy package - + @@ -172,6 +177,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 @@ -196,7 +202,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -221,7 +227,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 11 11 @@ -248,6 +254,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 --no-module-directories diff --git a/sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md index 2e573c6c6f15..1e78d0790f07 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md @@ -1,8 +1,13 @@ # Change Log azure-data-appconfiguration -## Version 1.0.0-preview.7 (2019-11-20) +## Version 1.0.0-preview.7 (2019-11-26) +For details on the Azure SDK for Java (November 2019 Preview) release refer to the [release announcement](https://aka.ms/azure-sdk-preview7-java). + +- Added support for Azure Activity Directory authentication. +- Added service API version support #### Breaking Changes - Removed clearReadOnly API, updated setReadOnly API to support setting and clearing read only based on the flag passed. +- Removed Range class, SettingSelector no longer supports Range. ## Version 1.0.0-preview.6 (2019-10-31) For details on the Azure SDK for Java (October 2019 Preview) release refer to the [release announcement](https://aka.ms/azure-sdk-preview6-java). diff --git a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml index 3dc58205a7f9..56c420d8992d 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml +++ b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml @@ -7,7 +7,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -36,16 +36,17 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 org.slf4j slf4j-api + 1.7.28 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 @@ -58,37 +59,43 @@ org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.hamcrest hamcrest-library + 2.2 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test com.azure azure-identity - 1.0.1 + 1.0.1 test diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java index df4d670d247e..d8d5a5a11096 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java @@ -22,6 +22,7 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.data.appconfiguration.implementation.ConfigurationClientCredentials; import com.azure.data.appconfiguration.implementation.ConfigurationCredentialsPolicy; @@ -77,15 +78,12 @@ public final class ConfigurationClientBuilder { private static final String ACCEPT_HEADER = "Accept"; private static final String ACCEPT_HEADER_VALUE = "application/vnd.microsoft.azconfig.kv+json"; private static final String APP_CONFIG_PROPERTIES = "azure-appconfig.properties"; - private static final String NAME = "name"; - private static final String VERSION = "version"; private static final RetryPolicy DEFAULT_RETRY_POLICY = new RetryPolicy("retry-after-ms", ChronoUnit.MILLIS); private final ClientLogger logger = new ClientLogger(ConfigurationClientBuilder.class); private final List policies; private final HttpHeaders headers; - private final String clientName; - private final String clientVersion; + private final UserAgentProperties properties; private ConfigurationClientCredentials credential; private TokenCredential tokenCredential; @@ -105,9 +103,7 @@ public ConfigurationClientBuilder() { policies = new ArrayList<>(); httpLogOptions = new HttpLogOptions(); - Map properties = CoreUtils.getProperties(APP_CONFIG_PROPERTIES); - clientName = properties.getOrDefault(NAME, "UnknownName"); - clientVersion = properties.getOrDefault(VERSION, "UnknownVersion"); + properties = CoreUtils.getUserAgentPropertiesFromProperties(APP_CONFIG_PROPERTIES); headers = new HttpHeaders() .put(ECHO_REQUEST_ID_HEADER, "true") @@ -175,8 +171,8 @@ public ConfigurationAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, - buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), + properties.getVersion(), buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersPolicy(headers)); policies.add(new AddDatePolicy()); diff --git a/sdk/appconfiguration/tests.yml b/sdk/appconfiguration/tests.yml index f9dc11c4b906..688142d8f8bf 100644 --- a/sdk/appconfiguration/tests.yml +++ b/sdk/appconfiguration/tests.yml @@ -7,4 +7,3 @@ jobs: EnvVars: AZURE_TEST_MODE: RECORD AZURE_APPCONFIG_CONNECTION_STRING: $(java-azconfig-test-connection-string) - AZURE_LOG_LEVEL: 2 diff --git a/sdk/applicationinsights/microsoft-azure-applicationinsights-query/pom.xml b/sdk/applicationinsights/microsoft-azure-applicationinsights-query/pom.xml index 54260df4a445..c66c214f9a05 100644 --- a/sdk/applicationinsights/microsoft-azure-applicationinsights-query/pom.xml +++ b/sdk/applicationinsights/microsoft-azure-applicationinsights-query/pom.xml @@ -17,7 +17,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -48,31 +48,31 @@ com.microsoft.azure azure-client-runtime - ${runtime.version} + 1.6.3 junit junit - 4.12 + 4.13-beta-3 test com.microsoft.azure azure-client-authentication - ${runtime.version} + 1.6.3 test com.microsoft.azure azure-arm-client-runtime - ${runtime.version} + 1.6.3 test-jar test com.microsoft.azure azure-arm-client-runtime - ${runtime.version} + 1.6.3 @@ -80,7 +80,7 @@ org.codehaus.mojo properties-maven-plugin - 1.0.0 + 1.0.0 generate-resources @@ -98,6 +98,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -110,11 +111,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 1.7 1.7 @@ -134,6 +136,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search @@ -150,7 +153,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20 + 3.0.0-M3 false diff --git a/sdk/authorization/microsoft-azure-authentication-msi-token-provider/pom.xml b/sdk/authorization/microsoft-azure-authentication-msi-token-provider/pom.xml index 92b01f3f4c2b..3ac8c074457d 100644 --- a/sdk/authorization/microsoft-azure-authentication-msi-token-provider/pom.xml +++ b/sdk/authorization/microsoft-azure-authentication-msi-token-provider/pom.xml @@ -18,7 +18,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -53,7 +53,7 @@ junit junit test - 4.12 + 4.13-beta-3 @@ -61,7 +61,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.1.0 + 3.1.2 @@ -72,7 +72,9 @@ + org.apache.maven.plugins maven-assembly-plugin + 2.2 package @@ -90,12 +92,12 @@ org.codehaus.mojo build-helper-maven-plugin - 3.0.0 + 3.0.0 org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 8 8 @@ -110,7 +112,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/batch/microsoft-azure-batch/pom.xml b/sdk/batch/microsoft-azure-batch/pom.xml index ff968f143f3e..ade115602bdd 100644 --- a/sdk/batch/microsoft-azure-batch/pom.xml +++ b/sdk/batch/microsoft-azure-batch/pom.xml @@ -9,7 +9,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -37,40 +37,47 @@ com.microsoft.azure azure-client-runtime + 1.6.15 com.microsoft.azure adal4j + 1.6.4 commons-codec commons-codec + 1.13 junit junit + 4.13-beta-3 test com.microsoft.azure azure-storage + 8.0.0 test commons-io commons-io + 2.5 test com.microsoft.azure azure-mgmt-resources + 1.3.1-SNAPSHOT test-jar test @@ -78,6 +85,7 @@ com.microsoft.azure azure-mgmt-resources + 1.3.0 test @@ -88,6 +96,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.7 1.7 @@ -99,6 +108,7 @@ org.apache.maven.plugins maven-resources-plugin + 2.4.3 ${basedir}/target/test-classes/session-records diff --git a/sdk/cognitiveservices/ms-azure-cs-autosuggest/pom.xml b/sdk/cognitiveservices/ms-azure-cs-autosuggest/pom.xml index ac4d66dd61fc..a4c7e3e429f0 100644 --- a/sdk/cognitiveservices/ms-azure-cs-autosuggest/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-autosuggest/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-autosuggest @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml b/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml index 2ac45a4de50a..5c66ee0b8b03 100644 --- a/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-computervision/pom.xml @@ -10,7 +10,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-computervision @@ -50,6 +50,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -57,6 +58,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -69,11 +71,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-contentmoderator/pom.xml b/sdk/cognitiveservices/ms-azure-cs-contentmoderator/pom.xml index 0c70acdb10b0..99f9286c485a 100644 --- a/sdk/cognitiveservices/ms-azure-cs-contentmoderator/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-contentmoderator/pom.xml @@ -10,7 +10,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-contentmoderator @@ -50,6 +50,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -57,6 +58,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -69,11 +71,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-customimagesearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-customimagesearch/pom.xml index 65a1f32bbd74..37a06ce6bb02 100644 --- a/sdk/cognitiveservices/ms-azure-cs-customimagesearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-customimagesearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-customimagesearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-customsearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-customsearch/pom.xml index 59f0bf0a1e42..87027402ac1a 100644 --- a/sdk/cognitiveservices/ms-azure-cs-customsearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-customsearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-customsearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-customvision-prediction/pom.xml b/sdk/cognitiveservices/ms-azure-cs-customvision-prediction/pom.xml index f00417f1b7af..ab5f995dd525 100644 --- a/sdk/cognitiveservices/ms-azure-cs-customvision-prediction/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-customvision-prediction/pom.xml @@ -10,7 +10,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-customvision-prediction @@ -51,6 +51,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -58,6 +59,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -70,11 +72,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-customvision-training/pom.xml b/sdk/cognitiveservices/ms-azure-cs-customvision-training/pom.xml index 411c1a3c21f0..6915632c9e44 100644 --- a/sdk/cognitiveservices/ms-azure-cs-customvision-training/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-customvision-training/pom.xml @@ -10,7 +10,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-customvision-training @@ -50,6 +50,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -57,6 +58,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -69,11 +71,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-entitysearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-entitysearch/pom.xml index 9fd336667819..ee246582c94a 100644 --- a/sdk/cognitiveservices/ms-azure-cs-entitysearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-entitysearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-entitysearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-faceapi/pom.xml b/sdk/cognitiveservices/ms-azure-cs-faceapi/pom.xml index 6f7ac74b2699..dd0d6e269027 100644 --- a/sdk/cognitiveservices/ms-azure-cs-faceapi/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-faceapi/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-faceapi @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-imagesearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-imagesearch/pom.xml index a9c27f330692..4843c4780a91 100644 --- a/sdk/cognitiveservices/ms-azure-cs-imagesearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-imagesearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-imagesearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-luis-authoring/pom.xml b/sdk/cognitiveservices/ms-azure-cs-luis-authoring/pom.xml index 2734598038ca..29345eeef586 100644 --- a/sdk/cognitiveservices/ms-azure-cs-luis-authoring/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-luis-authoring/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-luis-authoring @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-luis-runtime/pom.xml b/sdk/cognitiveservices/ms-azure-cs-luis-runtime/pom.xml index d2c9e869ae83..86d086dadf67 100644 --- a/sdk/cognitiveservices/ms-azure-cs-luis-runtime/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-luis-runtime/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-luis-runtime @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-newssearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-newssearch/pom.xml index f0e898bf3cce..9392f983ce43 100644 --- a/sdk/cognitiveservices/ms-azure-cs-newssearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-newssearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-newssearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-spellcheck/pom.xml b/sdk/cognitiveservices/ms-azure-cs-spellcheck/pom.xml index 68994ad9be9b..9f9ad5d250bc 100644 --- a/sdk/cognitiveservices/ms-azure-cs-spellcheck/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-spellcheck/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml 1.1.0-beta.1 @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-textanalytics/pom.xml b/sdk/cognitiveservices/ms-azure-cs-textanalytics/pom.xml index d994b1416537..a738c5dffa39 100644 --- a/sdk/cognitiveservices/ms-azure-cs-textanalytics/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-textanalytics/pom.xml @@ -10,7 +10,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-textanalytics @@ -50,6 +50,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -57,6 +58,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -69,11 +71,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-videosearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-videosearch/pom.xml index 319c83a076df..7947c2c80a5c 100644 --- a/sdk/cognitiveservices/ms-azure-cs-videosearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-videosearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-videosearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-visualsearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-visualsearch/pom.xml index 6dabcfca44e7..4b6cfec288e0 100644 --- a/sdk/cognitiveservices/ms-azure-cs-visualsearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-visualsearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-visualsearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/cognitiveservices/ms-azure-cs-websearch/pom.xml b/sdk/cognitiveservices/ms-azure-cs-websearch/pom.xml index e17cdc602cca..3585cbb3b56b 100644 --- a/sdk/cognitiveservices/ms-azure-cs-websearch/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-websearch/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml azure-cognitiveservices-websearch @@ -48,6 +48,7 @@ com.microsoft.azure azure-client-runtime + 1.6.15 @@ -55,6 +56,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -67,11 +69,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/core/azure-core-amqp/pom.xml b/sdk/core/azure-core-amqp/pom.xml index da47336afce2..176b0b0a73ab 100644 --- a/sdk/core/azure-core-amqp/pom.xml +++ b/sdk/core/azure-core-amqp/pom.xml @@ -7,7 +7,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -57,46 +57,54 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.microsoft.azure qpid-proton-j-extensions + 1.2.1 org.apache.qpid proton-j + 0.33.2 io.projectreactor reactor-test + 3.3.0.RELEASE test org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.slf4j slf4j-simple + 1.7.25 test org.mockito mockito-core + 3.0.0 test diff --git a/sdk/core/azure-core-http-netty/pom.xml b/sdk/core/azure-core-http-netty/pom.xml index 0e91895db880..a9f6d8c13a95 100644 --- a/sdk/core/azure-core-http-netty/pom.xml +++ b/sdk/core/azure-core-http-netty/pom.xml @@ -8,14 +8,14 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml com.azure azure-core-http-netty jar - 1.1.0-beta.1 + 1.1.0 Microsoft Azure Netty HTTP Client Library This package contains the Netty HTTP client plugin for azure-core. @@ -58,36 +58,58 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 io.netty netty-handler + 4.1.42.Final io.netty netty-handler-proxy + 4.1.42.Final io.netty netty-buffer + 4.1.42.Final io.netty netty-codec-http + 4.1.42.Final + + + + io.netty + netty-codec-http2 + 4.1.42.Final + + + io.netty + netty-transport-native-unix-common + 4.1.42.Final + + + io.netty + netty-transport-native-epoll + 4.1.42.Final + linux-x86_64 io.projectreactor.netty reactor-netty + 0.9.0.RELEASE com.azure azure-core - 1.1.0-beta.1 + 1.1.0 test-jar test @@ -100,23 +122,27 @@ io.projectreactor reactor-test + 3.3.0.RELEASE test org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test com.github.tomakehurst wiremock-standalone + 2.24.1 test diff --git a/sdk/core/azure-core-http-okhttp/pom.xml b/sdk/core/azure-core-http-okhttp/pom.xml index 1cfdfd213ae4..1161f46d0e18 100644 --- a/sdk/core/azure-core-http-okhttp/pom.xml +++ b/sdk/core/azure-core-http-okhttp/pom.xml @@ -8,7 +8,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -59,19 +59,20 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.squareup.okhttp3 okhttp + 4.2.2 com.azure azure-core - 1.1.0-beta.1 + 1.1.0 test-jar test @@ -84,23 +85,27 @@ io.projectreactor reactor-test + 3.3.0.RELEASE test org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test com.github.tomakehurst wiremock-standalone + 2.24.1 test diff --git a/sdk/core/azure-core-management/pom.xml b/sdk/core/azure-core-management/pom.xml index d81a4b96f4ae..d07b1b640436 100644 --- a/sdk/core/azure-core-management/pom.xml +++ b/sdk/core/azure-core-management/pom.xml @@ -7,7 +7,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -57,17 +57,19 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test @@ -80,13 +82,14 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test org.slf4j slf4j-simple + 1.7.25 test diff --git a/sdk/core/azure-core-test/pom.xml b/sdk/core/azure-core-test/pom.xml index c4347a57ff09..7b8789f9786e 100644 --- a/sdk/core/azure-core-test/pom.xml +++ b/sdk/core/azure-core-test/pom.xml @@ -6,7 +6,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -38,43 +38,51 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 io.projectreactor reactor-test + 3.3.0.RELEASE org.junit.jupiter junit-jupiter-api + 5.4.2 compile org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.slf4j slf4j-api + 1.7.28 org.slf4j slf4j-simple + 1.7.25 com.github.tomakehurst wiremock-standalone + 2.24.1 org.eclipse.jetty jetty-http + 9.4.11.v20180605 org.eclipse.jetty jetty-server + 9.4.11.v20180605 @@ -85,6 +93,7 @@ org.eclipse.jetty jetty-maven-plugin + 9.3.22.v20171030 11081 @@ -101,6 +110,7 @@ org.codehaus.mojo exec-maven-plugin + 1.2.1 java @@ -114,8 +124,9 @@ + org.apache.maven.plugins maven-jar-plugin - ${maven-jar-plugin.version} + 3.1.2 test-jar diff --git a/sdk/core/azure-core-tracing-opencensus/pom.xml b/sdk/core/azure-core-tracing-opencensus/pom.xml index f8a83de308f3..ed3bb8a2a8e3 100644 --- a/sdk/core/azure-core-tracing-opencensus/pom.xml +++ b/sdk/core/azure-core-tracing-opencensus/pom.xml @@ -6,7 +6,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -35,28 +35,31 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 io.opencensus opencensus-api + 0.24.0 io.opencensus opencensus-impl - 0.24.0 + 0.24.0 test org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test diff --git a/sdk/core/azure-core-tracing-opentelemetry/pom.xml b/sdk/core/azure-core-tracing-opentelemetry/pom.xml index 1de635254b8e..8f668db15ec1 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/pom.xml +++ b/sdk/core/azure-core-tracing-opentelemetry/pom.xml @@ -6,7 +6,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -35,29 +35,31 @@ io.opentelemetry opentelemetry-api - 0.2.0 + 0.2.0 com.azure azure-core - 1.1.0-beta.1 + 1.1.0 io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.0 test org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test diff --git a/sdk/core/azure-core/pom.xml b/sdk/core/azure-core/pom.xml index e03f7a5dff5c..28ff43d3d3a2 100644 --- a/sdk/core/azure-core/pom.xml +++ b/sdk/core/azure-core/pom.xml @@ -7,14 +7,14 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml com.azure azure-core jar - 1.1.0-beta.1 + 1.1.0 Microsoft Azure Java Core Library This package contains core types for Azure Java clients. @@ -57,14 +57,17 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 + 2.10.0 com.fasterxml.jackson.dataformat jackson-dataformat-xml + 2.10.0 org.slf4j slf4j-api + 1.7.28 provided io.projectreactor reactor-core + 3.3.0.RELEASE io.projectreactor reactor-test + 3.3.0.RELEASE test io.netty netty-tcnative-boringssl-static + 2.0.26.Final org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.hamcrest hamcrest-library + 2.2 test org.slf4j slf4j-simple + 1.7.25 test org.mockito mockito-core + 3.0.0 test com.github.tomakehurst wiremock-standalone + 2.24.1 test org.eclipse.jetty jetty-http + 9.4.11.v20180605 test org.eclipse.jetty jetty-server + 9.4.11.v20180605 test org.openjdk.jmh jmh-core - RELEASE + 1.22 test org.openjdk.jmh jmh-generator-annprocess - RELEASE + 1.22 test @@ -155,6 +170,7 @@ org.eclipse.jetty jetty-maven-plugin + 9.3.22.v20171030 11081 @@ -171,6 +187,7 @@ org.codehaus.mojo exec-maven-plugin + 1.2.1 java @@ -184,8 +201,9 @@ + org.apache.maven.plugins maven-jar-plugin - ${maven-jar-plugin.version} + 3.1.2 test-jar diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java index 548810b0f0b2..f643b4975664 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java @@ -42,6 +42,9 @@ public BearerTokenAuthenticationPolicy(TokenCredential credential, String... sco @Override public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { + if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) { + return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme")); + } return cache.getToken() .flatMap(token -> { context.getHttpRequest().getHeaders().put(AUTHORIZATION_HEADER, BEARER + " " + token.getToken()); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/UserAgentPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/UserAgentPolicy.java index eb76dce89bc9..a3ed93973896 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/UserAgentPolicy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/UserAgentPolicy.java @@ -91,8 +91,6 @@ public UserAgentPolicy(String applicationId, String sdkName, String sdkVersion, *

If the passed configuration contains true for AZURE_TELEMETRY_DISABLED the platform information won't be * included in the user agent.

* - * @deprecated This method has been deprecated in favor of {@link - * #UserAgentPolicy(String, String, String, Configuration)}. * @param sdkName Name of the client library. * @param sdkVersion Version of the client library. * @param version {@link ServiceVersion} of the service to be used when making requests. @@ -100,7 +98,6 @@ public UserAgentPolicy(String applicationId, String sdkName, String sdkVersion, * Configuration#PROPERTY_AZURE_TELEMETRY_DISABLED}. If {@code null} is passed the {@link * Configuration#getGlobalConfiguration() global configuration} will be checked. */ - @Deprecated public UserAgentPolicy(String sdkName, String sdkVersion, Configuration configuration, ServiceVersion version) { this.userAgent = buildUserAgent(null, sdkName, sdkVersion, configuration); } diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedFluxBase.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedFluxBase.java index 84d30c776feb..2e49329b52b6 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedFluxBase.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedFluxBase.java @@ -149,7 +149,7 @@ private Publisher extractAndFetchT(PagedResponse page) { if (nextPageLink == null) { return Flux.fromIterable(page.getItems()); } - return Flux.fromIterable(page.getItems()).concatWith(byT(nextPageLink)); + return Flux.fromIterable(page.getItems()).concatWith(Flux.defer(() -> byT(nextPageLink))); } /** @@ -163,6 +163,6 @@ private Publisher extractAndFetchPage(P page) { if (nextPageLink == null) { return Flux.just(page); } - return Flux.just(page).concatWith(byPage(page.getContinuationToken())); + return Flux.just(page).concatWith(Flux.defer(() -> byPage(page.getContinuationToken()))); } } diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedIterableBase.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedIterableBase.java index c9eaaeba30f5..cd974741386d 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedIterableBase.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/PagedIterableBase.java @@ -28,6 +28,12 @@ * @see IterableStream */ public class PagedIterableBase> extends IterableStream { + /* + * This is the default batch size that will be requested when using stream or iterable by page, this will indicate + * to Reactor how many elements should be prefetched before another batch is requested. + */ + private static final int DEFAULT_BATCH_SIZE = 1; + private final PagedFluxBase pagedFluxBase; /** @@ -46,7 +52,7 @@ public PagedIterableBase(PagedFluxBase pagedFluxBase) { * @return {@link Stream} of a Response that extends {@link PagedResponse} */ public Stream

streamByPage() { - return pagedFluxBase.byPage().toStream(); + return pagedFluxBase.byPage().toStream(DEFAULT_BATCH_SIZE); } /** @@ -58,7 +64,7 @@ public Stream

streamByPage() { * with the continuation token */ public Stream

streamByPage(String continuationToken) { - return pagedFluxBase.byPage(continuationToken).toStream(); + return pagedFluxBase.byPage(continuationToken).toStream(DEFAULT_BATCH_SIZE); } /** @@ -68,7 +74,7 @@ public Stream

streamByPage(String continuationToken) { * @return {@link Iterable} interface */ public Iterable

iterableByPage() { - return pagedFluxBase.byPage().toIterable(); + return pagedFluxBase.byPage().toIterable(DEFAULT_BATCH_SIZE); } /** @@ -80,6 +86,6 @@ public Iterable

iterableByPage() { * @return {@link Iterable} interface */ public Iterable

iterableByPage(String continuationToken) { - return pagedFluxBase.byPage(continuationToken).toIterable(); + return pagedFluxBase.byPage(continuationToken).toIterable(DEFAULT_BATCH_SIZE); } } diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java index b9b34cdd8be9..d196e3147fb6 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java @@ -24,6 +24,8 @@ */ public final class CoreUtils { private static final String COMMA = ","; + private static final String NAME = "name"; + private static final String VERSION = "version"; private CoreUtils() { // Exists only to defeat instantiation. @@ -162,12 +164,19 @@ public static Publisher extractAndFetch(PagedResponse page, Context co /** - * Helper method that returns an immutable {@link Map} of properties defined in {@code propertiesFileName}. + * Helper method that returns {@link UserAgentProperties} from properties defined in {@code propertiesFileName}. * * @param propertiesFileName The file name defining the properties. - * @return an immutable {@link Map}. + * @return {@link UserAgentProperties}. */ - public static Map getProperties(String propertiesFileName) { + public static UserAgentProperties getUserAgentPropertiesFromProperties(String propertiesFileName) { + Map propertyMap = getProperties(propertiesFileName); + String name = propertyMap.getOrDefault(NAME, "UnknownName"); + String version = propertyMap.getOrDefault(VERSION, "UnknownVersion"); + return new UserAgentProperties(name, version); + } + + private static Map getProperties(String propertiesFileName) { ClientLogger logger = new ClientLogger(CoreUtils.class); try (InputStream inputStream = CoreUtils.class.getClassLoader() .getResourceAsStream(propertiesFileName)) { diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/IterableStream.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/IterableStream.java index 5d431f16209d..c213418c4093 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/IterableStream.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/IterableStream.java @@ -32,6 +32,12 @@ * @see Iterable */ public class IterableStream implements Iterable { + /* + * This is the default batch size that will be requested when using stream or iterable by page, this will indicate + * to Reactor how many elements should be prefetched before another batch is requested. + */ + private static final int DEFAULT_BATCH_SIZE = 1; + private final ClientLogger logger = new ClientLogger(IterableStream.class); private final Flux flux; private final Iterable iterable; @@ -66,7 +72,7 @@ public IterableStream(Iterable iterable) { */ public Stream stream() { if (flux != null) { - return flux.toStream(); + return flux.toStream(DEFAULT_BATCH_SIZE); } else if (iterable != null) { return StreamSupport.stream(iterable.spliterator(), false); } else { @@ -84,7 +90,7 @@ public Stream stream() { @Override public Iterator iterator() { if (flux != null) { - return flux.toIterable().iterator(); + return flux.toIterable(DEFAULT_BATCH_SIZE).iterator(); } else if (iterable != null) { return iterable.iterator(); } else { diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/credential/CredentialsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/credential/CredentialsTests.java index 82b4c17b4dca..2a04aa65160f 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/credential/CredentialsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/credential/CredentialsTests.java @@ -13,6 +13,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; import java.net.URL; import java.time.OffsetDateTime; @@ -53,11 +54,32 @@ public void tokenCredentialTest() throws Exception { }; final HttpPipeline pipeline = new HttpPipelineBuilder() - .httpClient(new NoOpHttpClient()) - .policies(new BearerTokenAuthenticationPolicy(credentials, "scope./default"), auditorPolicy) - .build(); + .httpClient(new NoOpHttpClient()) + .policies(new BearerTokenAuthenticationPolicy(credentials, "scope./default"), auditorPolicy) + .build(); - HttpRequest request = new HttpRequest(HttpMethod.GET, new URL("http://localhost")); + HttpRequest request = new HttpRequest(HttpMethod.GET, new URL("https://localhost")); pipeline.send(request).block(); } + + @Test + public void tokenCredentialHttpSchemeTest() throws Exception { + TokenCredential credentials = request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)); + + HttpPipelinePolicy auditorPolicy = (context, next) -> { + String headerValue = context.getHttpRequest().getHeaders().getValue("Authorization"); + Assertions.assertEquals("Bearer this_is_a_token", headerValue); + return next.process(); + }; + + final HttpPipeline pipeline = new HttpPipelineBuilder() + .httpClient(new NoOpHttpClient()) + .policies(new BearerTokenAuthenticationPolicy(credentials, "scope./default"), auditorPolicy) + .build(); + + HttpRequest request = new HttpRequest(HttpMethod.GET, new URL("http://localhost")); + StepVerifier.create(pipeline.send(request)) + .expectErrorMessage("token credentials require a URL using the HTTPS protocol scheme") + .verify(); + } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedIterableTest.java b/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedIterableTest.java index d2fe97586cc6..136abaad61a8 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedIterableTest.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedIterableTest.java @@ -3,162 +3,224 @@ package com.azure.core.http.rest; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpMethod; import com.azure.core.http.HttpRequest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; +import java.util.ArrayList; import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Unit tests for {@link PagedIterable}. */ public class PagedIterableTest { - private List> pagedResponses; private List> pagedStringResponses; - @Test - public void testEmptyResults() { - PagedFlux pagedFlux = getIntegerPagedFlux(0); + private HttpHeaders httpHeaders = new HttpHeaders().put("header1", "value1").put("header2", "value2"); + private HttpRequest httpRequest = new HttpRequest(HttpMethod.GET, "http://localhost"); + private String deserializedHeaders = "header1,value1,header2,value2"; + + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void streamByPage(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - assertEquals(0, pagedIterable.streamByPage().count()); + List> pages = pagedIterable.streamByPage().collect(Collectors.toList()); + + assertEquals(numberOfPages, pages.size()); + assertEquals(pagedResponses, pages); } - @Test - public void testPageStream() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void iterateByPage(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - assertEquals(5, pagedIterable.streamByPage().count()); - assertEquals(pagedResponses, pagedIterable.streamByPage().collect(Collectors.toList())); + List> pages = new ArrayList<>(); + pagedIterable.iterableByPage().iterator().forEachRemaining(pages::add); + + assertEquals(numberOfPages, pages.size()); + assertEquals(pagedResponses, pages); } - @Test - public void testPageIterable() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void streamByT(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - Iterator> iter = pagedIterable.iterableByPage().iterator(); + List values = pagedIterable.stream().collect(Collectors.toList()); - int index = 0; - while (iter.hasNext()) { - PagedResponse pagedResponse = iter.next(); - assertEquals(pagedResponses.get(index++), pagedResponse); - } + assertEquals(numberOfPages * 3, values.size()); + assertEquals(Stream.iterate(0, i -> i + 1).limit(numberOfPages * 3).collect(Collectors.toList()), values); } - @Test - public void testStream() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void iterateByT(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); + List values = new ArrayList<>(); + pagedIterable.iterator().forEachRemaining(values::add); - assertEquals(15, pagedIterable.stream().count()); - List ints = Stream.iterate(0, i -> i + 1).limit(15).collect(Collectors.toList()); - assertEquals(ints, pagedIterable.stream().collect(Collectors.toList())); + assertEquals(numberOfPages * 3, values.size()); + assertEquals(Stream.iterate(0, i -> i + 1).limit(numberOfPages * 3).collect(Collectors.toList()), values); } - @Test - public void testIterable() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void streamByPageMap(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - Iterator iter = pagedIterable.iterator(); + List> pages = pagedIterable.mapPage(String::valueOf).streamByPage() + .collect(Collectors.toList()); - int index = 0; - while (iter.hasNext()) { - int val = iter.next(); - assertEquals(index++, val); + assertEquals(numberOfPages, pages.size()); + for (int i = 0; i < numberOfPages; i++) { + assertEquals(pagedStringResponses.get(i).getValue(), pages.get(i).getValue()); } } + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void iterateByPageMap(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); + PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); + List> pages = new ArrayList<>(); + pagedIterable.mapPage(String::valueOf).iterableByPage().iterator().forEachRemaining(pages::add); + + assertEquals(numberOfPages, pages.size()); + for (int i = 0; i < numberOfPages; i++) { + assertEquals(pagedStringResponses.get(i).getValue(), pages.get(i).getValue()); + } + } + + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void streamByTMap(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); + PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); + List values = pagedIterable.mapPage(String::valueOf).stream().collect(Collectors.toList()); + + assertEquals(numberOfPages * 3, values.size()); + assertEquals(Stream.iterate(0, i -> i + 1).limit(numberOfPages * 3).map(String::valueOf) + .collect(Collectors.toList()), values); + } + + @ParameterizedTest + @ValueSource(ints = {0, 5}) + public void iterateByTMap(int numberOfPages) { + PagedFlux pagedFlux = getIntegerPagedFlux(numberOfPages); + PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); + List values = new ArrayList<>(); + pagedIterable.mapPage(String::valueOf).iterator().forEachRemaining(values::add); + + assertEquals(numberOfPages * 3, values.size()); + assertEquals(Stream.iterate(0, i -> i + 1).limit(numberOfPages * 3).map(String::valueOf) + .collect(Collectors.toList()), values); + } + @Test - public void testMap() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + public void streamFirstPage() { + TestPagedFlux pagedFlux = getTestPagedFlux(5); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - List intStrs = - Stream.iterate(0, i -> i + 1).map(String::valueOf).limit(15).collect(Collectors.toList()); - assertEquals(intStrs, pagedIterable.mapPage(String::valueOf).stream().collect(Collectors.toList())); + + assertEquals(pagedResponses.get(0), pagedIterable.streamByPage().limit(1).collect(Collectors.toList()).get(0)); + + /* + * The goal for this test would be that 0 next page retrieval calls are made but due to how Flux.concatWith + * works it needs to begin the next publisher to determine whether onNext or onComplete should trigger. This + * results in 2 next page retrieval calls for the following reason: + * + * - Makes the initial get first page call, then needs to validate that get next page emits. 1 call made. + * - Retrieving the first page in verification moves the stream iterator to the initial next page, Reactor then + * needs to verify that the page after it emits. 2 calls made. + */ + assertEquals(2, pagedFlux.getNextPageRetrievals()); } @Test - public void testPageMap() { - PagedFlux pagedFlux = getIntegerPagedFlux(5); + public void iterateFirstPage() { + TestPagedFlux pagedFlux = getTestPagedFlux(5); PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - int[] index = new int[1]; - assertTrue(pagedIterable.mapPage(String::valueOf).streamByPage().allMatch(pagedResponse -> - pagedStringResponses.get(index[0]++).getValue().equals(pagedResponse.getValue()))); + + assertEquals(pagedResponses.get(0), pagedIterable.iterableByPage().iterator().next()); + + /* + * The goal for this test would be that 0 next page retrieval calls are made but due to how Flux.concatWith + * works it needs to begin the next publisher to determine whether onNext or onComplete should trigger. This + * results in 2 next page retrieval calls for the following reason: + * + * - Makes the initial get first page call, then needs to validate that get next page emits. 1 call made. + * - Retrieving the first page in verification moves the stream iterator to the initial next page, Reactor then + * needs to verify that the page after it emits. 2 calls made. + */ + assertEquals(2, pagedFlux.getNextPageRetrievals()); } - private PagedFlux getIntegerPagedFlux(int noOfPages) { - try { - HttpHeaders httpHeaders = new HttpHeaders().put("header1", "value1") - .put("header2", "value2"); + @Test + public void streamFirstValue() { + TestPagedFlux pagedFlux = getTestPagedFlux(5); + PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - HttpRequest httpRequest = new HttpRequest(HttpMethod.GET, new URL("http://localhost")); + Integer firstValue = pagedResponses.get(0).getValue().get(0); + assertEquals(firstValue, pagedIterable.stream().limit(1).collect(Collectors.toList()).get(0)); + } - String deserializedHeaders = "header1,value1,header2,value2"; - pagedResponses = IntStream.range(0, noOfPages) - .boxed() - .map(i -> createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, i, noOfPages)) - .collect(Collectors.toList()); + @Test + public void iterateFirstValue() { + TestPagedFlux pagedFlux = getTestPagedFlux(5); + PagedIterable pagedIterable = new PagedIterable<>(pagedFlux); - pagedStringResponses = IntStream.range(0, noOfPages) - .boxed() - .map(i -> createPagedResponseWithString(httpRequest, httpHeaders, deserializedHeaders, i, noOfPages)) - .collect(Collectors.toList()); + Integer firstValue = pagedResponses.get(0).getValue().get(0); + assertEquals(firstValue, pagedIterable.iterator().next()); + assertEquals(0, pagedFlux.getNextPageRetrievals()); + } - return new PagedFlux<>(() -> pagedResponses.isEmpty() ? Mono.empty() : Mono.just(pagedResponses.get(0)), - continuationToken -> getNextPage(continuationToken, pagedResponses)); - } catch (MalformedURLException e) { - return null; - } + private PagedFlux getIntegerPagedFlux(int numberOfPages) { + createPagedResponse(numberOfPages); + + return new PagedFlux<>(() -> pagedResponses.isEmpty() ? Mono.empty() : Mono.just(pagedResponses.get(0)), + continuationToken -> getNextPage(continuationToken, pagedResponses)); } - private PagedFlux getIntegerPagedFluxSinglePage() { - try { - HttpHeaders httpHeaders = new HttpHeaders().put("header1", "value1") - .put("header2", "value2"); - HttpRequest httpRequest = new HttpRequest(HttpMethod.GET, new URL("http://localhost")); - - String deserializedHeaders = "header1,value1,header2,value2"; - pagedResponses = IntStream.range(0, 1) - .boxed() - .map(i -> createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, i, 1)) - .collect(Collectors.toList()); - - pagedStringResponses = IntStream.range(0, 1) - .boxed() - .map(i -> createPagedResponseWithString(httpRequest, httpHeaders, deserializedHeaders, i, 1)) - .collect(Collectors.toList()); - return new PagedFlux<>(() -> pagedResponses.isEmpty() ? Mono.empty() : Mono.just(pagedResponses.get(0))); - } catch (MalformedURLException e) { - return null; - } + private TestPagedFlux getTestPagedFlux(int numberOfPages) { + createPagedResponse(numberOfPages); + + return new TestPagedFlux<>(() -> pagedResponses.isEmpty() ? Mono.empty() : Mono.just(pagedResponses.get(0)), + continuationToken -> getNextPage(continuationToken, pagedResponses)); } - private PagedResponseBase createPagedResponse(HttpRequest httpRequest, - HttpHeaders httpHeaders, String deserializedHeaders, int i, int noOfPages) { - return new PagedResponseBase<>(httpRequest, 200, - httpHeaders, - getItems(i), - i < noOfPages - 1 ? String.valueOf(i + 1) : null, - deserializedHeaders); + private void createPagedResponse(int numberOfPages) { + pagedResponses = IntStream.range(0, numberOfPages) + .boxed() + .map(i -> + createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, numberOfPages, this::getItems, i)) + .collect(Collectors.toList()); + + pagedStringResponses = IntStream.range(0, numberOfPages) + .boxed() + .map(i -> createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, numberOfPages, + this::getStringItems, i)) + .collect(Collectors.toList()); } - private PagedResponseBase createPagedResponseWithString(HttpRequest httpRequest, - HttpHeaders httpHeaders, String deserializedHeaders, int i, int noOfPages) { - return new PagedResponseBase<>(httpRequest, 200, - httpHeaders, - getStringItems(i), - i < noOfPages - 1 ? String.valueOf(i + 1) : null, + private PagedResponseBase createPagedResponse(HttpRequest httpRequest, HttpHeaders headers, + String deserializedHeaders, int numberOfPages, Function> valueSupplier, int i) { + return new PagedResponseBase<>(httpRequest, 200, headers, valueSupplier.apply(i), + (i < numberOfPages - 1) ? String.valueOf(i + 1) : null, deserializedHeaders); } @@ -169,15 +231,39 @@ private Mono> getNextPage(String continuationToken, return Mono.empty(); } - return Mono.just(pagedResponses.get(Integer.valueOf(continuationToken))); + return Mono.just(pagedResponses.get(Integer.parseInt(continuationToken))); } - private List getItems(Integer i) { + private List getItems(int i) { return IntStream.range(i * 3, i * 3 + 3).boxed().collect(Collectors.toList()); } - private List getStringItems(Integer i) { - return IntStream.range(i * 3, i * 3 + 3).boxed().map(val -> String.valueOf(val)).collect(Collectors.toList()); + private List getStringItems(int i) { + return IntStream.range(i * 3, i * 3 + 3).boxed().map(String::valueOf).collect(Collectors.toList()); } + /* + * Test class used to verify that paged iterable will lazily request next pages. + */ + private static class TestPagedFlux extends PagedFlux { + private int nextPageRetrievals = 0; + + TestPagedFlux(Supplier>> firstPageRetriever, + Function>> nextPageRetriever) { + super(firstPageRetriever, nextPageRetriever); + } + + @Override + public Flux> byPage(String continuationToken) { + nextPageRetrievals++; + return super.byPage(continuationToken); + } + + /* + * Returns the number of times another page has been retrieved. + */ + int getNextPageRetrievals() { + return nextPageRetrievals; + } + } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java index ca1052fae5fa..d4226e690ea8 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java @@ -40,16 +40,17 @@ public void findFirstOfTypeWithNoneOfType() { @Test public void testProperties() { - assertNotNull(CoreUtils.getProperties("azure-core.properties").get("version")); - assertNotNull(CoreUtils.getProperties("azure-core.properties").get("name")); - assertTrue(CoreUtils.getProperties("azure-core.properties").get("version") + assertNotNull(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getVersion()); + assertNotNull(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getName()); + assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getVersion() .matches("\\d.\\d.\\d([-a-zA-Z0-9.])*")); } @Test public void testMissingProperties() { - assertNotNull(CoreUtils.getProperties("foo.properties")); - assertTrue(CoreUtils.getProperties("foo.properties").isEmpty()); - assertNull(CoreUtils.getProperties("azure-core.properties").get("foo")); + assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("foo.properties") + .getVersion().matches("UnknownVersion")); + assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("foo.properties") + .getName().matches("UnknownName")); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml b/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml index 4c10b94c262b..55baf4743098 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml +++ b/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml @@ -8,7 +8,7 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos-parent - 3.4.0 + 3.5.0 com.microsoft.azure @@ -33,54 +33,56 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos - 3.4.0 + 3.5.0 com.beust jcommander + 1.58 com.google.guava guava - ${guava.version} + 27.0.1-jre io.dropwizard.metrics metrics-core - ${metrics.version} + 4.1.0 io.dropwizard.metrics metrics-jvm - ${metrics.version} + 4.1.0 io.dropwizard.metrics metrics-graphite - ${metrics.version} + 4.1.0 io.micrometer micrometer-registry-azure-monitor - ${micrometer.version} + 1.2.0 io.micrometer micrometer-registry-graphite - ${micrometer.version} + 1.2.0 @@ -88,32 +90,38 @@ Licensed under the MIT License. log4j log4j + 1.2.17 org.apache.commons commons-lang3 + 3.8.1 org.slf4j slf4j-api + 1.7.28 org.slf4j slf4j-log4j12 + 1.7.0 org.assertj assertj-core + 3.11.1 test org.testng testng + 6.14.3 test @@ -123,6 +131,7 @@ Licensed under the MIT License. org.codehaus.mojo exec-maven-plugin + 1.2.1 com.azure.data.cosmos.benchmark.Main @@ -131,6 +140,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-assembly-plugin + 2.2 jar-with-dependencies @@ -155,6 +165,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.8 1.8 @@ -164,6 +175,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-eclipse-plugin + 2.8 @@ -176,6 +188,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-antrun-plugin + 1.8 false diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml b/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml index 4a55aa812f07..55116eb84c94 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml +++ b/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml @@ -8,7 +8,7 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos-parent - 3.4.0 + 3.5.0 com.microsoft.azure @@ -34,6 +34,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.8 1.8 @@ -43,6 +44,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-eclipse-plugin + 2.8 @@ -55,13 +57,16 @@ Licensed under the MIT License. org.codehaus.mojo exec-maven-plugin + 1.2.1 com.azure.data.cosmos.benchmark.Main + org.apache.maven.plugins maven-assembly-plugin + 2.2 jar-with-dependencies @@ -89,44 +94,51 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos - 3.4.0 + 3.5.0 com.google.guava guava + 27.0.1-jre log4j log4j + 1.2.17 org.slf4j slf4j-api + 1.7.28 org.slf4j slf4j-log4j12 + 1.7.0 org.hamcrest hamcrest-all + 1.3 test org.mockito mockito-core + 1.10.19 test org.testng testng + 6.14.3 test diff --git a/sdk/cosmos/microsoft-azure-cosmos/pom.xml b/sdk/cosmos/microsoft-azure-cosmos/pom.xml index 2660c5b31a7a..76374aa0b7cd 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/pom.xml +++ b/sdk/cosmos/microsoft-azure-cosmos/pom.xml @@ -7,12 +7,12 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos-parent - 3.4.0 + 3.5.0 com.microsoft.azure azure-cosmos - 3.4.0 + 3.5.0 Microsoft Azure SDK for SQL API of Azure Cosmos DB Service This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension rx support) for Azure Cosmos DB SQL API jar @@ -33,119 +33,138 @@ Licensed under the MIT License. com.fasterxml.jackson.core jackson-databind + 2.10.0 com.fasterxml.uuid java-uuid-generator + 3.2.0 commons-io commons-io + 2.5 commons-validator commons-validator + 1.6 io.projectreactor reactor-core + 3.3.0.RELEASE io.netty netty-codec-http + 4.1.42.Final io.netty netty-handler + 4.1.42.Final org.slf4j slf4j-api + 1.7.28 org.apache.commons commons-lang3 + 3.8.1 org.apache.commons commons-collections4 + 4.2 org.apache.commons commons-text + 1.6 org.testng testng + 6.14.3 test org.assertj assertj-core + 3.11.1 test org.slf4j slf4j-log4j12 + 1.7.0 test log4j log4j + 1.2.17 test com.google.guava guava + 27.0.1-jre io.dropwizard.metrics metrics-core - ${metrics.version} + 4.1.0 io.micrometer micrometer-core - ${micrometer.version} + 1.2.0 io.projectreactor reactor-test + 3.3.0.RELEASE test io.reactivex.rxjava2 rxjava + 2.2.4 io.projectreactor.netty reactor-netty - ${reactor-netty.version} + 0.9.0.RELEASE org.mockito mockito-core + 1.10.19 test @@ -156,6 +175,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.8 1.8 @@ -165,6 +185,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-eclipse-plugin + 2.8 @@ -177,6 +198,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-checkstyle-plugin + 3.1.0 false false @@ -194,6 +216,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 src/test/resources/fast-testng.xml @@ -211,6 +234,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 src/test/resources/long-testng.xml @@ -228,6 +252,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 src/test/resources/emulator-testng.xml diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java index 5f5d62eba5eb..767ced3bd2a5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java +++ b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java @@ -257,7 +257,7 @@ public static class Versions { // @see // https://stackoverflow.com/questions/2469922/generate-a-version-java-file-in-maven // {x-version-update-start;com.microsoft.azure:azure-cosmos;current} - public static final String SDK_VERSION = "3.4.0"; + public static final String SDK_VERSION = "3.5.0"; // {x-version-update-end} public static final String SDK_NAME = "cosmosdb-java-sdk"; } diff --git a/sdk/cosmos/pom.xml b/sdk/cosmos/pom.xml index fb70af8fa2e9..e6fe8f8ca8b4 100644 --- a/sdk/cosmos/pom.xml +++ b/sdk/cosmos/pom.xml @@ -7,13 +7,13 @@ Licensed under the MIT License. com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../pom.data.xml com.microsoft.azure azure-cosmos-parent - 3.4.0 + 3.5.0 pom Microsoft Azure Cosmos DB SQL API @@ -36,68 +36,12 @@ Licensed under the MIT License. UTF-8 ${project.version} ${project.version} - 4.1.0 - 1.2.0 - 1.10.19 - 4.1.42.Final - 2.0.26.Final ${project.version} - 27.0.1-jre - 3.3.0.RELEASE - 0.9.0.RELEASE unit ${project.basedir}/target/collectedArtifactsForRelease - - - - com.microsoft.azure - azure-cosmos - 3.4.0 - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - io.projectreactor - reactor-core - ${reactor-core.version} - - - - io.netty - netty-codec-http - ${netty.version} - - - - com.google.guava - guava - ${guava.version} - - - - io.netty - netty-tcnative - ${netty-tcnative.version} - linux-x86_64 - - - - io.netty - netty-handler - ${netty.version} - - - - @@ -114,6 +58,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-surefire-plugin + 3.0.0-M3 @@ -131,6 +76,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -146,6 +92,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -161,6 +108,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -176,6 +124,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -192,6 +141,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -217,6 +167,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -232,6 +183,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -247,6 +199,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 @@ -258,6 +211,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-surefire-plugin + 3.0.0-M3 unit @@ -274,6 +228,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 %regex[.*] @@ -299,7 +254,9 @@ Licensed under the MIT License. + org.apache.maven.plugins maven-javadoc-plugin + 3.1.1 true true @@ -322,6 +279,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-source-plugin + 3.0.1 attach-sources @@ -334,6 +292,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-compiler-plugin + 3.8.1 1.8 1.8 @@ -343,7 +302,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-eclipse-plugin - 2.8 + 2.8 @@ -355,7 +314,7 @@ Licensed under the MIT License. org.apache.maven.plugins maven-antrun-plugin - 1.8 + 1.8 diff --git a/sdk/eventgrid/microsoft-azure-eventgrid/pom.xml b/sdk/eventgrid/microsoft-azure-eventgrid/pom.xml index a756ef8ccb26..b0c2367ae6c9 100644 --- a/sdk/eventgrid/microsoft-azure-eventgrid/pom.xml +++ b/sdk/eventgrid/microsoft-azure-eventgrid/pom.xml @@ -17,7 +17,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml https://github.com/Azure/azure-sdk-for-java @@ -47,24 +47,24 @@ com.microsoft.azure azure-client-runtime - 1.5.0 + 1.5.0 junit junit - 4.12 + 4.13-beta-3 test com.microsoft.azure azure-client-authentication - 1.5.0 + 1.5.0 test commons-io commons-io - 2.6 + 2.6 @@ -72,6 +72,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -84,11 +85,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 1.7 1.7 @@ -108,7 +110,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 2.8 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search diff --git a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/pom.xml b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/pom.xml index 5966d49697fa..9a3a01406a1e 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/pom.xml +++ b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/pom.xml @@ -10,7 +10,7 @@ azure-client-sdk-parent com.azure - 1.6.0 + 1.7.0 ../../../pom.client.xml 4.0.0 @@ -51,26 +51,31 @@ org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test org.mockito mockito-core + 3.0.0 test diff --git a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java index 5939e88a193e..23e074732d25 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java +++ b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java @@ -17,6 +17,7 @@ import com.azure.storage.blob.models.BlobListDetails; import com.azure.storage.blob.models.BlobItemProperties; import com.azure.storage.blob.models.ListBlobsOptions; +import java.util.List; import java.util.Objects; import java.util.function.Function; import reactor.core.Exceptions; @@ -127,13 +128,13 @@ private Mono convertToCheckpoint(BlobItem blobItem) { * This method is called by the {@link EventProcessorClient} to claim ownership of a list of partitions. This will * return the list of partitions that were owned successfully. * - * @param requestedPartitionOwnerships Array of partition ownerships this instance is requesting to own. + * @param requestedPartitionOwnerships List of partition ownerships this instance is requesting to own. * @return A flux of partitions this instance successfully claimed ownership. */ @Override - public Flux claimOwnership(PartitionOwnership... requestedPartitionOwnerships) { + public Flux claimOwnership(List requestedPartitionOwnerships) { - return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> { + return Flux.fromIterable(requestedPartitionOwnerships).flatMap(partitionOwnership -> { String partitionId = partitionOwnership.getPartitionId(); String blobName = getBlobName(partitionOwnership.getFullyQualifiedNamespace(), partitionOwnership.getEventHubName(), partitionOwnership.getConsumerGroup(), partitionId, @@ -204,7 +205,14 @@ public Mono updateCheckpoint(Checkpoint checkpoint) { metadata.put(OFFSET, offset); BlobAsyncClient blobAsyncClient = blobClients.get(blobName); - return blobAsyncClient.setMetadata(metadata); + return blobAsyncClient.exists().flatMap(exists -> { + if (exists) { + return blobAsyncClient.setMetadata(metadata); + } else { + return blobAsyncClient.getBlockBlobAsyncClient().uploadWithResponse(Flux.just(UPLOAD_DATA), 0, null, + metadata, null, null, null).then(); + } + }); } private String getBlobPrefix(String fullyQualifiedNamespace, String eventHubName, String consumerGroupName, diff --git a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java index 062cdf4357be..4a57a840f1dd 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java +++ b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java @@ -9,6 +9,8 @@ import com.azure.messaging.eventhubs.models.PartitionOwnership; import com.azure.storage.blob.BlobContainerAsyncClient; import com.azure.storage.blob.BlobContainerClientBuilder; +import java.util.ArrayList; +import java.util.List; import java.util.StringJoiner; /** @@ -47,14 +49,14 @@ public static void main(String[] args) throws Exception { .subscribe(etag -> System.out.println(etag), error -> System.out .println(error.getMessage())); - PartitionOwnership[] pos = new PartitionOwnership[5]; + List pos = new ArrayList<>(); for (int i = 0; i < 5; i++) { PartitionOwnership po = new PartitionOwnership() .setEventHubName("abc") .setConsumerGroup("xyz") .setOwnerId("owner1") .setPartitionId(String.valueOf(i)); - pos[i] = po; + pos.add(po); } blobCheckpointStore.claimOwnership(pos).subscribe(BlobCheckpointStoreSample::printPartitionOwnership, System.out::println); diff --git a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/test/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobEventProcessorClientStoreTest.java b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/test/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobEventProcessorClientStoreTest.java index 282ee588e1c2..40df3b74448e 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/test/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobEventProcessorClientStoreTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/test/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobEventProcessorClientStoreTest.java @@ -99,6 +99,8 @@ public void testUpdateCheckpoint() { when(blobContainerAsyncClient.getBlobAsyncClient("ns/eh/cg/checkpoint/0")).thenReturn(blobAsyncClient); when(blobContainerAsyncClient.listBlobs(any(ListBlobsOptions.class))).thenReturn(response); + when(blobAsyncClient.getBlockBlobAsyncClient()).thenReturn(blockBlobAsyncClient); + when(blobAsyncClient.exists()).thenReturn(Mono.just(true)); when(blobAsyncClient.setMetadata(ArgumentMatchers.>any())) .thenReturn(Mono.empty()); @@ -123,7 +125,7 @@ public void testClaimOwnership() { .thenReturn(Mono.just(new ResponseBase<>(null, 200, httpHeaders, null, null))); BlobCheckpointStore blobCheckpointStore = new BlobCheckpointStore(blobContainerAsyncClient); - StepVerifier.create(blobCheckpointStore.claimOwnership(po)) + StepVerifier.create(blobCheckpointStore.claimOwnership(Arrays.asList(po))) .assertNext(partitionOwnership -> { assertEquals("owner1", partitionOwnership.getOwnerId()); assertEquals("0", partitionOwnership.getPartitionId()); @@ -157,7 +159,7 @@ public void testUpdateCheckpointError() { Map headers = new HashMap<>(); headers.put("eTag", "etag2"); when(blobContainerAsyncClient.getBlobAsyncClient("ns/eh/cg/checkpoint/0")).thenReturn(blobAsyncClient); - + when(blobAsyncClient.exists()).thenReturn(Mono.just(true)); when(blobAsyncClient.setMetadata(ArgumentMatchers.>any())) .thenReturn(Mono.error(new SocketTimeoutException())); @@ -179,7 +181,7 @@ public void testFailedOwnershipClaim() { any(BlobRequestConditions.class))) .thenReturn(Mono.error(new ResourceModifiedException("Etag did not match", null))); BlobCheckpointStore blobCheckpointStore = new BlobCheckpointStore(blobContainerAsyncClient); - StepVerifier.create(blobCheckpointStore.claimOwnership(po)).verifyComplete(); + StepVerifier.create(blobCheckpointStore.claimOwnership(Arrays.asList(po))).verifyComplete(); } private PartitionOwnership createPartitionOwnership(String fullyQualifiedNamespace, String eventHubName, diff --git a/sdk/eventhubs/azure-messaging-eventhubs/README.md b/sdk/eventhubs/azure-messaging-eventhubs/README.md index 02dd87c2f5e0..8cd5b45b0ff7 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/README.md +++ b/sdk/eventhubs/azure-messaging-eventhubs/README.md @@ -23,17 +23,17 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples] - [Table of contents](#table-of-contents) - [Getting started](#getting-started) - - [Default SSL](#default-ssl-library) - [Prerequisites](#prerequisites) - [Adding the package to your product](#adding-the-package-to-your-product) + - [Default SSL library](#default-ssl-library) - [Methods to authorize with Event Hubs](#methods-to-authorize-with-event-hubs) - - [Create an Event Hub client using a connection string](#create-an-event-hub-client-using-a-connection-string) + - [Create an Event Hub producer using a connection string](#create-an-event-hub-producer-using-a-connection-string) - [Create an Event Hub client using Microsoft identity platform (formerly Azure Active Directory)](#create-an-event-hub-client-using-microsoft-identity-platform-formerly-azure-active-directory) - [Key concepts](#key-concepts) - [Examples](#examples) - [Publish events to an Event Hub](#publish-events-to-an-event-hub) - [Consume events from an Event Hub partition](#consume-events-from-an-event-hub-partition) - - [Consume events using an Event Processor](#consume-events-using-an-event-processor) + - [Consume events using an EventProcessorClient](#consume-events-using-an-eventprocessorclient) - [Troubleshooting](#troubleshooting) - [Enable client logging](#enable-client-logging) - [Enable AMQP transport logging](#enable-amqp-transport-logging) @@ -44,17 +44,14 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples] ## Getting started -### Default SSL library -All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSL operations. The Boring SSL library is an uber jar containing native libraries for Linux / macOS / Windows, and provides better performance compared to the default SSL implementation within the JDK. For more information, including how to reduce the dependency size, refer to the [performance tuning][performance_tuning] section of the wiki. - ### Prerequisites - Java Development Kit (JDK) with version 8 or above - [Maven][maven] - Microsoft Azure subscription - - You can create a free account at: https://azure.microsoft.com + - You can create a free account at: https://azure.microsoft.com - Azure Event Hubs instance - - Step-by-step guide for [creating an Event Hub using the Azure Portal][event_hubs_create] + - Step-by-step guide for [creating an Event Hub using the Azure Portal][event_hubs_create] ### Adding the package to your product @@ -68,6 +65,13 @@ All client libraries, by default, use the Tomcat-native Boring SSL library to en ``` [//]: # ({x-version-update-end}) +### Default SSL library +All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level +performance for SSL operations. The Boring SSL library is an uber jar containing native libraries +for Linux/macOS/Windows, and provides better performance compared to the default SSL +implementation within the JDK. For more information, including how to reduce the dependency size, +refer to the [performance tuning][performance_tuning] section of the wiki. + ### Methods to authorize with Event Hubs For the Event Hubs client library to interact with an Event Hub, it will need to understand how to connect and authorize @@ -79,9 +83,10 @@ The easiest means for doing so is to use a connection string, which is created a namespace. If you aren't familiar with shared access policies in Azure, you may wish to follow the step-by-step guide to [get an Event Hubs connection string][event_hubs_connection_string]. -Both the asynchronous and synchronous Event Hub producer and consumer clients can be created using -`EventHubClientBuilder`. Invoking `.buildAsyncProducer()` and `buildProducer` will build the asynchronous and -synchronous producers. Similarly, `.buildAsyncConsumer` and `.buildConsumer` will build the appropriate consumers. +Both the asynchronous and synchronous Event Hub producer and consumer clients can be created using +`EventHubClientBuilder`. Invoking `buildAsyncProducerClient()` or `buildProducerClient()` will build the asynchronous or +synchronous producers. Similarly, `buildAsyncConsumerClient()` or `buildConsumerClient()` will build the appropriate +consumers. The snippet below creates a synchronous Event Hub producer. @@ -90,7 +95,7 @@ String connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>" String eventHubName = "<< NAME OF THE EVENT HUB >>"; EventHubProducerClient producer = new EventHubClientBuilder() .connectionString(connectionString, eventHubName) - .buildProducer(); + .buildProducerClient(); ``` ### Create an Event Hub client using Microsoft identity platform (formerly Azure Active Directory) @@ -127,11 +132,11 @@ ClientSecretCredential credential = new ClientSecretCredentialBuilder() // The fully qualified namespace for the Event Hubs instance. This is likely to be similar to: // {your-namespace}.servicebus.windows.net -String fullyQualifiedNamespace = "<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>" +String fullyQualifiedNamespace = "my-test-eventhubs.servicebus.windows.net"; String eventHubName = "<< NAME OF THE EVENT HUB >>"; EventHubProducerClient client = new EventHubClientBuilder() .credential(fullyQualifiedNamespace, eventHubName, credential) - .buildProducer(); + .buildProducerClient(); ``` ## Key concepts @@ -162,38 +167,33 @@ are well documented in [OASIS Advanced Messaging Queuing Protocol (AMQP) Version ## Examples -- [Inspect Event Hub and partition properties][sample_get_event_hubs_metadata] -- [Publish an EventDataBatch to an Event Hub][sample_publish_eventdatabatch] -- [Consume events from an Event Hub partition][sample_consume_event] -- [Consume events from all Event Hub partitions][sample_event_processor] - ### Publish events to an Event Hub -In order to publish events, you'll need to create an asynchronous -[`EventHubProducerAsyncClient`][source_eventhubasyncproducerclient] or a synchronous -[`EventHubProducerClient`][source_eventHubProducerClient]. -Each producers can send events to either, a specific partition, or allow the Event Hubs service to decide which -partition events should be published to. It is recommended to use automatic routing when the publishing of events needs -to be highly available or when event data should be distributed evenly among the partitions. In the our example, we will -take advantage of automatic routing. +To publish events, you'll need to create an asynchronous [`EventHubProducerAsyncClient`][EventHubProducerAsyncClient] or +a synchronous [`EventHubProducerClient`][EventHubProducerClient]. Each producer can send events to either, a specific +partition, or allow the Event Hubs service to decide which partition events should be published to. It is recommended to +use automatic routing when the publishing of events needs to be highly available or when event data should be +distributed evenly among the partitions. -#### Event Hub producer creation +#### Create an Event Hub producer and publish events -Developers can create a producer by calling `buildProducer()` or `buildAsyncProducer`. If `buildProducer` is invoked, a -synchronous `EventHubProducerClient` is created. If `buildAsyncProducer` is used, an asynchronous -`EventHubProducerAsyncClient` is returned. +Developers can create a producer by calling `buildAsyncProducerClient()` or `buildProducerClient()`. If +`buildProducerClient()` is invoked, a synchronous `EventHubProducerClient` is created. If `buildAsyncProducerClient()` +is used, an asynchronous `EventHubProducerAsyncClient` is returned. -Specifying `batchOptions.partitionId(String)` will send events to a specific partition, and not, will allow for automatic -routing. In addition, specifying `partitionKey(String)` will tell Event Hubs service to hash the events and send them to -the same partition. +Specifying `CreateBatchOptions.setPartitionId(String)` will send events to a specific partition. If not specified, will +allow for automatic partition routing. In addition, specifying `CreateBatchOptions.setPartitionKey(String)` will tell +Event Hubs service to hash the events and send them to the same partition. -The snippet below creates a synchronous producer and sends events to any partition, allowing Event Hubs service to route the event -to an available partition. +The snippet below creates a synchronous producer and sends events to any partition, allowing Event Hubs service to route +the event to an available partition. ```java +List eventDataList = Arrays.asList(new EventData("Foo"), new EventData("Bar")); + EventHubProducerClient producer = new EventHubClientBuilder() .connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>") - .buildProducer(); + .buildProducerClient(); EventDataBatch eventDataBatch = producer.createBatch(); for (EventData eventData : eventDataList) { if (!eventDataBatch.tryAdd(eventData)) { @@ -203,100 +203,108 @@ for (EventData eventData : eventDataList) { } // send the last batch of remaining events -if (eventDataBatch.getSize() > 0) { +if (eventDataBatch.getCount() > 0) { producer.send(eventDataBatch); } ``` -To send events to a particular partition, set the optional parameter `partitionId` on -[`CreateBatchOptions`][source_CreateBatchOptions]. +To send events to a particular partition, set the optional parameter `setPartitionId(String)` on +[`CreateBatchOptions`][CreateBatchOptions]. -#### Partition identifier +#### Publish events using partition identifier Many Event Hub operations take place within the scope of a specific partition. Because partitions are owned by the Event -Hub, their names are assigned at the time of creation. To understand what partitions are available, You can use the -`getPartitionIds` function to get the ids of all available partitions in your Event Hub instance. +Hub, their names are assigned at the time of creation. To understand what partitions are available, you can use the +`getPartitionIds()` function to get the ids of all available partitions in your Event Hub instance. All clients created +using `EventHubsClientBuilder` can query for metadata about the Event Hub using `getPartitionIds()` or +`getEventHubProperties()`. ```java -IterableStream partitionIds = client.getPartitionIds(); +EventHubProducerClient producer = new EventHubClientBuilder() + .connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>") + .buildProducerClient(); + +CreateBatchOptions options = new CreateBatchOptions().setPartitionId("0"); +EventDataBatch batch = producer.createBatch(options); + +// Add events to batch and when you want to send the batch, send it using the producer. +producer.send(batch); ``` -#### Partition key +#### Publish events using partition key When an Event Hub producer is not associated with any specific partition, it may be desirable to request that the Event Hubs service keep different events or batches of events together on the same partition. This can be accomplished by setting a `partition key` when publishing the events. ```java -CreateBatchOptions batchOptions = new CreateBatchOptions() - .partitionKey("grouping-key"); +CreateBatchOptions batchOptions = new CreateBatchOptions().setPartitionKey("grouping-key"); EventDataBatch eventDataBatch = producer.createBatch(batchOptions); -// add events to eventDataBatch + +// Add events to batch and when you want to send the batch, send it using the producer. producer.send(eventDataBatch); ``` ### Consume events from an Event Hub partition -In order to consume events, you'll need to create an `EventHubAsyncConsumer` or `EventHubConsumer` for a specific -partition and consumer group combination. When an Event Hub is created, it starts with a default consumer group that can -be used to get started. A consumer also needs to specify where in the event stream to begin receiving events; in our -example, we will focus on reading new events as they are published. +In order to consume events, you'll need to create an [`EventHubConsumerAsyncClient`][EventHubConsumerAsyncClient] or +[`EventHubConsumerClient`][EventHubConsumerClient] for a specific consumer group. When an Event Hub is created, it +starts with a default consumer group that can be used to get started. A consumer also needs to specify where in the +event stream to begin receiving events. -#### Consume events with EventHubAsyncConsumer +#### Consume events with EventHubConsumerAsyncClient In the snippet below, we are creating an asynchronous consumer that receives events from `partitionId` and only listens -to newest events that get pushed to the partition using `receive(String partitionId)`. Developers can begin receiving -events by calling `.receive(String partitionId)` and subscribing to the stream. +to newest events that get pushed to the partition by invoking `receiveFromPartition(String, EventPosition)`. Developers +can begin receiving events from multiple partitions using the same EventHubConsumerAsyncClient by calling +`receiveFromPartition(String, EventPosition)` with another partition id, and subscribing to that Flux. ```java -EventHubAsyncConsumer client = new EventHubClientBuilder() +EventHubConsumerAsyncClient consumer = new EventHubClientBuilder() .connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>") - .consumerGroup(EventHubAsyncClient.DEFAULT_CONSUMER_GROUP_NAME) - .startingPosition(EventPosition.earliest()) - .buildAsyncConsumer(); + .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME) + .buildAsyncConsumerClient(); -consumer.receive(partitionId).subscribe(event -> { +// Receive events from partition with id "0", only getting events that are newly added to the partition. +consumer.receiveFromPartition("0", EventPosition.latest()).subscribe(event -> { // Process each event as it arrives. }); ``` -#### Consume events with EventHubConsumer +#### Consume events with EventHubConsumerClient -Developers can create a synchronous consumer that returns events in batches using an `EventHubAsyncConsumer`. In the +Developers can create a synchronous consumer that returns events in batches using an `EventHubConsumerClient`. In the snippet below, a consumer is created that starts reading events from the beginning of the partition's event stream. ```java -EventHubConsumer client = new EventHubClientBuilder() +EventHubConsumerClient consumer = new EventHubClientBuilder() .connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>") - .consumerGroup(EventHubAsyncClient.DEFAULT_CONSUMER_GROUP_NAME) - .startingPosition(EventPosition.earliest()) - .buildConsumer(); + .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME) + .buildConsumerClient(); String partitionId = "<< EVENT HUB PARTITION ID >>"; // Get the first 15 events in the stream, or as many events as can be received within 40 seconds. -IterableStream events = consumer.receive(partitionId, 15, Duration.ofSeconds(40)); -for (EventData event : events) { - // Process each event +IterableStream events = consumer.receiveFromPartition(partitionId, 15, + EventPosition.earliest(), Duration.ofSeconds(40)); +for (PartitionEvent event : events) { + System.out.println("Event: " + event.getData().getBodyAsString()); } - -// Calling receive again returns the next 15 events in the stream, or as many as possible in 40 seconds. -IterableStream nextEvents = consumer.receive(partitionId, 15, Duration.ofSeconds(40)); ``` -### Consume events using an Event Processor Client +### Consume events using an EventProcessorClient -To consume events for all partitions of an Event Hub, you'll create an [`EventProcessorClient`][source_eventprocessorclient] for a -specific consumer group. When an Event Hub is created, it provides a default consumer group that can be used to get -started. +To consume events for all partitions of an Event Hub, you'll create an [`EventProcessorClient`][EventProcessorClient] +for a specific consumer group. When an Event Hub is created, it provides a default consumer group that can be used to +get started. -The [`EventProcessorClient`][source_eventprocessorclient] will delegate processing of events to a callback function that you -provide, allowing you to focus on the logic needed to provide value while the processor holds responsibility for +The [`EventProcessorClient`][EventProcessorClient] will delegate processing of events to a callback function that you +provide, allowing you to focus on the logic needed to provide value while the processor holds responsibility for managing the underlying consumer operations. -In our example, we will focus on building the [`EventProcessorClient`][source_eventprocessorclient], use the -[`InMemoryCheckpointStore`][source_inmemorycheckpointstore] available in samples, and a callback function that -processes events received from the Event Hub and writes to console. +In our example, we will focus on building the [`EventProcessorClient`][EventProcessorClient], use the +[`InMemoryCheckpointStore`][InMemoryCheckpointStore] available in samples, and a callback function that processes events +received from the Event Hub and writes to console. ```java class Program { @@ -316,9 +324,9 @@ class Program { // This will start the processor. It will start processing events from all partitions. eventProcessorClient.start(); - + // (for demo purposes only - adding sleep to wait for receiving events) - TimeUnit.SECONDS.sleep(2); + TimeUnit.SECONDS.sleep(2); // When the user wishes to stop processing events, they can call `stop()`. eventProcessorClient.stop(); @@ -332,7 +340,7 @@ class Program { You can set the `AZURE_LOG_LEVEL` environment variable to view logging statements made in the client library. For example, setting `AZURE_LOG_LEVEL=2` would show all informational, warning, and error log messages. The log levels can -be found here: [log levels][source_loglevels]. +be found here: [log levels][LogLevels]. ### Enable AMQP transport logging @@ -364,17 +372,17 @@ This is a general exception for AMQP related failures, which includes the AMQP e that caused this exception as ErrorContext. 'isTransient' is a boolean indicating if the exception is a transient error or not. If true, then the request can be retried; otherwise not. -The [ErrorCondition][source_errorcondition] contains error conditions common to the AMQP protocol and used by Azure +[`AmqpErrorCondition`][AmqpErrorCondition] contains error conditions common to the AMQP protocol and used by Azure services. When an AMQP exception is thrown, examining the error condition field can inform developers as to why the AMQP exception occurred and if possible, how to mitigate this exception. A list of all the AMQP exceptions can be found in [OASIS AMQP Version 1.0 Transport Errors][oasis_amqp_v1_error]. -The [ErrorContext][source_errorcontext] in the [AmqpException][source_amqpexception] provides information about the AMQP +The [`AmqpErrorContext`][AmqpErrorContext] in the [`AmqpException`][AmqpException] provides information about the AMQP session, link, or connection that the exception occurred in. This is useful to diagnose which level in the transport this exception occurred at and whether it was an issue in one of the producers or consumers. -The recommended way to solve the specific exception the AMQP exception represents is to follow the [Event Hubs Messaging -Exceptions][event_hubs_messaging_exceptions] guidance. +The recommended way to solve the specific exception the AMQP exception represents is to follow the +[Event Hubs Messaging Exceptions][event_hubs_messaging_exceptions] guidance. #### Operation cancelled exception @@ -400,12 +408,14 @@ advantage of the full feature set of the Azure Event Hubs service. In order to h the following set of sample is available: - [Inspect Event Hub and partition properties][sample_get_event_hubs_metadata] -- [Publish an event batch to an Event Hub][sample_publish_eventdatabatch] +- [Publish events using Microsoft identity platform][sample_publish_identity] - [Publish events to a specific Event Hub partition with partition identifier][sample_publish_partitionId] - [Publish events to a specific Event Hub partition with partition key][sample_publish_partitionKey] +- [Publish events to an Event Hub with a size-limited batch][sample_publish_size_limited] - [Publish events with custom metadata][sample_publish_custom_metadata] - [Consume events from an Event Hub partition][sample_consume_event] -- [Save the last read event and resume from that point][sample_sequence_number] +- [Consume events starting from an event sequence number][sample_consume_sequence_number] +- [Consume events from all partitions using EventProcessorClient][sample_event_processor] ## Contributing @@ -429,26 +439,27 @@ Guidelines](./CONTRIBUTING.md) for more information. [oasis_amqp_v1]: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html [performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning [qpid_proton_j_apache]: http://qpid.apache.org/proton/ -[sample_consume_event]: ./src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java -[sample_event_processor]: ./src/samples/java/com/azure/messaging/eventhubs/EventProcessorSample.java [sample_examples]: ./src/samples/java/com/azure/messaging/eventhubs/ +[sample_consume_event]: ./src/samples/java/com/azure/messaging/eventhubs/ConsumeEvents.java +[sample_consume_sequence_number]: ./src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java +[sample_event_processor]: ./src/samples/java/com/azure/messaging/eventhubs/EventProcessorSample.java [sample_get_event_hubs_metadata]: ./src/samples/java/com/azure/messaging/eventhubs/GetEventHubMetadata.java [sample_publish_custom_metadata]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithCustomMetadata.java -[sample_publish_eventdatabatch]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventDataBatch.java +[sample_publish_identity]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithAzureIdentity.java [sample_publish_partitionId]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventsToSpecificPartition.java [sample_publish_partitionKey]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithPartitionKey.java -[sample_sequence_number]: ./src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java -[source_amqpexception]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpException.java +[sample_publish_size_limited]: ./src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithSizeLimitedBatches.java [source_code]: ./ -[source_errorcondition]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/ErrorCondition.java -[source_errorcontext]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/ErrorContext.java -[source_eventhubasyncclient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubAsyncClient.java -[source_eventhubasyncproducerclient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java -[source_eventhubclient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubClient.java -[source_eventHubProducerClient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java -[source_eventprocessorclient]: ./src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java -[source_CreateBatchOptions]: ./src/main/java/com/azure/messaging/eventhubs/models/CreateBatchOptions.java -[source_inmemorycheckpointstore]: ./src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java -[source_loglevels]: ../../core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java +[AmqpException]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpException.java +[AmqpErrorCondition]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorCondition.java +[AmqpErrorContext]: ../../core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorContext.java +[EventHubConsumerAsyncClient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java +[EventHubConsumerClient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java +[EventHubProducerAsyncClient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java +[EventHubProducerClient]: ./src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java +[EventProcessorClient]: ./src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java +[CreateBatchOptions]: ./src/main/java/com/azure/messaging/eventhubs/models/CreateBatchOptions.java +[InMemoryCheckpointStore]: ./src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java +[LogLevels]: ../../core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Feventhubs%2Fazure-messaging-eventhubs%2FREADME.png) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/pom.xml b/sdk/eventhubs/azure-messaging-eventhubs/pom.xml index c0994d2cc4dc..79ebeb999013 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/pom.xml +++ b/sdk/eventhubs/azure-messaging-eventhubs/pom.xml @@ -8,7 +8,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -37,7 +37,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -61,31 +61,37 @@ org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test org.mockito mockito-core + 3.0.0 test diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/CheckpointStore.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/CheckpointStore.java index 0126fae6aa35..b683d1835cd7 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/CheckpointStore.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/CheckpointStore.java @@ -5,6 +5,7 @@ import com.azure.messaging.eventhubs.models.Checkpoint; import com.azure.messaging.eventhubs.models.PartitionOwnership; +import java.util.List; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -31,10 +32,10 @@ Flux listOwnership(String fullyQualifiedNamespace, String ev * Called to claim ownership of a list of partitions. This will return the list of partitions that were owned * successfully. * - * @param requestedPartitionOwnerships Array of partition ownerships this instance is requesting to own. + * @param requestedPartitionOwnerships List of partition ownerships this instance is requesting to own. * @return A flux of partitions this instance successfully claimed ownership. */ - Flux claimOwnership(PartitionOwnership... requestedPartitionOwnerships); + Flux claimOwnership(List requestedPartitionOwnerships); /** * Called to get the list of checkpoints from the underlying data store. This method could return empty results if diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java index b944fe34cded..0d1e0f5c561d 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java @@ -343,6 +343,21 @@ public EventHubClientBuilder prefetchCount(int prefetchCount) { return this; } + /** + * Package-private method that sets the scheduler for the created Event Hub client. + * + * TODO (conniey): Currently, the default is to use an elastic scheduler if none is specified to facilitate the + * possibility of legacy blocking code. However, we should consider if we should give consumers an option to use a + * parallel Scheduler. https://github.com/Azure/azure-sdk-for-java/issues/5466 + * + * @param scheduler Scheduler to set. + * @return The updated {@link EventHubClientBuilder} object. + */ + EventHubClientBuilder scheduler(Scheduler scheduler) { + this.scheduler = scheduler; + return this; + } + /** * Creates a new {@link EventHubConsumerAsyncClient} based on the options set on this builder. Every time * {@code buildAsyncConsumer()} is invoked, a new instance of {@link EventHubConsumerAsyncClient} is created. diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java index 3af7f25ef199..30014b962d0d 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java @@ -29,8 +29,8 @@ import static com.azure.core.util.FluxUtil.monoError; /** - * A consumer responsible for reading {@link EventData} from a specific Event Hub partition in the context of a specific - * consumer group. + * An asynchronous consumer responsible for reading {@link EventData} from either a specific Event Hub partition + * or all partitions in the context of a specific consumer group. * *

Creating an {@link EventHubConsumerAsyncClient}

*

Required parameters are {@code consumerGroup}, and credentials are required when diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java index 322ba9f0fe8a..4cb9344faf3d 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java @@ -22,8 +22,8 @@ import java.util.concurrent.atomic.AtomicInteger; /** - * A consumer responsible for reading {@link EventData} from either a specific Event Hub partition or all partitions in - * the context of a consumer group. + * A synchronous consumer responsible for reading {@link EventData} from an Event Hub partition in the context of + * a specific consumer group. * *

Creating a synchronous consumer

*

Required parameters are {@code consumerGroup} and credentials when creating a consumer.

diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java index f8559e44c997..f68e4eee65f1 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java @@ -50,9 +50,9 @@ import static com.azure.messaging.eventhubs.implementation.ClientConstants.MAX_MESSAGE_LENGTH_BYTES; /** - * A producer responsible for transmitting {@link EventData} to a specific Event Hub, grouped together in batches. - * Depending on the options specified at creation, the producer may be created to allow event data to be automatically - * routed to an available partition or specific to a partition. + * An asynchronous producer responsible for transmitting {@link EventData} to a specific Event Hub, grouped + * together in batches. Depending on the options specified at creation, the producer may be created to allow event data + * to be automatically routed to an available partition or specific to a partition. * *

* Allowing automatic routing of partitions is recommended when: diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java index 356e93c4a8f6..76e72d960f5a 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java @@ -15,9 +15,9 @@ import java.util.Objects; /** - * A producer responsible for transmitting {@link EventData} to a specific Event Hub, grouped together in batches. - * Depending on the options specified at creation, the producer may be created to allow event data to be automatically - * routed to an available partition or specific to a partition. + * A synchronous producer responsible for transmitting {@link EventData} to a specific Event Hub, grouped + * together in batches. Depending on the options specified at creation, the producer may be created to allow event data + * to be automatically routed to an available partition or specific to a partition. * *

* Allowing automatic routing of partitions is recommended when: diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProperties.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProperties.java index 0e3a89e52f43..15fe0fb2b2e3 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProperties.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProperties.java @@ -6,15 +6,14 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.IterableStream; import com.azure.messaging.eventhubs.models.EventPosition; -import reactor.core.publisher.Flux; import java.time.Instant; import java.util.Arrays; +import java.util.Objects; /** - * Holds information about an Event Hub which can come handy while performing operations like - * {@link EventHubConsumerAsyncClient#receiveFromPartition(String, EventPosition) receiving events from a specific - * partition}. + * Holds information about an Event Hub which can come handy while performing operations like {@link + * EventHubConsumerAsyncClient#receiveFromPartition(String, EventPosition) receiving events from a specific partition}. * * @see EventHubConsumerAsyncClient * @see EventHubConsumerClient @@ -25,19 +24,24 @@ public final class EventHubProperties { private final Instant createdAt; private final IterableStream partitionIds; - EventHubProperties( - final String name, - final Instant createdAt, - final String[] partitionIds) { - this.name = name; - this.createdAt = createdAt; - this.partitionIds = partitionIds != null - ? new IterableStream<>(Flux.fromArray(Arrays.copyOf(partitionIds, partitionIds.length))) - : new IterableStream<>(Flux.empty()); + /** + * Creates an instance of {@link EventHubProperties}. + * + * @param name Name of the Event Hub. + * @param createdAt Datetime the Event Hub was created, in UTC. + * @param partitionIds The partitions ids in the Event Hub. + * + * @throws NullPointerException if {@code name}, {@code createdAt}, or {@code partitionIds} is {@code null}. + */ + EventHubProperties(final String name, final Instant createdAt, final String[] partitionIds) { + this.name = Objects.requireNonNull(name, "'name' cannot be null."); + this.createdAt = Objects.requireNonNull(createdAt, "'createdAt' cannot be null."); + this.partitionIds = new IterableStream<>(Arrays.asList( + Objects.requireNonNull(partitionIds, "'partitionIds' cannot be null."))); } /** - * Gets the Event Hub name + * Gets the name of the Event Hub. * * @return Name of the Event Hub. */ @@ -46,7 +50,7 @@ public String getName() { } /** - * Gets the instant, in UTC, at which Event Hub was created at. + * Gets the instant, in UTC, at which Event Hub was created. * * @return The instant, in UTC, at which the Event Hub was created. */ diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClientBuilder.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClientBuilder.java index 77e08187a643..aef2a3a63100 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClientBuilder.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClientBuilder.java @@ -307,14 +307,15 @@ public EventProcessorClientBuilder trackLastEnqueuedEventProperties(boolean trac *

* * @return A new instance of {@link EventProcessorClient}. - * @throws NullPointerException if {@code processEvent} or {@code checkpointStore} or {@code consumerGroup} is - * {@code null}. + * @throws NullPointerException if {@code processEvent} or {@code processError} or {@code checkpointStore} or + * {@code consumerGroup} is {@code null}. * @throws IllegalArgumentException if the credentials have not been set using either {@link * #connectionString(String)} or {@link #credential(String, String, TokenCredential)}. Or, if a proxy is specified * but the transport type is not {@link AmqpTransportType#AMQP_WEB_SOCKETS web sockets}. */ public EventProcessorClient buildEventProcessorClient() { Objects.requireNonNull(processEvent, "'processEvent' cannot be null"); + Objects.requireNonNull(processError, "'processError' cannot be null"); Objects.requireNonNull(checkpointStore, "'checkpointStore' cannot be null"); Objects.requireNonNull(consumerGroup, "'consumerGroup' cannot be null"); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancer.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancer.java index 99e3534c21d4..e19c7e3a9c7c 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancer.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancer.java @@ -146,16 +146,6 @@ private Mono loadBalance(final Tuple2, Lis partitionOwnershipMap); logger.info("Number of active ownership records {}", activePartitionOwnershipMap.size()); - if (CoreUtils.isNullOrEmpty(activePartitionOwnershipMap)) { - /* - * If the active partition ownership map is empty, this is the first time an event processor is - * running or all Event Processors are down for this Event Hub, consumer group combination. All - * partitions in this Event Hub are available to claim. Choose a random partition to claim ownership. - */ - claimOwnership(partitionOwnershipMap, partitionIds.get(RANDOM.nextInt(numberOfPartitions))); - return; - } - /* * Create a map of owner id and a list of partitions it owns */ @@ -167,6 +157,17 @@ private Mono loadBalance(final Tuple2, Lis // add the current event processor to the map if it doesn't exist ownerPartitionMap.putIfAbsent(this.ownerId, new ArrayList<>()); + if (CoreUtils.isNullOrEmpty(activePartitionOwnershipMap)) { + /* + * If the active partition ownership map is empty, this is the first time an event processor is + * running or all Event Processors are down for this Event Hub, consumer group combination. All + * partitions in this Event Hub are available to claim. Choose a random partition to claim ownership. + */ + claimOwnership(partitionOwnershipMap, ownerPartitionMap, + partitionIds.get(RANDOM.nextInt(numberOfPartitions))); + return; + } + /* * Find the minimum number of partitions every event processor should own when the load is * evenly distributed. @@ -191,6 +192,8 @@ private Mono loadBalance(final Tuple2, Lis ownerPartitionMap)) { // If the partitions are evenly distributed among all active event processors, no change required. logger.info("Load is balanced"); + // renew ownership of already owned partitions + checkpointStore.claimOwnership(ownerPartitionMap.get(this.ownerId)).subscribe(); return; } @@ -198,6 +201,8 @@ private Mono loadBalance(final Tuple2, Lis // This event processor already has enough partitions and shouldn't own more. logger.info("This event processor owns {} partitions and shouldn't own more", ownerPartitionMap.get(ownerId).size()); + // renew ownership of already owned partitions + checkpointStore.claimOwnership(ownerPartitionMap.get(this.ownerId)).subscribe(); return; } @@ -224,7 +229,7 @@ private Mono loadBalance(final Tuple2, Lis return findPartitionToSteal(ownerPartitionMap); }); - claimOwnership(partitionOwnershipMap, partitionToClaim); + claimOwnership(partitionOwnershipMap, ownerPartitionMap, partitionToClaim); }); } @@ -320,14 +325,17 @@ private Map removeInactivePartitionOwnerships( }).collect(Collectors.toMap(Entry::getKey, Entry::getValue)); } - private void claimOwnership(final Map partitionOwnershipMap, - final String partitionIdToClaim) { + private void claimOwnership(final Map partitionOwnershipMap, Map> ownerPartitionsMap, final String partitionIdToClaim) { logger.info("Attempting to claim ownership of partition {}", partitionIdToClaim); PartitionOwnership ownershipRequest = createPartitionOwnershipRequest(partitionOwnershipMap, partitionIdToClaim); + List currentPartitionsOwned = ownerPartitionsMap.get(ownerId); + currentPartitionsOwned.add(ownershipRequest); + checkpointStore - .claimOwnership(ownershipRequest) + .claimOwnership(currentPartitionsOwned) .timeout(Duration.ofMinutes(1)) // TODO: configurable .doOnNext(partitionOwnership -> logger.info("Successfully claimed ownership of partition {}", partitionOwnership.getPartitionId())) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventContext.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventContext.java index 90069bf7b45c..e167d0882f3b 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventContext.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventContext.java @@ -89,8 +89,9 @@ public Mono updateCheckpointAsync(EventData eventData) { return monoError(logger, new NullPointerException("'eventData' cannot be null")); } Checkpoint checkpoint = new Checkpoint() - .setConsumerGroup(partitionContext.getConsumerGroup()) + .setFullyQualifiedNamespace(partitionContext.getFullyQualifiedNamespace()) .setEventHubName(partitionContext.getEventHubName()) + .setConsumerGroup(partitionContext.getConsumerGroup()) .setPartitionId(partitionContext.getPartitionId()) .setSequenceNumber(eventData.getSequenceNumber()) .setOffset(eventData.getOffset()); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvents.java similarity index 99% rename from sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java rename to sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvents.java index 1aaea8b63d86..f89dcab19dfb 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvents.java @@ -16,7 +16,7 @@ /** * Sample demonstrates how to receive events from an Azure Event Hub instance. */ -public class ConsumeEvent { +public class ConsumeEvents { private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); private static final int NUMBER_OF_EVENTS = 10; diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java index 733ef6095470..a2559f15e574 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEventsFromKnownSequenceNumberPosition.java @@ -4,30 +4,27 @@ import com.azure.messaging.eventhubs.models.EventPosition; import com.azure.messaging.eventhubs.models.SendOptions; -import reactor.core.Disposable; import java.time.Duration; -import java.util.concurrent.Semaphore; +import java.util.concurrent.atomic.AtomicBoolean; import static java.nio.charset.StandardCharsets.UTF_8; /** - * Sample demonstrates how to receive events starting from the specific sequence number position in an Event Hub instance. + * Sample demonstrates how to receive events starting from the specific sequence number position in an Event Hub + * instance. It also demonstrates how to publish events to a specific partition. */ public class ConsumeEventsFromKnownSequenceNumberPosition { private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); - private static long lastEnqueuedSequenceNumber = -1; - private static String lastEnqueuedSequencePartitionId = null; /** - * Main method to invoke this demo about how to receive event from a known sequence number position in an Azure Event Hub instance. + * Main method to invoke this demo about how to receive event from a known sequence number position in an Azure + * Event Hub instance. * * @param args Unused arguments to the program. - * @throws InterruptedException The countdown latch was interrupted while waiting for this sample to - * complete. */ - public static void main(String[] args) throws InterruptedException { - Semaphore semaphore = new Semaphore(0); + public static void main(String[] args) { + final AtomicBoolean isRunning = new AtomicBoolean(true); // The connection string value can be obtained by: // 1. Going to your Event Hubs namespace in Azure Portal. @@ -36,76 +33,59 @@ public static void main(String[] args) throws InterruptedException { // 4. Copying the connection string from the policy's properties. String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}"; - EventHubClientBuilder builder = new EventHubClientBuilder() - .connectionString(connectionString) - .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME); - - EventHubConsumerAsyncClient earliestConsumer = builder.buildAsyncConsumerClient(); - - earliestConsumer.getPartitionIds().flatMap(partitionId -> earliestConsumer.getPartitionProperties(partitionId)) - .subscribe( - properties -> { - if (!properties.isEmpty()) { - lastEnqueuedSequenceNumber = properties.getLastEnqueuedSequenceNumber(); - lastEnqueuedSequencePartitionId = properties.getId(); - } - }, - error -> System.err.println("Error occurred while fetching partition properties: " + error.toString()), - () -> { - // Releasing the semaphore now that we've finished querying for partition properties. - semaphore.release(); - }); - - System.out.println("Waiting for partition properties to complete..."); - // Acquiring the semaphore so that this sample does not end before all the partition properties are fetched. - semaphore.acquire(); - System.out.printf("Last enqueued sequence number: %s%n", lastEnqueuedSequenceNumber); + final EventHubClientBuilder builder = new EventHubClientBuilder() + .connectionString(connectionString); + + // The consumer group is required for consuming events. + final EventHubConsumerAsyncClient consumer = builder + .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME) + .buildAsyncConsumerClient(); + + // Find the first non-empty partition we can start consuming from. + // Block on it because we don't know what partition to start reading from, yet. + final PartitionProperties nonEmptyPartition = consumer.getPartitionIds() + .flatMap(partitionId -> consumer.getPartitionProperties(partitionId)) + .filter(properties -> !properties.isEmpty()) + .blockFirst(OPERATION_TIMEOUT); // Make sure to have at least one non-empty event hub in order to continue the sample execution // if you don't have an non-empty event hub, try with another example 'SendEvent' in the same directory. - if (lastEnqueuedSequenceNumber == -1 || lastEnqueuedSequencePartitionId == null) { - System.err.println("All event hubs are empty"); + if (nonEmptyPartition == null) { + System.err.println("All event hub partitions are empty"); System.exit(0); } - // Create a consumer. - // The "$Default" consumer group is created by default. This value can be found by going to the Event Hub - // instance you are connecting to, and selecting the "Consumer groups" page. EventPosition.latest() tells the - // service we only want events that are sent to the partition after we begin listening. - EventHubConsumerAsyncClient consumer = new EventHubClientBuilder() - .connectionString(connectionString) - .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME) - .buildAsyncConsumerClient(); + // ex. The last enqueued sequence number is 99. If isInclusive is true, the received event starting from + // the same event with sequence number of '99'. Otherwise, the event with sequence number of '100' will + // be the first event received. + final EventPosition position = EventPosition.fromSequenceNumber( + nonEmptyPartition.getLastEnqueuedSequenceNumber(), true); - // We start receiving any events that come from `firstPartition`, print out the contents, and decrement the - // countDownLatch. - final EventPosition position = EventPosition.fromSequenceNumber(lastEnqueuedSequenceNumber, false); - Disposable subscription = consumer.receiveFromPartition(lastEnqueuedSequencePartitionId, position).subscribe(partitionEvent -> { - EventData event = partitionEvent.getData(); - String contents = new String(event.getBody(), UTF_8); - // ex. The last enqueued sequence number is 99. If isInclusive is true, the received event starting from the same - // event with sequence number of '99'. Otherwise, the event with sequence number of '100' will be the first - // event received. - System.out.println(String.format("Receiving an event starting from the sequence number: %s. Contents: %s", - event.getSequenceNumber(), contents)); + // We start receiving any events that come from that non-empty partition, print out the contents. + // We keep receiving events while `takeWhile` resolves to true, that is, the program is still running. + consumer.receiveFromPartition(nonEmptyPartition.getId(), position) + .takeWhile(ignored -> isRunning.get()) + .subscribe(partitionEvent -> { + EventData event = partitionEvent.getData(); + String contents = new String(event.getBody(), UTF_8); - semaphore.release(); - }); + System.out.println(String.format("Event sequence number number: %s. Contents: %s%n", + event.getSequenceNumber(), contents)); + }); - EventHubProducerAsyncClient producer = builder.buildAsyncProducerClient(); + // Create a producer. + final EventHubProducerClient producer = builder.buildProducerClient(); - // Because the consumer is only listening to new events, we need to send some events to that partition. - // This sends the events to `lastEnqueuedSequencePartitionId`. - SendOptions sendOptions = new SendOptions().setPartitionId(lastEnqueuedSequencePartitionId); + // Because the consumer is only listening to new events after the last enqueued event was received, we need to + // send some events to that partition. + final SendOptions sendOptions = new SendOptions().setPartitionId(nonEmptyPartition.getId()); + producer.send(new EventData("Hello world!" .getBytes(UTF_8)), sendOptions); - producer.send(new EventData("Hello world!".getBytes(UTF_8)), sendOptions).block(OPERATION_TIMEOUT); - // Acquiring the semaphore so that this sample does not end before all events are fetched. - semaphore.acquire(); + // Set isRunning to false so we stop taking events. + isRunning.set(false); // Dispose and close of all the resources we've created. - subscription.dispose(); producer.close(); consumer.close(); - earliestConsumer.close(); } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClientJavaDocCodeSamples.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClientJavaDocCodeSamples.java index d6e2ffc1ce59..8485f7088c90 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClientJavaDocCodeSamples.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClientJavaDocCodeSamples.java @@ -23,7 +23,8 @@ public void initialization() { // BEGIN: com.azure.messaging.eventhubs.eventhubconsumerasyncclient.instantiation // The required parameters are `consumerGroup` and a way to authenticate with Event Hubs using credentials. EventHubConsumerAsyncClient consumer = new EventHubClientBuilder() - .connectionString("event-hub-instance-connection-string") + .connectionString("Endpoint={fully-qualified-namespace};SharedAccessKeyName={policy-name};" + + "SharedAccessKey={key};EntityPath={eh-name}") .consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME) .buildAsyncConsumerClient(); // END: com.azure.messaging.eventhubs.eventhubconsumerasyncclient.instantiation diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/GetEventHubMetadata.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/GetEventHubMetadata.java index ecfb4c6ada5c..109117f647d4 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/GetEventHubMetadata.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/GetEventHubMetadata.java @@ -2,21 +2,16 @@ // Licensed under the MIT License. package com.azure.messaging.eventhubs; -import java.util.concurrent.Semaphore; - /** - * Demonstrates how to fetch metadata from an Event Hub's partitions. + * Demonstrates how to fetch metadata from an Event Hub's partitions using synchronous client. */ public class GetEventHubMetadata { /** * Demonstrates how to get metadata from an Event Hub's partitions. * * @param args Unused arguments to the sample. - * @throws InterruptedException if the semaphore could not be acquired. */ - public static void main(String[] args) throws InterruptedException { - Semaphore semaphore = new Semaphore(1); - + public static void main(String[] args) { // The connection string value can be obtained by: // 1. Going to your Event Hubs namespace in Azure Portal. // 2. Creating an Event Hub instance. @@ -24,36 +19,29 @@ public static void main(String[] args) throws InterruptedException { // 4. Copying the connection string from the policy's properties. String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}"; - // Instantiate a client that will be used to call the service. - EventHubProducerAsyncClient client = new EventHubClientBuilder() + // Instantiate a client that will be used to call the service. Using a try-resource block, so it disposes of + // the client when we are done. + EventHubProducerClient client = new EventHubClientBuilder() .connectionString(connectionString) - .buildAsyncProducerClient(); - - // Acquiring the semaphore so that this sample does not end before all the partition properties are fetched. - semaphore.acquire(); + .buildProducerClient(); // Querying the partition identifiers for the Event Hub. Then calling client.getPartitionProperties with the // identifier to get information about each partition. - client.getPartitionIds().flatMap(partitionId -> client.getPartitionProperties(partitionId)) - .subscribe(properties -> { - System.out.println("The Event Hub has the following properties:"); - System.out.printf( - "Event Hub Name: %s; Partition Id: %s; Is partition empty? %s; First Sequence Number: %s; " - + "Last Enqueued Time: %s; Last Enqueued Sequence Number: %s; Last Enqueued Offset: %s", - properties.getEventHubName(), properties.getId(), properties.isEmpty(), - properties.getBeginningSequenceNumber(), - properties.getLastEnqueuedTime(), - properties.getLastEnqueuedSequenceNumber(), - properties.getLastEnqueuedOffset()); - }, error -> { - System.err.println("Error occurred while fetching partition properties: " + error.toString()); - }, () -> { - // Releasing the semaphore now that we've finished querying for partition properties. - semaphore.release(); - }); + for (String partitionId : client.getPartitionIds()) { + PartitionProperties properties = client.getPartitionProperties(partitionId); + System.out.printf( + "Event Hub Name: %s; Partition Id: %s; Is partition empty? %s; First Sequence Number: %s; " + + "Last Enqueued Time: %s; Last Enqueued Sequence Number: %s; Last Enqueued Offset: %s%n", + properties.getEventHubName(), + properties.getId(), + properties.isEmpty(), + properties.getBeginningSequenceNumber(), + properties.getLastEnqueuedTime(), + properties.getLastEnqueuedSequenceNumber(), + properties.getLastEnqueuedOffset()); + } - System.out.println("Waiting for partition properties to complete..."); - semaphore.acquire(); - System.out.println("Finished."); + // Dispose of the client. + client.close(); } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java index 3807892a3a54..f564cc58a06c 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/InMemoryCheckpointStore.java @@ -6,6 +6,7 @@ import com.azure.core.util.logging.ClientLogger; import com.azure.messaging.eventhubs.models.Checkpoint; import com.azure.messaging.eventhubs.models.PartitionOwnership; +import java.util.List; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -44,12 +45,12 @@ public Flux listOwnership(String fullyQualifiedNamespace, St * already claimed by an instance or if the ETag in the request doesn't match the previously stored ETag, then * ownership claim is denied. * - * @param requestedPartitionOwnerships Array of partition ownerships this instance is requesting to own. + * @param requestedPartitionOwnerships List of partition ownerships this instance is requesting to own. * @return Successfully claimed partition ownerships. */ @Override - public Flux claimOwnership(PartitionOwnership... requestedPartitionOwnerships) { - return Flux.fromArray(requestedPartitionOwnerships) + public Flux claimOwnership(List requestedPartitionOwnerships) { + return Flux.fromIterable(requestedPartitionOwnerships) .filter(partitionOwnership -> { return !partitionOwnershipMap.containsKey(partitionOwnership.getPartitionId()) || partitionOwnershipMap.get(partitionOwnership.getPartitionId()).getETag() diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventDataBatch.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventDataBatch.java deleted file mode 100644 index 3fb8f293331e..000000000000 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventDataBatch.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.messaging.eventhubs; - -import com.azure.messaging.eventhubs.models.CreateBatchOptions; -import reactor.core.publisher.Flux; - -import java.util.concurrent.atomic.AtomicReference; - -import static java.nio.charset.StandardCharsets.UTF_8; - -/** - * Sample demonstrates how to send an {@link EventDataBatch} to an Azure Event Hub. - */ -public class PublishEventDataBatch { - /** - * Main method to invoke this demo on how to send an {@link EventDataBatch} to an Azure Event Hub. - * - * @param args Unused arguments to the program. - */ - public static void main(String[] args) { - Flux telemetryEvents = Flux.just( - new EventData("Roast beef".getBytes(UTF_8)), - new EventData("Cheese".getBytes(UTF_8)), - new EventData("Tofu".getBytes(UTF_8)), - new EventData("Turkey".getBytes(UTF_8))); - - // The connection string value can be obtained by: - // 1. Going to your Event Hubs namespace in Azure Portal. - // 2. Creating an Event Hub instance. - // 3. Creating a "Shared access policy" for your Event Hub instance. - // 4. Copying the connection string from the policy's properties. - final String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};" - + "SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}"; - - // Create a producer. - EventHubProducerAsyncClient producer = new EventHubClientBuilder() - .connectionString(connectionString) - .buildAsyncProducerClient(); - - // Creating a batch where we want the events ending up in the same partition by setting the partition key. - final CreateBatchOptions options = new CreateBatchOptions() - .setPartitionKey("sandwiches") - .setMaximumSizeInBytes(256); - final AtomicReference currentBatch = new AtomicReference<>( - producer.createBatch(options).block()); - - // The sample Flux contains three events, but it could be an infinite stream of telemetry events. - telemetryEvents.subscribe(event -> { - final EventDataBatch batch = currentBatch.get(); - if (!batch.tryAdd(event)) { - producer.createBatch(options).map(newBatch -> { - currentBatch.set(newBatch); - return producer.send(batch); - }).block(); - } - }, error -> System.err.println("Error received:" + error), - () -> { - final EventDataBatch batch = currentBatch.getAndSet(null); - if (batch != null) { - producer.send(batch).block(); - } - - // Disposing of our producer. - producer.close(); - }); - } -} diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsToSpecificPartition.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsToSpecificPartition.java index d40335198791..19ef651f105b 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsToSpecificPartition.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsToSpecificPartition.java @@ -3,7 +3,9 @@ package com.azure.messaging.eventhubs; import com.azure.messaging.eventhubs.models.CreateBatchOptions; +import reactor.core.Exceptions; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.time.Duration; import java.util.concurrent.atomic.AtomicReference; @@ -11,14 +13,14 @@ import static java.nio.charset.StandardCharsets.UTF_8; /** - * Sample demonstrates how to sent events to specific event hub by define partition ID in producer option only. + * Sample demonstrates how to sent events to specific event hub by defining partition id using + * {@link CreateBatchOptions#setPartitionId(String)}. */ public class PublishEventsToSpecificPartition { private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); /** - * Main method to invoke this demo about how to send a batch of events with partition ID configured in producer - * option to an Azure Event Hub instance. + * Main method to invoke this demo about how to send a batch of events with partition id configured. * * @param args Unused arguments to the program. */ @@ -50,31 +52,51 @@ public static void main(String[] args) { // Create a batch to send the events. final CreateBatchOptions options = new CreateBatchOptions() - .setPartitionId(firstPartition) - .setMaximumSizeInBytes(256); + .setPartitionId(firstPartition); final AtomicReference currentBatch = new AtomicReference<>( producer.createBatch(options).block()); // We try to add as many events as a batch can fit based on the event size and send to Event Hub when // the batch can hold no more events. Create a new batch for next set of events and repeat until all events // are sent. - data.subscribe(event -> { + final Mono sendOperation = data.flatMap(event -> { final EventDataBatch batch = currentBatch.get(); - if (!batch.tryAdd(event)) { + if (batch.tryAdd(event)) { + return Mono.empty(); + } + + // The batch is full, so we create a new batch and send the batch. Mono.when completes when both operations + // have completed. + return Mono.when( + producer.send(batch), producer.createBatch(options).map(newBatch -> { currentBatch.set(newBatch); - return producer.send(batch); - }).block(); - } - }, error -> System.err.println("Error received:" + error), - () -> { + + // Add that event that we couldn't before. + if (!newBatch.tryAdd(event)) { + throw Exceptions.propagate(new IllegalArgumentException(String.format( + "Event is too large for an empty batch. Max size: %s. Event: %s", + newBatch.getMaxSizeInBytes(), event.getBodyAsString()))); + } + + return newBatch; + })); + }).then() + .doFinally(signal -> { final EventDataBatch batch = currentBatch.getAndSet(null); if (batch != null) { - producer.send(batch).block(); + producer.send(batch).block(OPERATION_TIMEOUT); } - - // Disposing of our producer. - producer.close(); }); + + // The sendOperation creation and assignment is not a blocking call. It does not get invoked until there is a + // subscriber to that operation. For the purpose of this example, we block so the program does not end before + // the send operation is complete. Any of the `.subscribe` overloads also work to start the Mono asynchronously. + try { + sendOperation.block(OPERATION_TIMEOUT); + } finally { + // Disposing of our producer. + producer.close(); + } } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithAzureIdentity.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithAzureIdentity.java new file mode 100644 index 000000000000..c89383280c20 --- /dev/null +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithAzureIdentity.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.messaging.eventhubs; + +import com.azure.core.credential.TokenCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.Exceptions; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.util.concurrent.atomic.AtomicReference; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Sample demonstrates how to send an {@link EventDataBatch} to an Azure Event Hub using Azure Identity. + */ +public class PublishEventsWithAzureIdentity { + private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); + + /** + * Main method to invoke this demo on how to send an {@link EventDataBatch} to an Azure Event Hub. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + Flux telemetryEvents = Flux.just( + new EventData("Roast beef".getBytes(UTF_8)), + new EventData("Cheese".getBytes(UTF_8)), + new EventData("Tofu".getBytes(UTF_8)), + new EventData("Turkey".getBytes(UTF_8))); + + // The default azure credential checks multiple locations for credentials and determines the best one to use. + // For the purpose of this sample, create a service principal and set the following environment variables. + // See https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal for + // information on how to create a service principal. + System.setProperty("AZURE_CLIENT_ID", "<>"); + System.setProperty("AZURE_CLIENT_ID", "<>"); + System.setProperty("AZURE_TENANT_ID", "<>"); + + // DefaultAzureCredentialBuilder exists inside the azure-identity package. + TokenCredential credential = new DefaultAzureCredentialBuilder() + .build(); + + // Create a producer. + // "<>" will look similar to "{your-namespace}.servicebus.windows.net" + // "<>" will be the name of the Event Hub instance you created inside the Event Hubs namespace. + EventHubProducerAsyncClient producer = new EventHubClientBuilder() + .credential( + "<>", + "<>", + credential) + .buildAsyncProducerClient(); + + final AtomicReference currentBatch = new AtomicReference<>( + producer.createBatch().block()); + + // The sample Flux contains three events, but it could be an infinite stream of telemetry events. + final Mono sendOperation = telemetryEvents.flatMap(event -> { + final EventDataBatch batch = currentBatch.get(); + if (batch.tryAdd(event)) { + return Mono.empty(); + } + + // The batch is full, so we create a new batch and send the batch. Mono.when completes when both operations + // have completed. + return Mono.when( + producer.send(batch), + producer.createBatch().map(newBatch -> { + currentBatch.set(newBatch); + + // Add that event that we couldn't before. + if (!newBatch.tryAdd(event)) { + throw Exceptions.propagate(new IllegalArgumentException(String.format( + "Event is too large for an empty batch. Max size: %s. Event: %s", + newBatch.getMaxSizeInBytes(), event.getBodyAsString()))); + } + + return newBatch; + })); + }).then() + .doFinally(signal -> { + final EventDataBatch batch = currentBatch.getAndSet(null); + if (batch != null) { + producer.send(batch).block(OPERATION_TIMEOUT); + } + }); + + // The sendOperation creation and assignment is not a blocking call. It does not get invoked until there is a + // subscriber to that operation. For the purpose of this example, we block so the program does not end before + // the send operation is complete. Any of the `.subscribe` overloads also work to start the Mono asynchronously. + try { + sendOperation.block(OPERATION_TIMEOUT); + } finally { + // Disposing of our producer. + producer.close(); + } + } +} diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithCustomMetadata.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithCustomMetadata.java index fb4e1560b295..3da7d8128637 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithCustomMetadata.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithCustomMetadata.java @@ -2,8 +2,9 @@ // Licensed under the MIT License. package com.azure.messaging.eventhubs; -import com.azure.messaging.eventhubs.models.CreateBatchOptions; +import reactor.core.Exceptions; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.time.Duration; import java.util.concurrent.atomic.AtomicReference; @@ -11,7 +12,9 @@ import static java.nio.charset.StandardCharsets.UTF_8; /** - * Sample demonstrates how to sent events to a specific event hub by defining partition ID in producer option only. + * Sample demonstrates how to sent events with custom metadata to Event Hubs using {@link EventData#getProperties()}. + * Allows the service to load-balance the events between all partitions by using + * {@link EventHubProducerAsyncClient#createBatch()} which uses the default set of create batch options. */ public class PublishEventsWithCustomMetadata { private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); @@ -37,62 +40,68 @@ public static void main(String[] args) { // Because an event consists mainly of an opaque set of bytes, it may be difficult for consumers of those events // to make informed decisions about how to process them. // - // In order to allow event publishers to offer better context for consumers, event data may also contain custom metadata, - // in the form of a set of key/value pairs. This metadata is not used by, or in any way meaningful to, the Event Hubs - // service; it exists only for coordination between event publishers and consumers. + // In order to allow event publishers to offer better context for consumers, event data may also contain custom + // metadata, in the form of a set of key/value pairs. This metadata is not used by, or in any way meaningful to, + // the Event Hubs service; it exists only for coordination between event publishers and consumers. // - // One common scenario for the inclusion of metadata is to provide a hint about the type of data contained by an event, - // so that consumers understand its format and can deserialize it appropriately. - // - // We will publish two events based on simple sentences, but will attach some custom metadata with - // pretend type names and other hints. Note that the set of metadata is unique to an event; there is no need for every - // event in a batch to have the same metadata properties available nor the same data type for those properties. + // One common scenario for the inclusion of metadata is to provide a hint about the type of data contained by an + // event, so that consumers understand its format and can deserialize it appropriately. EventData firstEvent = new EventData("EventData Sample 1".getBytes(UTF_8)); firstEvent.getProperties().put("EventType", "com.microsoft.samples.hello-event"); firstEvent.getProperties().put("priority", 1); firstEvent.getProperties().put("score", 9.0); - EventData secEvent = new EventData("EventData Sample 2".getBytes(UTF_8)); - secEvent.getProperties().put("EventType", "com.microsoft.samples.goodbye-event"); - secEvent.getProperties().put("priority", "17"); - secEvent.getProperties().put("blob", 10); - - final Flux data = Flux.just(firstEvent, secEvent); + EventData secondEvent = new EventData("EventData Sample 2".getBytes(UTF_8)); + secondEvent.getProperties().put("EventType", "com.microsoft.samples.goodbye-event"); + secondEvent.getProperties().put("priority", "17"); + secondEvent.getProperties().put("blob", 10); - // We want to send events to the a specific partition. For the sake of this sample, we take the first partition - // identifier. - // .blockFirst() here is used to synchronously block until the first partition id is emitted. The maximum wait - // time is set by passing in the OPERATION_TIMEOUT value. If no item is emitted before the timeout elapses, a - // TimeoutException is thrown. - String firstPartition = producer.getPartitionIds().blockFirst(OPERATION_TIMEOUT); + final Flux data = Flux.just(firstEvent, secondEvent); - // Create a batch to send the events. - final CreateBatchOptions options = new CreateBatchOptions() - .setPartitionId(firstPartition) - .setMaximumSizeInBytes(256); final AtomicReference currentBatch = new AtomicReference<>( - producer.createBatch(options).block()); + producer.createBatch().block()); // We try to add as many events as a batch can fit based on the event size and send to Event Hub when // the batch can hold no more events. Create a new batch for next set of events and repeat until all events // are sent. - data.subscribe(event -> { + final Mono sendOperation = data.flatMap(event -> { final EventDataBatch batch = currentBatch.get(); - if (!batch.tryAdd(event)) { - producer.createBatch(options).map(newBatch -> { - currentBatch.set(newBatch); - return producer.send(batch); - }).block(); + if (batch.tryAdd(event)) { + return Mono.empty(); } - }, error -> System.err.println("Error received:" + error), - () -> { + + // The batch is full, so we create a new batch and send the batch. Mono.when completes when both operations + // have completed. + return Mono.when( + producer.send(batch), + producer.createBatch().map(newBatch -> { + currentBatch.set(newBatch); + + // Add that event that we couldn't before. + if (!newBatch.tryAdd(event)) { + throw Exceptions.propagate(new IllegalArgumentException(String.format( + "Event is too large for an empty batch. Max size: %s. Event: %s", + newBatch.getMaxSizeInBytes(), event.getBodyAsString()))); + } + + return newBatch; + })); + }).then() + .doFinally(signal -> { final EventDataBatch batch = currentBatch.getAndSet(null); if (batch != null) { - producer.send(batch).block(); + producer.send(batch).block(OPERATION_TIMEOUT); } - - // Disposing of our producer. - producer.close(); }); + + // The sendOperation creation and assignment is not a blocking call. It does not get invoked until there is a + // subscriber to that operation. For the purpose of this example, we block so the program does not end before + // the send operation is complete. Any of the `.subscribe` overloads also work to start the Mono asynchronously. + try { + sendOperation.block(OPERATION_TIMEOUT); + } finally { + // Disposing of our producer. + producer.close(); + } } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithPartitionKey.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithPartitionKey.java index 23918d80a7b7..2496e26e06f3 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithPartitionKey.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithPartitionKey.java @@ -3,20 +3,24 @@ package com.azure.messaging.eventhubs; import com.azure.messaging.eventhubs.models.CreateBatchOptions; +import reactor.core.Exceptions; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import java.time.Duration; import java.util.concurrent.atomic.AtomicReference; import static java.nio.charset.StandardCharsets.UTF_8; /** - * Send a list of events with send option configured + * Send a Flux of events using a partition key. */ public class PublishEventsWithPartitionKey { + private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); /** - * Main method to invoke this demo about how to send a list of events with partition ID configured in send option - * to an Azure Event Hub instance. + * Main method to invoke this demo about how to send a list of events with partition key configured in + * CreateBatchOptions to an Azure Event Hub instance. * * @param args Unused arguments to the program. */ @@ -43,41 +47,63 @@ public static void main(String[] args) { // the Event Hubs service keep different batches of events together on the same partition. This can be // accomplished by setting a partition key when publishing the events. // - // The partition key is NOT the identifier of a specific partition. Rather, it is an arbitrary piece of string data - // that Event Hubs uses as the basis to compute a hash value. Event Hubs will associate the hash value with a specific - // partition, ensuring that any events published with the same partition key are rerouted to the same partition. + // The partition key is NOT the identifier of a specific partition. Rather, it is an arbitrary piece of string + // data that Event Hubs uses as the basis to compute a hash value. Event Hubs will associate the hash value with + // a specific partition, ensuring that any events published with the same partition key are rerouted to the same + // partition. // - // All of event data send to the same partition of the partition key 'basketball' associate with. + // All the event data with partition key 'basketball' end up in the same partition. // - // Note that there is no means of accurately predicting which partition will be associated with a given partition key; - // we can only be assured that it will be a consistent choice of partition. If you have a need to understand which - // exact partition an event is published to, you will need to use an Event Hub producer associated with that partition. + // Note that there is no means of accurately predicting which partition will be associated with a given + // partition key; we can only be assured that it will be a consistent choice of partition. If you have a need to + // understand which exact partition an event is published to, you will need to use + // CreateBatchOptions.setPartitionId(String) when creating the EventDataBatch. final CreateBatchOptions options = new CreateBatchOptions() - .setPartitionKey("basketball") - .setMaximumSizeInBytes(256); + .setPartitionKey("basketball"); final AtomicReference currentBatch = new AtomicReference<>( producer.createBatch(options).block()); // We try to add as many events as a batch can fit based on the event size and send to Event Hub when // the batch can hold no more events. Create a new batch for next set of events and repeat until all events // are sent. - data.subscribe(event -> { + final Mono sendOperation = data.flatMap(event -> { final EventDataBatch batch = currentBatch.get(); - if (!batch.tryAdd(event)) { - producer.createBatch(options).map(newBatch -> { - currentBatch.set(newBatch); - return producer.send(batch); - }).block(); + if (batch.tryAdd(event)) { + return Mono.empty(); } - }, error -> System.err.println("Error received:" + error), - () -> { + + // The batch is full, so we create a new batch and send the batch. Mono.when completes when both operations + // have completed. + return Mono.when( + producer.send(batch), + producer.createBatch().map(newBatch -> { + currentBatch.set(newBatch); + + // Add that event that we couldn't before. + if (!newBatch.tryAdd(event)) { + throw Exceptions.propagate(new IllegalArgumentException(String.format( + "Event is too large for an empty batch. Max size: %s. Event: %s", + newBatch.getMaxSizeInBytes(), event.getBodyAsString()))); + } + + return newBatch; + })); + }).then() + .doFinally(signal -> { final EventDataBatch batch = currentBatch.getAndSet(null); if (batch != null) { - producer.send(batch).block(); + producer.send(batch).block(OPERATION_TIMEOUT); } - - // Disposing of our producer. - producer.close(); }); + + // The sendOperation creation and assignment is not a blocking call. It does not get invoked until there is a + // subscriber to that operation. For the purpose of this example, we block so the program does not end before + // the send operation is complete. Any of the `.subscribe` overloads also work to start the Mono asynchronously. + try { + sendOperation.block(OPERATION_TIMEOUT); + } finally { + // Disposing of our producer. + producer.close(); + } } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithSizeLimitedBatches.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithSizeLimitedBatches.java new file mode 100644 index 000000000000..21544154c737 --- /dev/null +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/PublishEventsWithSizeLimitedBatches.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.eventhubs; + +import com.azure.messaging.eventhubs.models.CreateBatchOptions; +import reactor.core.Exceptions; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.util.concurrent.atomic.AtomicReference; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Demonstrates how to publish events when there is a size constraint on batch size using + * {@link CreateBatchOptions#setMaximumSizeInBytes(int)}. + */ +public class PublishEventsWithSizeLimitedBatches { + private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); + + /** + * Main method to invoke this demo on how to send an {@link EventDataBatch} to an Azure Event Hub. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + Flux telemetryEvents = Flux.just( + new EventData("Roast beef".getBytes(UTF_8)), + new EventData("Cheese".getBytes(UTF_8)), + new EventData("Tofu".getBytes(UTF_8)), + new EventData("Turkey".getBytes(UTF_8))); + + // The connection string value can be obtained by: + // 1. Going to your Event Hubs namespace in Azure Portal. + // 2. Creating an Event Hub instance. + // 3. Creating a "Shared access policy" for your Event Hub instance. + // 4. Copying the connection string from the policy's properties. + String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}"; + + // Instantiate a client that will be used to call the service. + EventHubProducerAsyncClient producer = new EventHubClientBuilder() + .connectionString(connectionString) + .buildAsyncProducerClient(); + + // In cases where developers need to size limit their batch size, they can use `setMaximumSizeInBytes` to limit + // the size of their EventDataBatch. By default, it will be the max size allowed by the underlying link. + // Since there is no partition id or partition key set, the Event Hubs service will automatically load balance + // the events between all available partitions. + final CreateBatchOptions options = new CreateBatchOptions() + .setMaximumSizeInBytes(256); + final AtomicReference currentBatch = new AtomicReference<>( + producer.createBatch(options).block()); + + // The sample Flux contains three events, but it could be an infinite stream of telemetry events. + // We try to add as many events as a batch can fit based on the event size and send to Event Hub when + // the batch can hold no more events. Create a new batch for next set of events and repeat until all events + // are sent. + final Mono sendOperation = telemetryEvents.flatMap(event -> { + final EventDataBatch batch = currentBatch.get(); + if (batch.tryAdd(event)) { + return Mono.empty(); + } + + // The batch is full, so we create a new batch and send the batch. Mono.when completes when both operations + // have completed. + return Mono.when( + producer.send(batch), + producer.createBatch().map(newBatch -> { + currentBatch.set(newBatch); + + // Add that event that we couldn't before. + if (!newBatch.tryAdd(event)) { + throw Exceptions.propagate(new IllegalArgumentException(String.format( + "Event is too large for an empty batch. Max size: %s. Event: %s", + newBatch.getMaxSizeInBytes(), event.getBodyAsString()))); + } + + return newBatch; + })); + }).then() + .doFinally(signal -> { + final EventDataBatch batch = currentBatch.getAndSet(null); + if (batch != null) { + producer.send(batch).block(OPERATION_TIMEOUT); + } + }); + + // The sendOperation creation and assignment is not a blocking call. It does not get invoked until there is a + // subscriber to that operation. For the purpose of this example, we block so the program does not end before + // the send operation is complete. Any of the `.subscribe` overloads also work to start the Mono asynchronously. + try { + sendOperation.block(OPERATION_TIMEOUT); + } finally { + // Disposing of our producer. + producer.close(); + } + } +} + + diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubClientMetadataIntegrationTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubClientMetadataIntegrationTest.java index a039b0a7fa39..0dd3db73b4bc 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubClientMetadataIntegrationTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubClientMetadataIntegrationTest.java @@ -15,9 +15,6 @@ import reactor.core.publisher.Flux; import reactor.test.StepVerifier; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - /** * Tests the metadata operations such as fetching partition properties and event hub properties. */ @@ -104,7 +101,7 @@ public void getPartitionPropertiesMultipleCalls() { * Verifies that error conditions are handled for fetching Event Hub metadata. */ @Test - public void getPartitionPropertiesInvalidToken() throws InvalidKeyException, NoSuchAlgorithmException { + public void getPartitionPropertiesInvalidToken() { // Arrange final ConnectionStringProperties original = getConnectionStringProperties(); final TokenCredential invalidTokenCredential = new EventHubSharedKeyCredential( @@ -130,7 +127,7 @@ public void getPartitionPropertiesInvalidToken() throws InvalidKeyException, NoS * Verifies that error conditions are handled for fetching partition metadata. */ @Test - public void getPartitionPropertiesNonExistentHub() throws InvalidKeyException, NoSuchAlgorithmException { + public void getPartitionPropertiesNonExistentHub() { // Arrange final ConnectionStringProperties original = getConnectionStringProperties(); final TokenCredential validCredentials = new EventHubSharedKeyCredential( diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientIntegrationTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientIntegrationTest.java index 32ada50cd853..de95c04f17e9 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientIntegrationTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientIntegrationTest.java @@ -177,16 +177,20 @@ public void sendWithCredentials() { .buildAsyncProducerClient(); // Act & Assert - StepVerifier.create(client.getEventHubProperties()) - .assertNext(properties -> { - Assertions.assertEquals(getEventHubName(), properties.getName()); - Assertions.assertEquals(2, properties.getPartitionIds().stream().count()); - }) - .expectComplete() - .verify(TIMEOUT); - - StepVerifier.create(client.send(event, options)) - .expectComplete() - .verify(TIMEOUT); + try { + StepVerifier.create(client.getEventHubProperties()) + .assertNext(properties -> { + Assertions.assertEquals(getEventHubName(), properties.getName()); + Assertions.assertEquals(2, properties.getPartitionIds().stream().count()); + }) + .expectComplete() + .verify(TIMEOUT); + + StepVerifier.create(client.send(event, options)) + .expectComplete() + .verify(TIMEOUT); + } finally { + dispose(client); + } } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerClientIntegrationTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerClientIntegrationTest.java index da15f3d36686..4d622d2decf4 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerClientIntegrationTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerClientIntegrationTest.java @@ -140,4 +140,23 @@ public void sendAllPartitions() { producer.send(batch); } } + + /** + * Sending with credentials. + */ + @Test + public void sendWithCredentials() { + // Arrange + final EventData event = new EventData("body"); + final SendOptions options = new SendOptions().setPartitionId(PARTITION_ID); + final EventHubProducerClient client = createBuilder(true) + .buildProducerClient(); + + // Act & Assert + try { + client.send(event, options); + } finally { + dispose(client); + } + } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubPropertiesTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubPropertiesTest.java index c5bee70d1e72..7d9740d18de9 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubPropertiesTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubPropertiesTest.java @@ -36,22 +36,41 @@ public void setsProperties() { } /** - * Verifies that the {@link EventHubProperties#getPartitionIds()} array is not {@code null} when we pass {@code null} - * to the constructor. + * Throws when we try to set null partitionIds. */ @Test - public void setsPropertiesNoPartitions() { + public void requiresPartitions() { // Arrange final String name = "Some-event-hub-name"; final Instant instant = Instant.ofEpochSecond(145620); - // Act - final EventHubProperties eventHubProperties = new EventHubProperties(name, instant, null); + // Act & Assert + Assertions.assertThrows(NullPointerException.class, () -> new EventHubProperties(name, instant, null)); + } - // Assert - Assertions.assertEquals(name, eventHubProperties.getName()); - Assertions.assertEquals(instant, eventHubProperties.getCreatedAt()); - Assertions.assertNotNull(eventHubProperties.getPartitionIds()); - Assertions.assertEquals(0, eventHubProperties.getPartitionIds().stream().count()); + /** + * Throws when we try to set null createdAt. + */ + @Test + public void requiresCreatedAt() { + // Arrange + final String name = "Some-event-hub-name"; + final String[] partitionIds = new String[]{"one-partition", "two-partition", "three-partition"}; + + // Act & Assert + Assertions.assertThrows(NullPointerException.class, () -> new EventHubProperties(name, null, partitionIds)); } + + /** + */ + @Test + public void requiresName() { + // Arrange + final Instant instant = Instant.ofEpochSecond(145620); + final String[] partitionIds = new String[]{"one-partition", "two-partition", "three-partition"}; + + // Act & Assert + Assertions.assertThrows(NullPointerException.class, () -> new EventHubProperties(null, instant, partitionIds)); + } + } 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 63270cb18124..e6f1fc55ec33 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 @@ -21,6 +21,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInfo; import org.mockito.Mockito; +import reactor.core.scheduler.Schedulers; import java.io.Closeable; import java.io.IOException; @@ -159,7 +160,8 @@ protected EventHubClientBuilder createBuilder(boolean useCredentials) { final EventHubClientBuilder builder = new EventHubClientBuilder() .proxyOptions(ProxyOptions.SYSTEM_DEFAULTS) .retry(RETRY_OPTIONS) - .transportType(AmqpTransportType.AMQP); + .transportType(AmqpTransportType.AMQP) + .scheduler(Schedulers.newParallel("eh-integration")); if (useCredentials) { final String fqdn = getFullyQualifiedDomainName(); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancerTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancerTest.java index 233ad8ee2488..eaeb4d322e32 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancerTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/PartitionBasedLoadBalancerTest.java @@ -345,7 +345,8 @@ public void testCheckpointStoreFailure() throws Exception { sleep(5); verify(eventHubAsyncClient, atLeast(1)).getPartitionIds(); verify(eventHubAsyncClient, never()).createConsumer(anyString(), anyInt()); - verify(eventHubConsumer, never()).receiveFromPartition(anyString(), any(EventPosition.class), any(ReceiveOptions.class)); + verify(eventHubConsumer, never()) + .receiveFromPartition(anyString(), any(EventPosition.class), any(ReceiveOptions.class)); verify(partitionProcessor, never()).processEvent(any(EventContext.class)); verify(partitionProcessor, never()).processError(any(ErrorContext.class)); verify(eventHubConsumer, never()).close(); @@ -369,7 +370,8 @@ public void testEventHubClientFailure() { sleep(2); verify(eventHubAsyncClient, atLeast(1)).getPartitionIds(); verify(eventHubAsyncClient, never()).createConsumer(anyString(), anyInt()); - verify(eventHubConsumer, never()).receiveFromPartition(anyString(), any(EventPosition.class), any(ReceiveOptions.class)); + verify(eventHubConsumer, never()) + .receiveFromPartition(anyString(), any(EventPosition.class), any(ReceiveOptions.class)); verify(partitionProcessor, never()).processEvent(any(EventContext.class)); verify(partitionProcessor, never()).processError(any(ErrorContext.class)); verify(eventHubConsumer, never()).close(); @@ -392,7 +394,7 @@ public void testEmptyOwnerId() { .setETag(UUID.randomUUID().toString()) .setLastModifiedTime(System.currentTimeMillis()) .setOwnerId(""); - checkpointStore.claimOwnership(claim1, claim2).subscribe(); + checkpointStore.claimOwnership(Arrays.asList(claim1, claim2)).subscribe(); List partitionIds = Arrays.asList("1", "2", "3"); when(eventHubAsyncClient.getPartitionIds()).thenReturn(Flux.fromIterable(partitionIds)); diff --git a/sdk/eventhubs/microsoft-azure-eventhubs-eph/pom.xml b/sdk/eventhubs/microsoft-azure-eventhubs-eph/pom.xml index a1df513061bd..65b26e9fd0e0 100644 --- a/sdk/eventhubs/microsoft-azure-eventhubs-eph/pom.xml +++ b/sdk/eventhubs/microsoft-azure-eventhubs-eph/pom.xml @@ -7,7 +7,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -40,31 +40,36 @@ com.microsoft.azure azure-storage + 8.0.0 com.google.code.gson gson + 2.8.5 junit junit + 4.13-beta-3 test org.slf4j slf4j-simple + 1.7.25 test com.microsoft.azure msal4j - 0.4.0-preview + 0.4.0-preview test com.microsoft.azure adal4j + 1.6.4 test @@ -76,6 +81,7 @@ org.apache.maven.plugins maven-checkstyle-plugin + 3.1.0 true true diff --git a/sdk/eventhubs/microsoft-azure-eventhubs-extensions/pom.xml b/sdk/eventhubs/microsoft-azure-eventhubs-extensions/pom.xml index 4aeccb792001..60f0acb0fd1c 100644 --- a/sdk/eventhubs/microsoft-azure-eventhubs-extensions/pom.xml +++ b/sdk/eventhubs/microsoft-azure-eventhubs-extensions/pom.xml @@ -7,7 +7,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -40,31 +40,36 @@ org.apache.logging.log4j log4j-api + 2.11.1 org.apache.logging.log4j log4j-core + 2.11.1 junit junit + 4.13-beta-3 test org.slf4j slf4j-simple + 1.7.25 test com.microsoft.azure msal4j - 0.4.0-preview + 0.4.0-preview test com.microsoft.azure adal4j + 1.6.4 test @@ -76,6 +81,7 @@ org.apache.maven.plugins maven-checkstyle-plugin + 3.1.0 true true diff --git a/sdk/eventhubs/microsoft-azure-eventhubs/pom.xml b/sdk/eventhubs/microsoft-azure-eventhubs/pom.xml index fb9ebbfa6e38..a62fc2bb4e8b 100644 --- a/sdk/eventhubs/microsoft-azure-eventhubs/pom.xml +++ b/sdk/eventhubs/microsoft-azure-eventhubs/pom.xml @@ -7,7 +7,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -35,52 +35,60 @@ org.apache.qpid proton-j + 0.33.2 com.microsoft.azure qpid-proton-j-extensions + 1.2.1 org.slf4j slf4j-api + 1.7.28 com.microsoft.azure azure-client-authentication - ${client-runtime.version} + 1.6.15 compile com.nimbusds nimbus-jose-jwt - 6.0.1 + 6.0.1 junit junit + 4.13-beta-3 test org.slf4j slf4j-simple + 1.7.25 test com.microsoft.azure msal4j + 0.5.0-preview test com.microsoft.azure adal4j + 1.6.4 test org.mockito mockito-core + 3.0.0 test @@ -92,6 +100,7 @@ + diff --git a/sdk/identity/azure-identity/pom.xml b/sdk/identity/azure-identity/pom.xml index 932675cc4a0a..e930a9a15b19 100644 --- a/sdk/identity/azure-identity/pom.xml +++ b/sdk/identity/azure-identity/pom.xml @@ -15,7 +15,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -23,48 +23,62 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 + + + org.slf4j + slf4j-api + 1.7.28 com.microsoft.azure msal4j + 0.5.0-preview com.nimbusds oauth2-oidc-sdk + 6.14 org.nanohttpd nanohttpd + 2.3.1 junit junit + 4.13-beta-3 test org.mockito mockito-core + 3.0.0 test org.powermock powermock-module-junit4 + 2.0.2 test org.powermock powermock-api-mockito2 + 2.0.2 test net.java.dev.jna jna-platform + 5.4.0 io.projectreactor reactor-test + 3.3.0.RELEASE test diff --git a/sdk/keyvault/azure-security-keyvault-certificates/pom.xml b/sdk/keyvault/azure-security-keyvault-certificates/pom.xml index 3808a73f0824..f213d4c4228f 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-certificates/pom.xml @@ -6,7 +6,7 @@ azure-client-sdk-parent com.azure - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -36,30 +36,33 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 commons-codec commons-codec + 1.13 junit junit + 4.13-beta-3 test io.projectreactor reactor-test + 3.3.0.RELEASE test diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java deleted file mode 100644 index 802163cc7f08..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -class AzureKeyVaultConfiguration { - //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 - static final String SDK_NAME = "Azure-Keyvault"; - // {x-version-update-start;com.azure:azure-security-keyvault-certificates;current} - static final String SDK_VERSION = "4.0.0-beta.6"; - // {x-version-update-end} -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index 059ac90feab8..92a0afcaf744 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -17,6 +17,7 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.CoreUtils; import com.azure.core.util.Configuration; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import java.net.MalformedURLException; import java.net.URL; @@ -55,8 +56,9 @@ @ServiceClientBuilder(serviceClients = {CertificateClient.class, CertificateAsyncClient.class}) public final class CertificateClientBuilder { private final ClientLogger logger = new ClientLogger(CertificateClientBuilder.class); - + private static final String AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES = "azure-key-vault-certificates.properties"; private final List policies; + private final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -73,6 +75,7 @@ public CertificateClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); + properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES); } /** @@ -108,11 +111,13 @@ public CertificateClient buildClient() { * {@link CertificateClientBuilder#vaultUrl(String)} have not been set. */ public CertificateAsyncClient buildAsyncClient() { - Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : configuration; + Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : + configuration; URL buildEndpoint = getBuildEndpoint(buildConfiguration); if (buildEndpoint == null) { - throw logger.logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); + throw logger.logExceptionAsError(new IllegalStateException( + KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); } CertificateServiceVersion serviceVersion = version != null ? version : CertificateServiceVersion.getLatest(); @@ -121,12 +126,14 @@ public CertificateAsyncClient buildAsyncClient() { } if (credential == null) { - throw logger.logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.CREDENTIALS_REQUIRED))); + throw logger.logExceptionAsError(new IllegalStateException( + KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.CREDENTIALS_REQUIRED))); } // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), + properties.getVersion(), buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties index ffced4746fc3..df9cd43cfcc1 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties @@ -1,2 +1,3 @@ credentials_required=Azure Key Vault credentials are required. vault_endpoint_required=Azure Key Vault endpoint url is required. + diff --git a/sdk/keyvault/azure-security-keyvault-keys/pom.xml b/sdk/keyvault/azure-security-keyvault-keys/pom.xml index 96aac497bdc8..dbc410381df2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-keys/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -36,45 +36,51 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 commons-codec commons-codec + 1.13 org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.hamcrest hamcrest-library + 2.2 test io.projectreactor reactor-test + 3.3.0.RELEASE test diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java index 986fe3c7d0c3..f61dbc7437f9 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java @@ -17,8 +17,8 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; -import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import com.azure.security.keyvault.keys.implementation.KeyVaultCredentialPolicy; import java.net.MalformedURLException; @@ -60,8 +60,10 @@ @ServiceClientBuilder(serviceClients = KeyClient.class) public final class KeyClientBuilder { private final ClientLogger logger = new ClientLogger(KeyClientBuilder.class); + private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private final List policies; + private final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -78,6 +80,7 @@ public KeyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); + properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_KEYS); } /** @@ -136,7 +139,7 @@ public KeyAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), properties.getVersion(), buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java index 5a76313f4fc8..2facc36a5619 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java @@ -16,9 +16,10 @@ import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.http.policy.HttpPolicyProviders; import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.keys.implementation.KeyVaultCredentialPolicy; -import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import com.azure.security.keyvault.keys.models.JsonWebKey; import java.util.ArrayList; @@ -63,7 +64,9 @@ @ServiceClientBuilder(serviceClients = CryptographyClient.class) public final class CryptographyClientBuilder { final List policies; + final UserAgentProperties properties; private final ClientLogger logger = new ClientLogger(CryptographyClientBuilder.class); + private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private TokenCredential credential; private HttpPipeline pipeline; private JsonWebKey jsonWebKey; @@ -81,6 +84,7 @@ public CryptographyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); + properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_KEYS); } /** @@ -153,8 +157,8 @@ HttpPipeline setupPipeline() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, - buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), + properties.getVersion(), buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java deleted file mode 100644 index 46296bf3478b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.keys.implementation; - -public final class AzureKeyVaultConfiguration { - //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 - public static final String SDK_NAME = "Azure-Keyvault"; - // {x-version-update-start;com.azure:azure-security-keyvault-keys;current} - public static final String SDK_VERSION = "4.1.0-beta.1"; - // {x-version-update-end} -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java index fd255870d238..16bcf9b89b7c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java @@ -3,31 +3,29 @@ package com.azure.security.keyvault.keys; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; - -import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.netty.NettyAsyncHttpClientBuilder; -import com.azure.core.http.policy.*; -import com.azure.core.http.rest.Response; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.Response; import com.azure.core.test.TestBase; import com.azure.core.util.Configuration; -import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; -import com.azure.security.keyvault.keys.models.CreateKeyOptions; -import com.azure.security.keyvault.keys.models.KeyVaultKey; import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.keys.models.CreateKeyOptions; import com.azure.security.keyvault.keys.models.KeyType; +import com.azure.security.keyvault.keys.models.KeyVaultKey; import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; -import java.time.Duration; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; @@ -39,11 +37,17 @@ import java.util.function.Consumer; import java.util.function.Function; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + public abstract class KeyClientTestBase extends TestBase { private static final String KEY_NAME = "javaKeyTemp"; private static final KeyType RSA_KEY_TYPE = KeyType.RSA; private static final KeyType EC_KEY_TYPE = KeyType.EC; + private static final String SDK_NAME = "client_name"; + private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -58,22 +62,21 @@ T clientSetup(Function clientBuilder) { ? "http://localhost:8080" : System.getenv("AZURE_KEYVAULT_ENDPOINT"); - TokenCredential credential; + TokenCredential credential = null; - if (interceptorManager.isPlaybackMode()) { - credential = resource -> Mono.just(new AccessToken("Some fake token", OffsetDateTime.now(ZoneOffset.UTC).plus(Duration.ofMinutes(30)))); - } else { + if (!interceptorManager.isPlaybackMode()) { credential = new DefaultAzureCredentialBuilder().build(); } HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), KeyServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), KeyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); - policies.add(new BearerTokenAuthenticationPolicy(credential, KeyAsyncClient.KEY_VAULT_SCOPE)); - policies.addAll(policies); + if (credential != null) { + policies.add(new BearerTokenAuthenticationPolicy(credential, KeyAsyncClient.KEY_VAULT_SCOPE)); + } HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java index 1917a10f96bf..514094cc3229 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java @@ -3,25 +3,24 @@ package com.azure.security.keyvault.keys.cryptography; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; - -import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.netty.NettyAsyncHttpClientBuilder; -import com.azure.core.http.policy.*; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.test.TestBase; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; import java.math.BigInteger; import java.security.InvalidAlgorithmParameterException; @@ -31,13 +30,18 @@ import java.security.spec.KeySpec; import java.security.spec.RSAPrivateCrtKeySpec; import java.security.spec.RSAPublicKeySpec; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + public abstract class CryptographyClientTestBase extends TestBase { @@ -54,7 +58,7 @@ T clientSetup(Function clientBuilder) { ? "http://localhost:8080" : System.getenv("AZURE_KEYVAULT_ENDPOINT"); - TokenCredential credential; + TokenCredential credential = null; HttpClient httpClient; String tenantId = System.getenv("AZURE_TENANT_ID"); @@ -66,9 +70,7 @@ T clientSetup(Function clientBuilder) { assertNotNull(clientSecret); } - if (interceptorManager.isPlaybackMode()) { - credential = resource -> Mono.just(new AccessToken("Some fake token", OffsetDateTime.now(ZoneOffset.UTC).plus(Duration.ofMinutes(30)))); - } else { + if (!interceptorManager.isPlaybackMode()) { credential = new DefaultAzureCredentialBuilder().build(); } @@ -77,8 +79,9 @@ T clientSetup(Function clientBuilder) { policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); - policies.add(new BearerTokenAuthenticationPolicy(credential, CryptographyAsyncClient.KEY_VAULT_SCOPE)); - policies.addAll(policies); + if (credential != null) { + policies.add(new BearerTokenAuthenticationPolicy(credential, CryptographyAsyncClient.KEY_VAULT_SCOPE)); + } HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); diff --git a/sdk/keyvault/azure-security-keyvault-secrets/pom.xml b/sdk/keyvault/azure-security-keyvault-secrets/pom.xml index a935518c817f..17ae014949ab 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/pom.xml +++ b/sdk/keyvault/azure-security-keyvault-secrets/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -34,45 +34,51 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 commons-codec commons-codec + 1.13 org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.junit.jupiter junit-jupiter-params + 5.4.2 test org.hamcrest hamcrest-library + 2.2 test io.projectreactor reactor-test + 3.3.0.RELEASE test diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java deleted file mode 100644 index c3ac3ff8fc93..000000000000 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.secrets; - -class AzureKeyVaultConfiguration { - //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 - static final String SDK_NAME = "Azure-Keyvault"; - // {x-version-update-start;com.azure:azure-security-keyvault-secrets;current} - static final String SDK_VERSION = "4.1.0-beta.1"; - // {x-version-update-end} -} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java index 2cc1c59a4a52..c98d7384f9cc 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java @@ -17,6 +17,7 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.secrets.implementation.KeyVaultCredentialPolicy; @@ -58,8 +59,10 @@ @ServiceClientBuilder(serviceClients = SecretClient.class) public final class SecretClientBuilder { private final ClientLogger logger = new ClientLogger(SecretClientBuilder.class); + private static final String AZURE_KEY_VAULT_SECRETS = "azure-key-vault-secrets.properties"; private final List policies; + final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -76,6 +79,7 @@ public SecretClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); + properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_SECRETS); } /** @@ -137,8 +141,8 @@ public SecretAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, - buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), + properties.getVersion(), buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties b/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java index a935f94146a0..1af14cd26fe1 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java @@ -3,11 +3,6 @@ package com.azure.security.keyvault.secrets; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; - -import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpClient; @@ -28,7 +23,8 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.security.keyvault.secrets.models.KeyVaultSecret; import com.azure.security.keyvault.secrets.models.SecretProperties; -import java.time.Duration; +import org.junit.jupiter.api.Test; + import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; @@ -39,14 +35,19 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; public abstract class SecretClientTestBase extends TestBase { private static final String SECRET_NAME = "javaSecretTemp"; private static final String SECRET_VALUE = "Chocolate is hidden in the toothpaste cabinet"; + private static final String SDK_NAME = "client_name"; + private static final String SDK_VERSION = "client_version"; + @Override protected String getTestName() { return ""; @@ -56,22 +57,21 @@ void beforeTestSetup() { } T clientSetup(Function clientBuilder) { - TokenCredential credential; + TokenCredential credential = null; - if (interceptorManager.isPlaybackMode()) { - credential = resource -> Mono.just(new AccessToken("Some fake token", OffsetDateTime.now(ZoneOffset.UTC).plus(Duration.ofMinutes(30)))); - } else { + if (!interceptorManager.isPlaybackMode()) { credential = new DefaultAzureCredentialBuilder().build(); } HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), SecretServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), SecretServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); - policies.add(new BearerTokenAuthenticationPolicy(credential, SecretAsyncClient.KEY_VAULT_SCOPE)); - policies.addAll(policies); + if (credential != null) { + policies.add(new BearerTokenAuthenticationPolicy(credential, SecretAsyncClient.KEY_VAULT_SCOPE)); + } HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); diff --git a/sdk/keyvault/microsoft-azure-keyvault-complete/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-complete/pom.xml index fc73c573340d..0b45b1de807e 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-complete/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-complete/pom.xml @@ -7,7 +7,7 @@ the MIT License. See License.txt in the project root for license information. -- com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml diff --git a/sdk/keyvault/microsoft-azure-keyvault-core/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-core/pom.xml index a0cb7e38410f..f1796827a667 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-core/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-core/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -40,10 +40,12 @@ org.apache.commons commons-lang3 + 3.8.1 com.google.guava guava + 24.1.1-jre @@ -52,6 +54,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -65,6 +68,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 diff --git a/sdk/keyvault/microsoft-azure-keyvault-cryptography/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-cryptography/pom.xml index b872a5384eff..070940200186 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-cryptography/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-cryptography/pom.xml @@ -7,7 +7,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -53,20 +53,24 @@ com.fasterxml.jackson.core jackson-databind + 2.10.0 org.apache.commons commons-lang3 + 3.8.1 commons-codec commons-codec + 1.13 com.google.guava guava + 24.1.1-jre @@ -74,11 +78,13 @@ junit junit + 4.13-beta-3 test org.bouncycastle bcprov-jdk15on + 1.60 test @@ -88,6 +94,7 @@ org.apache.maven.plugins maven-resources-plugin + 2.4.3 ${basedir}/target/test-classes diff --git a/sdk/keyvault/microsoft-azure-keyvault-extensions/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-extensions/pom.xml index cb46c7477604..63eaf2a7c36a 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-extensions/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -63,26 +63,31 @@ com.microsoft.azure azure-mgmt-resources + 1.3.0 com.microsoft.rest client-runtime + 1.6.15 com.google.guava guava + 24.1.1-jre org.apache.commons commons-lang3 + 3.8.1 commons-codec commons-codec + 1.13 @@ -91,12 +96,14 @@ com.microsoft.azure azure-mgmt-resources + 1.3.1-SNAPSHOT test-jar test com.microsoft.azure adal4j + 1.6.4 test @@ -104,17 +111,19 @@ junit junit + 4.13-beta-3 test org.bouncycastle bcprov-jdk15on + 1.60 test org.mockito mockito-core - 1.10.19 + 1.10.19 test @@ -124,6 +133,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -136,6 +146,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 diff --git a/sdk/keyvault/microsoft-azure-keyvault-test/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-test/pom.xml index 5690465309e3..5186a53eeb2c 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-test/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-test/pom.xml @@ -6,7 +6,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -34,6 +34,7 @@ junit junit + 4.13-beta-3 test @@ -57,41 +58,44 @@ com.microsoft.azure azure-mgmt-storage - 1.3.0 + 1.3.0 test com.microsoft.azure azure-mgmt-graph-rbac - 1.3.0 + 1.3.0 test com.microsoft.azure azure-mgmt-resources + 1.3.0 test com.microsoft.azure azure-mgmt-keyvault + 1.11.1 test com.microsoft.azure azure-mgmt-resources - 1.3.1-SNAPSHOT + 1.3.1-SNAPSHOT test-jar test com.microsoft.azure adal4j + 1.6.4 test com.microsoft.azure azure-storage - 4.4.0 + 4.4.0 test diff --git a/sdk/keyvault/microsoft-azure-keyvault-webkey/pom.xml b/sdk/keyvault/microsoft-azure-keyvault-webkey/pom.xml index ee6f3eb9d658..0edfb8039bc8 100644 --- a/sdk/keyvault/microsoft-azure-keyvault-webkey/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault-webkey/pom.xml @@ -6,7 +6,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -39,30 +39,36 @@ com.fasterxml.jackson.core jackson-databind + 2.10.0 com.fasterxml.jackson.core jackson-core + 2.10.0 com.fasterxml.jackson.core jackson-annotations + 2.10.0 commons-codec commons-codec + 1.13 com.google.guava guava + 24.1.1-jre junit junit + 4.13-beta-3 test @@ -73,6 +79,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -85,6 +92,7 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 diff --git a/sdk/keyvault/microsoft-azure-keyvault/pom.xml b/sdk/keyvault/microsoft-azure-keyvault/pom.xml index 02cf7e08550c..0ea71fa8c16d 100644 --- a/sdk/keyvault/microsoft-azure-keyvault/pom.xml +++ b/sdk/keyvault/microsoft-azure-keyvault/pom.xml @@ -6,7 +6,7 @@ the MIT License. See License.txt in the project root for license information. -- com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -56,12 +56,14 @@ the MIT License. See License.txt in the project root for license information. -- com.microsoft.azure azure-client-runtime + 1.6.15 com.microsoft.rest client-runtime + 1.6.15 @@ -69,24 +71,28 @@ the MIT License. See License.txt in the project root for license information. -- com.microsoft.azure azure-mgmt-storage + 1.3.0 test com.microsoft.azure azure-mgmt-graph-rbac + 1.3.0 test com.microsoft.azure azure-mgmt-resources + 1.3.0 test com.microsoft.azure azure-mgmt-keyvault + 1.11.1 test @@ -99,6 +105,7 @@ the MIT License. See License.txt in the project root for license information. -- com.microsoft.azure azure-mgmt-resources + 1.3.1-SNAPSHOT test-jar test @@ -106,12 +113,14 @@ the MIT License. See License.txt in the project root for license information. -- com.microsoft.azure adal4j + 1.6.4 test com.microsoft.azure azure-storage + 8.0.0 test @@ -120,12 +129,14 @@ the MIT License. See License.txt in the project root for license information. -- com.microsoft.azure azure-client-authentication + 1.6.15 test junit junit + 4.13-beta-3 test @@ -137,6 +148,7 @@ the MIT License. See License.txt in the project root for license information. -- org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -150,11 +162,13 @@ the MIT License. See License.txt in the project root for license information. -- org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-failsafe-plugin + 2.22.0 ${basedir}/azure-keyvault/target/azure-keyvault-${project.version}.jar diff --git a/sdk/loganalytics/microsoft-azure-loganalytics/pom.xml b/sdk/loganalytics/microsoft-azure-loganalytics/pom.xml index 6e766ab17b8b..3608cbd58053 100644 --- a/sdk/loganalytics/microsoft-azure-loganalytics/pom.xml +++ b/sdk/loganalytics/microsoft-azure-loganalytics/pom.xml @@ -17,7 +17,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml https://github.com/Azure/azure-sdk-for-java @@ -49,31 +49,31 @@ com.microsoft.azure azure-client-runtime - ${runtime.version} + 1.6.3 junit junit - 4.12 + 4.13-beta-3 test com.microsoft.azure azure-client-authentication - ${runtime.version} + 1.6.3 test com.microsoft.azure azure-arm-client-runtime - ${runtime.version} + 1.6.3 test-jar test com.microsoft.azure azure-arm-client-runtime - ${runtime.version} + 1.6.3 @@ -81,7 +81,7 @@ org.codehaus.mojo properties-maven-plugin - 1.0.0 + 1.0.0 generate-resources @@ -99,6 +99,7 @@ org.apache.maven.plugins maven-jar-plugin + 3.1.2 @@ -111,11 +112,12 @@ org.codehaus.mojo build-helper-maven-plugin + 3.0.0 org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 1.7 1.7 @@ -135,7 +137,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search @@ -152,7 +154,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20 + 3.0.0-M3 false diff --git a/sdk/mediaservices/microsoft-azure-media/pom.xml b/sdk/mediaservices/microsoft-azure-media/pom.xml index 5e3907c1c30e..04ada0bebb62 100644 --- a/sdk/mediaservices/microsoft-azure-media/pom.xml +++ b/sdk/mediaservices/microsoft-azure-media/pom.xml @@ -25,7 +25,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -62,88 +62,92 @@ com.microsoft.azure azure-core - 0.9.8 + 0.9.8 com.microsoft.azure adal4j - 1.2.0 + 1.2.0 org.apache.httpcomponents httpclient - 4.3.6 + 4.3.6 javax.xml.bind jaxb-api - 2.2.7 + 2.2.7 provided javax.mail mail - 1.4.5 + 1.4.5 javax.inject javax.inject - 1 + 1 com.sun.jersey jersey-client - 1.19 + 1.19 com.sun.jersey jersey-json - 1.19 + 1.19 commons-logging commons-logging - 1.1.1 + 1.1.1 com.fasterxml.jackson.core jackson-databind + 2.10.0 com.fasterxml.jackson.core jackson-annotations + 2.10.0 com.fasterxml.jackson.core jackson-core + 2.10.0 io.jsonwebtoken jjwt - 0.5.1 + 0.5.1 org.hamcrest hamcrest-all - 1.3 + 1.3 test org.mockito mockito-all - 1.9.0 + 1.9.0 test junit junit - 4.12 + 4.13-beta-3 test org.bouncycastle bcprov-jdk15on + 1.60 test @@ -153,7 +157,7 @@ org.apache.maven.plugins maven-help-plugin - 2.1.1 + 2.1.1 validate @@ -170,7 +174,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 1.6 1.6 @@ -180,7 +184,7 @@ org.apache.maven.plugins maven-javadoc-plugin - + 3.1.1 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage /** diff --git a/sdk/servicebus/microsoft-azure-servicebus/pom.xml b/sdk/servicebus/microsoft-azure-servicebus/pom.xml index 246f05fa9c68..2c1636637842 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/pom.xml +++ b/sdk/servicebus/microsoft-azure-servicebus/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.microsoft.azure azure-servicebus - 3.1.3 + 3.1.4 Microsoft Azure SDK for Service Bus Java library for Azure Service Bus @@ -15,7 +15,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -45,6 +45,7 @@ org.apache.maven.plugins maven-surefire-plugin + 3.0.0-M3 15 true @@ -57,28 +58,33 @@ org.apache.qpid proton-j + 0.33.2 com.microsoft.azure qpid-proton-j-extensions + 1.2.1 org.slf4j slf4j-api + 1.7.28 org.asynchttpclient async-http-client + 2.10.4 com.microsoft.azure azure-client-authentication - 1.6.7 + 1.6.7 compile junit junit + 4.13-beta-3 test diff --git a/sdk/storage/azure-storage-blob-batch/pom.xml b/sdk/storage/azure-storage-blob-batch/pom.xml index 213d54283bb6..aba14e520dcc 100644 --- a/sdk/storage/azure-storage-blob-batch/pom.xml +++ b/sdk/storage/azure-storage-blob-batch/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -55,12 +55,12 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 com.azure @@ -70,6 +70,7 @@ org.slf4j slf4j-api + 1.7.28 provided @@ -97,26 +98,31 @@ org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test com.microsoft.azure adal4j + 1.6.4 test org.spockframework spock-core + 1.3-groovy-2.5 test cglib cglib-nodep + 3.2.7 test @@ -142,7 +148,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -185,19 +191,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -214,6 +220,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -246,12 +253,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -259,7 +266,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-blob-cryptography/pom.xml b/sdk/storage/azure-storage-blob-cryptography/pom.xml index 0a03c4606cd4..53a9b828840d 100644 --- a/sdk/storage/azure-storage-blob-cryptography/pom.xml +++ b/sdk/storage/azure-storage-blob-cryptography/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -47,18 +47,20 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test org.slf4j slf4j-simple + 1.7.25 test org.spockframework spock-core + 1.3-groovy-2.5 test @@ -66,14 +68,26 @@ cross platform compatibility within SDKs --> com.microsoft.azure azure-storage - 8.4.0 + 8.4.0 test + + + com.fasterxml.jackson.core + jackson-core + + com.microsoft.azure azure-keyvault-cryptography - 1.2.2 + 1.2.2 test + + + com.fasterxml.jackson.core + jackson-core + + com.azure @@ -84,6 +98,7 @@ + @@ -99,7 +114,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -142,19 +157,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -171,6 +186,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -203,12 +219,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -216,7 +232,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml index 40d4889566f2..34558cf48cf6 100644 --- a/sdk/storage/azure-storage-blob/pom.xml +++ b/sdk/storage/azure-storage-blob/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -55,7 +55,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -65,6 +65,7 @@ org.slf4j slf4j-api + 1.7.28 provided @@ -86,7 +87,7 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test @@ -98,26 +99,31 @@ org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test com.microsoft.azure adal4j + 1.6.4 test org.spockframework spock-core + 1.3-groovy-2.5 test cglib cglib-nodep + 3.2.7 test @@ -143,7 +149,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -186,19 +192,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -215,6 +221,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -247,12 +254,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -260,7 +267,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-common/pom.xml b/sdk/storage/azure-storage-common/pom.xml index 877b3b1fd4a3..c73af5bdb5ef 100644 --- a/sdk/storage/azure-storage-common/pom.xml +++ b/sdk/storage/azure-storage-common/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -36,16 +36,17 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 org.slf4j slf4j-api + 1.7.28 com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 provided @@ -73,21 +74,25 @@ org.junit.jupiter junit-jupiter-api + 5.4.2 test org.junit.jupiter junit-jupiter-engine + 5.4.2 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test diff --git a/sdk/storage/azure-storage-file-datalake/pom.xml b/sdk/storage/azure-storage-file-datalake/pom.xml index c1623ec83f27..f13cef9f9e09 100644 --- a/sdk/storage/azure-storage-file-datalake/pom.xml +++ b/sdk/storage/azure-storage-file-datalake/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -60,7 +60,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 provided @@ -82,22 +82,25 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test org.spockframework spock-core + 1.3-groovy-2.5 test @@ -130,7 +133,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -175,12 +178,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -188,7 +191,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -205,6 +208,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -239,12 +243,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -252,7 +256,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-file-share/pom.xml b/sdk/storage/azure-storage-file-share/pom.xml index a5a70febacb8..ead8c86b6a3d 100644 --- a/sdk/storage/azure-storage-file-share/pom.xml +++ b/sdk/storage/azure-storage-file-share/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -40,7 +40,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -54,7 +54,7 @@ com.google.code.findbugs jsr305 - 3.0.2 + 3.0.2 provided @@ -67,22 +67,25 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test org.slf4j slf4j-simple + 1.7.25 test io.projectreactor reactor-test + 3.3.0.RELEASE test org.spockframework spock-core + 1.3-groovy-2.5 test @@ -98,7 +101,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -141,19 +144,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -170,6 +173,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -202,12 +206,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -215,7 +219,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/azure-storage-queue-cryptography/pom.xml b/sdk/storage/azure-storage-queue-cryptography/pom.xml index d11ef0fbbd9c..c593db9afdfc 100644 --- a/sdk/storage/azure-storage-queue-cryptography/pom.xml +++ b/sdk/storage/azure-storage-queue-cryptography/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -47,23 +47,26 @@ - + + + + @@ -79,7 +82,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -122,19 +125,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -183,12 +186,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -196,7 +199,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 diff --git a/sdk/storage/azure-storage-queue/pom.xml b/sdk/storage/azure-storage-queue/pom.xml index fca79b266237..dc775c0e4127 100644 --- a/sdk/storage/azure-storage-queue/pom.xml +++ b/sdk/storage/azure-storage-queue/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -36,7 +36,7 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 com.azure @@ -52,23 +52,26 @@ com.azure azure-core-http-netty - 1.1.0-beta.1 + 1.1.0 test org.slf4j slf4j-simple + 1.7.25 test org.spockframework spock-core + 1.3-groovy-2.5 test io.projectreactor reactor-test + 3.3.0.RELEASE test @@ -90,7 +93,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + 3.8.1 1.8 1.8 @@ -133,19 +136,19 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 @@ -162,6 +165,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 9 9 @@ -194,12 +198,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 @@ -207,7 +211,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} + 3.0.0-M3 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED diff --git a/sdk/storage/microsoft-azure-storage-blob/pom.xml b/sdk/storage/microsoft-azure-storage-blob/pom.xml index 753c9e9e0b74..465d129a053d 100644 --- a/sdk/storage/microsoft-azure-storage-blob/pom.xml +++ b/sdk/storage/microsoft-azure-storage-blob/pom.xml @@ -9,7 +9,7 @@ com.azure azure-data-sdk-parent - 1.2.0 + 1.3.0 ../../../pom.data.xml @@ -50,40 +50,47 @@ com.microsoft.rest.v2 client-runtime + 2.1.1 org.slf4j slf4j-api + 1.7.28 com.microsoft.azure adal4j + 1.6.4 test junit junit + 4.13-beta-3 test org.spockframework spock-core + 1.3-groovy-2.5 test cglib cglib-nodep + 3.2.7 test uk.org.lidalia slf4j-test + 1.2.0 test @@ -97,6 +104,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.8.1 groovy-eclipse-compiler -Xlint:unchecked @@ -108,12 +116,12 @@ org.codehaus.groovy groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} + 3.4.0-01 org.codehaus.groovy groovy-eclipse-batch - ${groovy-eclipse-batch.version} + 2.5.8-01 diff --git a/sdk/template/azure-sdk-template/pom.xml b/sdk/template/azure-sdk-template/pom.xml index e98c1f4dfe3a..d61131d1e5f9 100644 --- a/sdk/template/azure-sdk-template/pom.xml +++ b/sdk/template/azure-sdk-template/pom.xml @@ -5,7 +5,7 @@ com.azure azure-client-sdk-parent - 1.6.0 + 1.7.0 ../../../pom.client.xml @@ -31,11 +31,12 @@ com.azure azure-core - 1.1.0-beta.1 + 1.1.0 junit junit + 4.13-beta-3 test From cd06b80d3b983033abc4b05d85dd9f45e22e5731 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Tue, 26 Nov 2019 12:15:01 -0800 Subject: [PATCH 2/8] More changes comming in --- eng/versioning/version_client_java_files.txt | 1 - .../src/main/java/com/azure/core/util/CoreUtils.java | 8 +++++++- .../java/com/azure/core/util/CoreUtilsTests.java | 6 ++++-- .../cryptography/CryptographyClientTestBase.java | 4 +++- .../cryptography/BlobCryptographyConfiguration.java | 10 ---------- .../blob/implementation/util/BuilderHelper.java | 12 ++++++------ .../src/main/resources/azure-storage-blob.properties | 2 ++ 7 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java create mode 100644 sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties diff --git a/eng/versioning/version_client_java_files.txt b/eng/versioning/version_client_java_files.txt index d0756c071b03..0d0d5a87f077 100644 --- a/eng/versioning/version_client_java_files.txt +++ b/eng/versioning/version_client_java_files.txt @@ -4,7 +4,6 @@ # The file format here should be the relative path from the root of the azure-sdk-for-java sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ClientConstants.java -sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java index d196e3147fb6..4aeb103b9656 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java @@ -176,7 +176,13 @@ public static UserAgentProperties getUserAgentPropertiesFromProperties(String pr return new UserAgentProperties(name, version); } - private static Map getProperties(String propertiesFileName) { + /** + * Helper method that returns an immutable {@link Map} of properties defined in {@code propertiesFileName}. + * + * @param propertiesFileName The file name defining the properties. + * @return an immutable {@link Map}. + */ + public static Map getProperties(String propertiesFileName) { ClientLogger logger = new ClientLogger(CoreUtils.class); try (InputStream inputStream = CoreUtils.class.getClassLoader() .getResourceAsStream(propertiesFileName)) { diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java index d4226e690ea8..52bfd84a518c 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java @@ -3,6 +3,7 @@ package com.azure.core.util; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -40,8 +41,9 @@ public void findFirstOfTypeWithNoneOfType() { @Test public void testProperties() { - assertNotNull(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getVersion()); - assertNotNull(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getName()); + UserAgentProperties properties = + CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties"); + assertFalse(properties.getName().matches("UnknownName")); assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getVersion() .matches("\\d.\\d.\\d([-a-zA-Z0-9.])*")); } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java index 514094cc3229..7aef1f6c4f36 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java @@ -44,6 +44,8 @@ public abstract class CryptographyClientTestBase extends TestBase { + private static final String SDK_NAME = "client_name"; + private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -76,7 +78,7 @@ T clientSetup(Function clientBuilder) { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); if (credential != null) { diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java deleted file mode 100644 index a3da06f8229a..000000000000 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.storage.blob.specialized.cryptography; - -class BlobCryptographyConfiguration { - static final String NAME = "azure-storage-blob-cryptography"; - // {x-version-update-start;com.azure:azure-storage-blob-cryptography;current} - static final String VERSION = "12.1.0-beta.1"; - // {x-version-update-end} -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java index a24017b92622..8efaa6c65c53 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java @@ -16,6 +16,8 @@ import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.blob.BlobUrlParts; import com.azure.storage.common.StorageSharedKeyCredential; @@ -37,10 +39,8 @@ * RESERVED FOR INTERNAL USE. */ public final class BuilderHelper { - private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-blob"; - // {x-version-update-start;com.azure:azure-storage-blob;current} - private static final String DEFAULT_USER_AGENT_VERSION = "12.1.0-beta.1"; - // {x-version-update-end} + private static final UserAgentProperties PROPERTIES = + CoreUtils.getUserAgentPropertiesFromProperties(""); /** * Constructs a {@link HttpPipeline} from values passed from a builder. @@ -153,8 +153,8 @@ public static void httpsValidation(Object objectToCheck, String objectName, Stri private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; - return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), DEFAULT_USER_AGENT_NAME, - DEFAULT_USER_AGENT_VERSION, configuration); + return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), PROPERTIES.getName(), + PROPERTIES.getVersion(), configuration); } /* diff --git a/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties b/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} From a0dfff8fffd12baa511e1d197458c517ecf79417 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 27 Nov 2019 11:30:11 -0800 Subject: [PATCH 3/8] Fixed the failed tests and linting issue --- eng/versioning/version_client_java_files.txt | 5 ----- .../appconfiguration/ConfigurationClient.java | 2 +- .../ConfigurationClientBuilder.java | 3 +-- .../java/com/azure/core/util/CoreUtils.java | 2 +- .../com/azure/core/util/CoreUtilsTests.java | 9 ++++---- .../azure-messaging-eventhubs.properties | 2 ++ .../CertificateClientBuilder.java | 2 +- .../keyvault/keys/KeyClientBuilder.java | 2 +- .../CryptographyClientBuilder.java | 2 +- .../KeyVaultKeysUserAgentPropertiesTest.java | 18 ++++++++++++++++ .../keyvault/secrets/SecretClientBuilder.java | 2 +- ...eyVaultSecretsUserAgentPropertiesTest.java | 18 ++++++++++++++++ .../cryptography/CryptographyConstants.java | 21 ++++++++++++++++++- .../EncryptedBlobClientBuilder.java | 9 ++++---- ...CryptographyUserAgentPropertiesTest.groovy | 17 +++++++++++++++ .../implementation/util/BuilderHelper.java | 2 +- .../blob/BlobUserAgentPropertiesTest.groovy | 17 +++++++++++++++ .../storage/file/share/FileConfiguration.java | 15 ------------- .../implementation/util/BuilderHelper.java | 9 ++++---- .../azure-storage-file-share.properties | 2 ++ .../FileShareUserAgentPropertiesTest.groovy | 17 +++++++++++++++ .../storage/queue/QueueConfiguration.java | 15 ------------- .../implementation/util/BuilderHelper.java | 9 ++++---- .../resources/azure-storage-queue.properties | 2 ++ .../queue/QueueUserAgentPropertiesTest.groovy | 17 +++++++++++++++ 25 files changed, 155 insertions(+), 64 deletions(-) create mode 100644 sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties create mode 100644 sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java create mode 100644 sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java create mode 100644 sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy create mode 100644 sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties create mode 100644 sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy delete mode 100644 sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java create mode 100644 sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties create mode 100644 sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy diff --git a/eng/versioning/version_client_java_files.txt b/eng/versioning/version_client_java_files.txt index 0d0d5a87f077..9f2721aa11ba 100644 --- a/eng/versioning/version_client_java_files.txt +++ b/eng/versioning/version_client_java_files.txt @@ -4,8 +4,3 @@ # The file format here should be the relative path from the root of the azure-sdk-for-java sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ClientConstants.java -sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java -sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java -sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java -sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java -sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java index d3a3a8b58bbf..cc68fd2e2aa2 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java @@ -334,7 +334,7 @@ public ConfigurationSetting setReadOnly(String key, String label, boolean isRead * *

Set the setting to read-only with the key-label "prodDBConnection"-"westUS".

* - * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-boolean-Context} + * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-Boolean-Context} * *

Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".

* diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java index d8d5a5a11096..ba00b7d27031 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java @@ -35,7 +35,6 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; /** @@ -103,7 +102,7 @@ public ConfigurationClientBuilder() { policies = new ArrayList<>(); httpLogOptions = new HttpLogOptions(); - properties = CoreUtils.getUserAgentPropertiesFromProperties(APP_CONFIG_PROPERTIES); + properties = CoreUtils.getUserAgentProperties(APP_CONFIG_PROPERTIES); headers = new HttpHeaders() .put(ECHO_REQUEST_ID_HEADER, "true") diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java index 4aeb103b9656..57873eec8f22 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java @@ -169,7 +169,7 @@ public static Publisher extractAndFetch(PagedResponse page, Context co * @param propertiesFileName The file name defining the properties. * @return {@link UserAgentProperties}. */ - public static UserAgentProperties getUserAgentPropertiesFromProperties(String propertiesFileName) { + public static UserAgentProperties getUserAgentProperties(String propertiesFileName) { Map propertyMap = getProperties(propertiesFileName); String name = propertyMap.getOrDefault(NAME, "UnknownName"); String version = propertyMap.getOrDefault(VERSION, "UnknownVersion"); diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java index 52bfd84a518c..9842599eb15a 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java @@ -4,7 +4,6 @@ package com.azure.core.util; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -42,17 +41,17 @@ public void findFirstOfTypeWithNoneOfType() { @Test public void testProperties() { UserAgentProperties properties = - CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties"); + CoreUtils.getUserAgentProperties("azure-core.properties"); assertFalse(properties.getName().matches("UnknownName")); - assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("azure-core.properties").getVersion() + assertTrue(CoreUtils.getUserAgentProperties("azure-core.properties").getVersion() .matches("\\d.\\d.\\d([-a-zA-Z0-9.])*")); } @Test public void testMissingProperties() { - assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("foo.properties") + assertTrue(CoreUtils.getUserAgentProperties("foo.properties") .getVersion().matches("UnknownVersion")); - assertTrue(CoreUtils.getUserAgentPropertiesFromProperties("foo.properties") + assertTrue(CoreUtils.getUserAgentProperties("foo.properties") .getName().matches("UnknownName")); } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties b/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index 92a0afcaf744..34f39ae19c92 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -75,7 +75,7 @@ public CertificateClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES); + properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES); } /** diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java index f61dbc7437f9..51c08562fe5a 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java @@ -80,7 +80,7 @@ public KeyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_KEYS); + properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_KEYS); } /** diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java index 2facc36a5619..a176d8f8afd1 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java @@ -84,7 +84,7 @@ public CryptographyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_KEYS); + properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_KEYS); } /** diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java new file mode 100644 index 000000000000..80f77b0205c3 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java @@ -0,0 +1,18 @@ +package com.azure.security.keyvault.keys; + +import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class KeyVaultKeysUserAgentPropertiesTest { + + @Test + public void testAzureConfiguration() { + UserAgentProperties properties = CoreUtils.getUserAgentProperties("azure-key-vault-keys.properties"); + assertFalse(properties.getName().matches("UnknownName")); + assertTrue(properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); + } +} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java index c98d7384f9cc..6a5b1d94b96b 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java @@ -79,7 +79,7 @@ public SecretClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentPropertiesFromProperties(AZURE_KEY_VAULT_SECRETS); + properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_SECRETS); } /** diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java new file mode 100644 index 000000000000..86525a08c7a5 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java @@ -0,0 +1,18 @@ +package com.azure.security.keyvault.secrets; + +import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class KeyVaultSecretsUserAgentPropertiesTest { + + @Test + public void testAzureConfiguration() { + UserAgentProperties properties = CoreUtils.getUserAgentProperties("azure-key-vault-secrets.properties"); + assertFalse(properties.getName().matches("UnknownName")); + assertTrue(properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); + } +} diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java index b6dd0dce1187..d98965e7ecf3 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java @@ -4,6 +4,9 @@ package com.azure.storage.blob.specialized.cryptography; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; + final class CryptographyConstants { static final String ENCRYPTION_PROTOCOL_V1 = "1.0"; @@ -15,7 +18,13 @@ final class CryptographyConstants { static final String AES = "AES"; - static final String AGENT_METADATA_VALUE = "JavaTrack2" + BlobCryptographyConfiguration.VERSION; + static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; + + static final String BLOB_CRYPTOGRAPHY_NAME = getName(); + + static final String BLOB_CRYPTOGRAPHY_VERSION = getVersion(); + + static final String AGENT_METADATA_VALUE = "JavaTrack2" + BLOB_CRYPTOGRAPHY_VERSION; static final String ENCRYPTION_DATA_KEY = "encryptiondata"; @@ -36,4 +45,14 @@ final class CryptographyConstants { private CryptographyConstants() { } + + private static String getName() { + UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); + return properties.getName(); + } + + private static String getVersion() { + UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); + return properties.getVersion(); + } } diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java index c2a6cb419d90..efa738f98367 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java @@ -45,6 +45,9 @@ import java.util.List; import java.util.Objects; +import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.BLOB_CRYPTOGRAPHY_NAME; +import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.BLOB_CRYPTOGRAPHY_VERSION; + /** * This class provides a fluent builder API to help aid the configuration and instantiation of Storage Blob clients. * @@ -151,16 +154,14 @@ private HttpPipeline getHttpPipeline() { return httpPipeline; } - String userAgentName = BlobCryptographyConfiguration.NAME; - String userAgentVersion = BlobCryptographyConfiguration.VERSION; Configuration userAgentConfiguration = (configuration == null) ? Configuration.NONE : configuration; // Closest to API goes first, closest to wire goes last. List policies = new ArrayList<>(); policies.add(new BlobDecryptionPolicy(keyWrapper, keyResolver)); - policies.add(new UserAgentPolicy(logOptions.getApplicationId(), userAgentName, userAgentVersion, - userAgentConfiguration)); + policies.add(new UserAgentPolicy(logOptions.getApplicationId(), BLOB_CRYPTOGRAPHY_NAME, + BLOB_CRYPTOGRAPHY_VERSION, userAgentConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddDatePolicy()); diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy new file mode 100644 index 000000000000..2e21e644f1f8 --- /dev/null +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy @@ -0,0 +1,17 @@ +package com.azure.storage.blob.specialized.cryptography + +import com.azure.core.util.CoreUtils +import com.azure.core.util.UserAgentProperties +import spock.lang.Specification + +class BlobCryptographyUserAgentPropertiesTest extends Specification { + + def "User agent properties not null"() { + given: + UserAgentProperties properties = CoreUtils.getUserAgentProperties( + "azure-storage-blob.properties") + expect: + !properties.getName().matches("UnknownName") + properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java index 8efaa6c65c53..9535f1a224c5 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java @@ -40,7 +40,7 @@ */ public final class BuilderHelper { private static final UserAgentProperties PROPERTIES = - CoreUtils.getUserAgentPropertiesFromProperties(""); + CoreUtils.getUserAgentProperties("azure-storage-blob.properties"); /** * Constructs a {@link HttpPipeline} from values passed from a builder. diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy new file mode 100644 index 000000000000..c8c77f9b7895 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy @@ -0,0 +1,17 @@ +package com.azure.storage.blob + +import com.azure.core.util.CoreUtils +import com.azure.core.util.UserAgentProperties +import spock.lang.Specification + +class BlobUserAgentPropertiesTest extends Specification { + + def "User agent properties not null"() { + given: + UserAgentProperties properties = CoreUtils.getUserAgentProperties( + "azure-storage-blob.properties") + expect: + !properties.getName().matches("UnknownName") + properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java deleted file mode 100644 index 3b15d4d96d4a..000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.file.share; - -/* - * Gets the SDK information for this library component. - */ -class FileConfiguration { - //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 - static final String NAME = "azure-storage-file-share"; - // {x-version-update-start;com.azure:azure-storage-file-share;current} - static final String VERSION = "12.0.0-beta.6"; - // {x-version-update-end} -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java index ec740c01506d..518eaae5de9b 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java @@ -15,6 +15,7 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.storage.common.implementation.Constants; import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.policy.RequestRetryPolicy; @@ -31,10 +32,8 @@ * This class provides helper methods for common builder patterns. */ public final class BuilderHelper { - private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-file-share"; - // {x-version-update-start;com.azure:azure-storage-file-share;current} - private static final String DEFAULT_USER_AGENT_VERSION = "12.0.0-beta.6"; - // {x-version-update-end} + private static final UserAgentProperties PROPERTIES = + CoreUtils.getUserAgentProperties("azure-storage-file-share.properties"); private static final Pattern IP_URL_PATTERN = Pattern .compile("(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:localhost)"); @@ -95,7 +94,7 @@ private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), - DEFAULT_USER_AGENT_NAME, DEFAULT_USER_AGENT_VERSION, configuration); + PROPERTIES.getName(), PROPERTIES.getVersion(), configuration); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties b/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy new file mode 100644 index 000000000000..d33cd9fb9b06 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy @@ -0,0 +1,17 @@ +package com.azure.storage.file.share + +import com.azure.core.util.CoreUtils +import com.azure.core.util.UserAgentProperties +import spock.lang.Specification + +class FileShareUserAgentPropertiesTest extends Specification { + + def "User agent properties not null"() { + given: + UserAgentProperties properties = CoreUtils.getUserAgentProperties( + "azure-storage-file-share.properties") + expect: + !properties.getName().matches("UnknownName") + properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") + } +} diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java deleted file mode 100644 index 75353409dc12..000000000000 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.queue; - -/* - * Gets the SDK information for this library component. - */ -class QueueConfiguration { - //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 - static final String NAME = "azure-storage-queue"; - // {x-version-update-start;com.azure:azure-storage-queue;current} - static final String VERSION = "12.1.0-beta.1"; - // {x-version-update-end} -} diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java index 2b8a224ec656..fb0ecb71288d 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java @@ -17,6 +17,7 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; @@ -41,10 +42,8 @@ * This class provides helper methods for common builder patterns. */ public final class BuilderHelper { - private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-queue"; - // {x-version-update-start;com.azure:azure-storage-queue;current} - private static final String DEFAULT_USER_AGENT_VERSION = "12.1.0-beta.1"; - // {x-version-update-end} + private static final UserAgentProperties PROPERTIES = + CoreUtils.getUserAgentProperties("azure-storage-queue.properties"); private static final Pattern IP_URL_PATTERN = Pattern .compile("(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:localhost)"); @@ -202,7 +201,7 @@ private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), - DEFAULT_USER_AGENT_NAME, DEFAULT_USER_AGENT_VERSION, configuration); + PROPERTIES.getName(), PROPERTIES.getVersion(), configuration); } /* diff --git a/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties b/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy new file mode 100644 index 000000000000..e1437a37a9ca --- /dev/null +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy @@ -0,0 +1,17 @@ +package com.azure.storage.queue; + +import com.azure.core.util.CoreUtils +import com.azure.core.util.UserAgentProperties +import spock.lang.Specification + +class QueueUserAgentPropertiesTest extends Specification { + + def "User agent properties not null"() { + given: + UserAgentProperties properties = CoreUtils.getUserAgentProperties( + "azure-storage-queue.properties") + expect: + !properties.getName().matches("UnknownName") + properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") + } +} From f3e2274bc56e3c6782bb5c166560454237e73326 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 27 Nov 2019 11:47:55 -0800 Subject: [PATCH 4/8] Added license headers --- .../keyvault/certificates/CertificateClientBuilder.java | 4 ++-- .../keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java | 3 +++ .../secrets/KeyVaultSecretsUserAgentPropertiesTest.java | 3 +++ .../BlobCryptographyUserAgentPropertiesTest.groovy | 3 +++ .../com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy | 3 +++ .../file/share/FileShareUserAgentPropertiesTest.groovy | 3 +++ .../azure/storage/queue/QueueUserAgentPropertiesTest.groovy | 3 +++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index 34f39ae19c92..7be4a7558a84 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -111,8 +111,8 @@ public CertificateClient buildClient() { * {@link CertificateClientBuilder#vaultUrl(String)} have not been set. */ public CertificateAsyncClient buildAsyncClient() { - Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : - configuration; + Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() + : configuration; URL buildEndpoint = getBuildEndpoint(buildConfiguration); if (buildEndpoint == null) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java index 80f77b0205c3..af1ecc5c9b28 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.keys; import com.azure.core.util.CoreUtils; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java index 86525a08c7a5..d3410876b23c 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.security.keyvault.secrets; import com.azure.core.util.CoreUtils; diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy index 2e21e644f1f8..9494d059a704 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy +++ b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.blob.specialized.cryptography import com.azure.core.util.CoreUtils diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy index c8c77f9b7895..67fc96cb840c 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.blob import com.azure.core.util.CoreUtils diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy index d33cd9fb9b06..d4f8af956cc6 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.file.share import com.azure.core.util.CoreUtils diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy index e1437a37a9ca..523a6b626407 100644 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy +++ b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.queue; import com.azure.core.util.CoreUtils From 5e8feeb8fafb55a00a8f3fa547cb85c06da06b0a Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 27 Nov 2019 14:11:56 -0800 Subject: [PATCH 5/8] Addressed comments --- .../ConfigurationClientBuilder.java | 1 + .../java/com/azure/core/util/CoreUtils.java | 6 ++-- .../CertificateClientBuilder.java | 1 + .../keyvault/keys/KeyClientBuilder.java | 1 + .../CryptographyClientBuilder.java | 1 + .../keyvault/secrets/SecretClientBuilder.java | 1 + .../cryptography/CryptographyConstants.java | 35 +++++++++++-------- .../EncryptedBlobClientBuilder.java | 7 ++-- 8 files changed, 33 insertions(+), 20 deletions(-) diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java index ba00b7d27031..259c633c4507 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java @@ -76,6 +76,7 @@ public final class ConfigurationClientBuilder { private static final String CONTENT_TYPE_HEADER_VALUE = "application/json"; private static final String ACCEPT_HEADER = "Accept"; private static final String ACCEPT_HEADER_VALUE = "application/vnd.microsoft.azconfig.kv+json"; + // This is properties file's name. private static final String APP_CONFIG_PROPERTIES = "azure-appconfig.properties"; private static final RetryPolicy DEFAULT_RETRY_POLICY = new RetryPolicy("retry-after-ms", ChronoUnit.MILLIS); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java index 57873eec8f22..7931bca14101 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java @@ -26,6 +26,8 @@ public final class CoreUtils { private static final String COMMA = ","; private static final String NAME = "name"; private static final String VERSION = "version"; + private static final String UNKNOWN_NAME = "UnknownName"; + private static final String UNKNOWN_VERSION = "UnknownVersion"; private CoreUtils() { // Exists only to defeat instantiation. @@ -171,8 +173,8 @@ public static Publisher extractAndFetch(PagedResponse page, Context co */ public static UserAgentProperties getUserAgentProperties(String propertiesFileName) { Map propertyMap = getProperties(propertiesFileName); - String name = propertyMap.getOrDefault(NAME, "UnknownName"); - String version = propertyMap.getOrDefault(VERSION, "UnknownVersion"); + String name = propertyMap.getOrDefault(NAME, UNKNOWN_NAME); + String version = propertyMap.getOrDefault(VERSION, UNKNOWN_VERSION); return new UserAgentProperties(name, version); } diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index 7be4a7558a84..136028c64c40 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -56,6 +56,7 @@ @ServiceClientBuilder(serviceClients = {CertificateClient.class, CertificateAsyncClient.class}) public final class CertificateClientBuilder { private final ClientLogger logger = new ClientLogger(CertificateClientBuilder.class); + // This is properties file's name. private static final String AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES = "azure-key-vault-certificates.properties"; private final List policies; private final UserAgentProperties properties; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java index 51c08562fe5a..dc2c90c77878 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java @@ -60,6 +60,7 @@ @ServiceClientBuilder(serviceClients = KeyClient.class) public final class KeyClientBuilder { private final ClientLogger logger = new ClientLogger(KeyClientBuilder.class); + // This is properties file's name. private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private final List policies; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java index a176d8f8afd1..3343309705c9 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java @@ -66,6 +66,7 @@ public final class CryptographyClientBuilder { final List policies; final UserAgentProperties properties; private final ClientLogger logger = new ClientLogger(CryptographyClientBuilder.class); + // This is properties file's name. private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private TokenCredential credential; private HttpPipeline pipeline; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java index 6a5b1d94b96b..1726b90c19ca 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java @@ -59,6 +59,7 @@ @ServiceClientBuilder(serviceClients = SecretClient.class) public final class SecretClientBuilder { private final ClientLogger logger = new ClientLogger(SecretClientBuilder.class); + // This is properties file's name. private static final String AZURE_KEY_VAULT_SECRETS = "azure-key-vault-secrets.properties"; private final List policies; diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java index d98965e7ecf3..97cce5652bc4 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java @@ -18,13 +18,13 @@ final class CryptographyConstants { static final String AES = "AES"; - static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; + static final UserAgentProperties USER_AGENT_PROPERTIES = getProperties(); - static final String BLOB_CRYPTOGRAPHY_NAME = getName(); +// static final String BLOB_CRYPTOGRAPHY_NAME = getName(); +// +// static final String BLOB_CRYPTOGRAPHY_VERSION = getVersion(); - static final String BLOB_CRYPTOGRAPHY_VERSION = getVersion(); - - static final String AGENT_METADATA_VALUE = "JavaTrack2" + BLOB_CRYPTOGRAPHY_VERSION; + static final String AGENT_METADATA_VALUE = "JavaTrack2" + USER_AGENT_PROPERTIES.getVersion(); static final String ENCRYPTION_DATA_KEY = "encryptiondata"; @@ -43,16 +43,23 @@ final class CryptographyConstants { static final String DECRYPT_UNENCRYPTED_BLOB = "Encryption client is being used but the blob metadata indicates " + "that it is not encrypted."; - private CryptographyConstants() { - } + // This is properties file's name. + private static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; - private static String getName() { - UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); - return properties.getName(); + private CryptographyConstants() { } - - private static String getVersion() { - UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); - return properties.getVersion(); +// +// private static String getName() { +// UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); +// return properties.getName(); +// } +// +// private static String getVersion() { +// UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); +// return properties.getVersion(); +// } + + private static UserAgentProperties getProperties() { + return CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); } } diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java index efa738f98367..225cde011f16 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java @@ -45,8 +45,7 @@ import java.util.List; import java.util.Objects; -import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.BLOB_CRYPTOGRAPHY_NAME; -import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.BLOB_CRYPTOGRAPHY_VERSION; +import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.USER_AGENT_PROPERTIES; /** * This class provides a fluent builder API to help aid the configuration and instantiation of Storage Blob clients. @@ -160,8 +159,8 @@ private HttpPipeline getHttpPipeline() { List policies = new ArrayList<>(); policies.add(new BlobDecryptionPolicy(keyWrapper, keyResolver)); - policies.add(new UserAgentPolicy(logOptions.getApplicationId(), BLOB_CRYPTOGRAPHY_NAME, - BLOB_CRYPTOGRAPHY_VERSION, userAgentConfiguration)); + policies.add(new UserAgentPolicy(logOptions.getApplicationId(), USER_AGENT_PROPERTIES.getName(), + USER_AGENT_PROPERTIES.getVersion(), userAgentConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddDatePolicy()); From fb02039919f2690fa23176239dce7f1c3bd5292c Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 27 Nov 2019 14:24:17 -0800 Subject: [PATCH 6/8] remove extra helper methods and constants --- .../cryptography/CryptographyConstants.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java index 97cce5652bc4..b617093b9837 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java @@ -18,11 +18,10 @@ final class CryptographyConstants { static final String AES = "AES"; - static final UserAgentProperties USER_AGENT_PROPERTIES = getProperties(); + // This is properties file's name. + private static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; -// static final String BLOB_CRYPTOGRAPHY_NAME = getName(); -// -// static final String BLOB_CRYPTOGRAPHY_VERSION = getVersion(); + static final UserAgentProperties USER_AGENT_PROPERTIES = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); static final String AGENT_METADATA_VALUE = "JavaTrack2" + USER_AGENT_PROPERTIES.getVersion(); @@ -43,23 +42,8 @@ final class CryptographyConstants { static final String DECRYPT_UNENCRYPTED_BLOB = "Encryption client is being used but the blob metadata indicates " + "that it is not encrypted."; - // This is properties file's name. - private static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; private CryptographyConstants() { } -// -// private static String getName() { -// UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); -// return properties.getName(); -// } -// -// private static String getVersion() { -// UserAgentProperties properties = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); -// return properties.getVersion(); -// } - - private static UserAgentProperties getProperties() { - return CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); - } + } From 9db258cd65218a6616bce1a0ad1067dc281907e3 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 5 Dec 2019 12:21:00 -0800 Subject: [PATCH 7/8] Used fake name and version in certificate tests --- .../keyvault/certificates/CertificateClientTestBase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java index f7d2d5be365e..f7003dbf352e 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java @@ -57,6 +57,8 @@ import static org.junit.jupiter.api.Assertions.fail; public abstract class CertificateClientTestBase extends TestBase { + private static final String SDK_NAME = "client_name"; + private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -80,7 +82,7 @@ T clientSetup(Function clientBuilder) { HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, + policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CertificateServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); From 910db9746156d572cbe7d41ed8ead59da41f0ef6 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 5 Dec 2019 14:59:38 -0800 Subject: [PATCH 8/8] Remove version in configuration class --- .../security/keyvault/secrets/AzureKeyVaultConfiguration.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java deleted file mode 100644 index e69de29bb2d1..000000000000