From ffa969aa6d8e4c7564cd8e069c7ef857e7919b81 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Wed, 11 Dec 2019 14:05:35 -0800 Subject: [PATCH] More tests on fluxUtil and Base64Util --- README.md | 39 +++--- eng/mgmt/gulpfile.js | 20 ++-- .../templates/jobs/archetype-sdk-tests.yml | 39 +++++- .../com/azure/core/util/Base64UtilTests.java | 51 ++++++++ .../com/azure/core/util/FluxUtilTest.java | 111 ++++++++++++++++++ .../core/util/logging/ClientLoggerTests.java | 52 ++++++++ .../EqualPartitionsBalancingStrategy.java | 2 +- .../implementation/LeaseRenewerImpl.java | 2 + sdk/storage/azure-storage-blob-batch/pom.xml | 4 + .../azure-storage-blob-cryptography/pom.xml | 4 + sdk/storage/azure-storage-blob/pom.xml | 4 + .../azure-storage-file-datalake/pom.xml | 20 +++- sdk/storage/azure-storage-file-share/pom.xml | 4 + sdk/storage/azure-storage-queue/pom.xml | 4 + 14 files changed, 319 insertions(+), 37 deletions(-) create mode 100644 sdk/core/azure-core/src/test/java/com/azure/core/util/Base64UtilTests.java diff --git a/README.md b/README.md index 967697a13199..feab34484999 100644 --- a/README.md +++ b/README.md @@ -22,32 +22,33 @@ Java 8 or later is required to use the November 2019 client libraries, otherwise Each service might have a number of libraries available from each of the following categories: -- [Client: GA November 2019 Releases](#Client-GA-November-2019-Releases) +- [Client: GA Decemeber 2019 Releases](#Client-GA-Decemeber-2019-Releases) - [Client - Previous Versions](#Client-Previous-Versions) - [Management](#Management) -### Client: GA November 2019 Releases +### Client: GA December 2019 Releases -New wave of packages that were released in November 2019 client library as General Availability (GA) and several others that were released in **preview**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java/guidelines/) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](sdk/core/README.md). +New wave of packages that were released in December 2019 client library as General Availability (GA) and several others that were released in **beta**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java/guidelines/) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](sdk/core/README.md). These libraries can be easily identified by sdk/ folder, package, and namespaces names starting with `azure-`, e.g. `azure-keyvault`. -The libraries released in the GA November 2019 release: -- [Identity](https://github.com/Azure/azure-sdk-for-java/blob/azure-identity_1.0.0/sdk/identity/azure-identity/README.md) -- [Key Vault Keys](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-keys_4.0.0/sdk/keyvault/azure-security-keyvault-keys/README.md) -- [Key Vault Secrets](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-secrets_4.0.0/sdk/keyvault/azure-security-keyvault-secrets/README.md) -- [Storage Blobs](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-blob/README.md) -- [Storage Blobs Batch](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-blob-batch/README.md) -- [Storage Blobs Cryptography](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-blob-cryptography/README.md) -- [Storage Queues](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.0.0/sdk/storage/azure-storage-queue/README.md) - -The libraries released in the November 2019 preview: -- [App Configuration](https://github.com/Azure/azure-sdk-for-java/tree/azure-data-appconfiguration_1.0.0-preview.6/sdk/appconfiguration/azure-data-appconfiguration) -- [Event Hubs](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.0.0-preview.5/sdk/eventhubs/azure-messaging-eventhubs/README.md) -- [Event Hubs Checkpoint Store](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.0.0-preview.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md) -- [Storage File Share](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-file-share_12.0.0-preview.5/sdk/storage/azure-storage-file-share/README.md) -- [Key Vault Certificates](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-certificates_4.0.0-preview.5/sdk/keyvault/azure-security-keyvault-certificates/README.md) -- [OpenCensus Tracing](https://github.com/Azure/azure-sdk-for-java/blob/azure-core-tracing-opencensus_1.0.0-preview.4/sdk/core/azure-core-tracing-opencensus/README.md) +The libraries released in the GA December 2019 release: +- [Identity](https://github.com/Azure/azure-sdk-for-java/blob/azure-identity_1.0.1/sdk/identity/azure-identity/README.md) +- [Key Vault Keys](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-keys_4.0.1/sdk/keyvault/azure-security-keyvault-keys/README.md) +- [Key Vault Secrets](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-secrets_4.0.1/sdk/keyvault/azure-security-keyvault-secrets/README.md) +- [Storage Blobs](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob_12.1.0/sdk/storage/azure-storage-blob/README.md) +- [Storage Blobs Batch](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob-batch_12.1.0/sdk/storage/azure-storage-blob-batch/README.md) +- [Storage Blobs Cryptography](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-blob-cryptography_12.1.0/sdk/storage/azure-storage-blob-cryptography/README.md) +- [Storage Queues](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-queue_12.1.0/sdk/storage/azure-storage-queue/README.md) +- [Storage File Share](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-file-share_12.0.0/sdk/storage/azure-storage-file-share/README.md) + +The libraries released in the December 2019 beta: +- [App Configuration](https://github.com/Azure/azure-sdk-for-java/tree/azure-data-appconfiguration_1.0.0-beta.7/sdk/appconfiguration/azure-data-appconfiguration/README.md) +- [Event Hubs](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.0.0-beta.6/sdk/eventhubs/azure-messaging-eventhubs/README.md) +- [Event Hubs Checkpoint Store](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.0.0-beta.4/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md) +- [Key Vault Certificates](https://github.com/Azure/azure-sdk-for-java/blob/azure-security-keyvault-certificates_4.0.0-beta.6/sdk/keyvault/azure-security-keyvault-certificates/README.md) +- [OpenCensus Tracing](https://github.com/Azure/azure-sdk-for-java/blob/azure-core-tracing-opencensus_1.0.0-beta.5/sdk/core/azure-core-tracing-opencensus/README.md) +- [OpenTelemetry Tracing](https://github.com/Azure/azure-sdk-for-java/blob/azure-core-tracing-opentelemetry_1.0.0-beta.1/sdk/core/azure-core-tracing-opentelemetry/README.md) > NOTE: If you need to ensure your code is ready for production use one of the stable, non-preview libraries. diff --git a/eng/mgmt/gulpfile.js b/eng/mgmt/gulpfile.js index 8b7cbdf8977a..273cb544497d 100644 --- a/eng/mgmt/gulpfile.js +++ b/eng/mgmt/gulpfile.js @@ -39,9 +39,10 @@ gulp.task('default', function() { console.log("\tThe version of AutoRest. E.g. 2.0.9, or the location of AutoRest repo, e.g. E:\\repo\\autorest"); console.log("--autorest-java"); - console.log("\tPath to an autorest.java generator to pass as a --use argument to AutoRest."); + console.log("\tOption#1: Path to an autorest.java generator to pass as a --use argument to AutoRest."); + console.log("\tOption#2: The version of AutoRest.Java. E.g. 2.0.9. You can also pass latest or preview."); console.log("\tUsually you'll only need to provide this and not a --autorest argument in order to work on Java code generation."); - console.log("\tSee https://github.com/Azure/autorest/blob/master/docs/developer/autorest-extension.md"); + console.log("\tSee https://github.com/Azure/autorest/blob/master/.attic/developer/autorest-extension.md"); console.log("--debug"); console.log("\tFlag that allows you to attach a debugger to the autorest.java generator."); @@ -62,6 +63,10 @@ var autoRestVersion = 'preview'; // default if (args['autorest'] !== undefined) { autoRestVersion = args['autorest']; } +var autoRestJavaVersion = ''; // default +if (args['autorest-java'] !== undefined) { + autoRestJavaVersion = args['autorest-java']; +} var debug = args['debug']; var autoRestArgs = args['autorest-args'] || ''; var autoRestExe; @@ -69,8 +74,8 @@ const mgmtPomFilename = 'pom.mgmt.xml' gulp.task('codegen', function(cb) { if (autoRestVersion.match(/[0-9]+\.[0-9]+\.[0-9]+.*/) || - autoRestVersion == 'preview') { - autoRestExe = 'autorest ---version=' + autoRestVersion; + autoRestVersion == 'preview' || autoRestVersion == 'latest') { + autoRestExe = 'autorest --version=' + autoRestVersion; handleInput(projects, cb); } else { autoRestExe = "node " + path.join(autoRestVersion, "src/autorest-core/dist/app.js"); @@ -107,9 +112,10 @@ var codegen = function(project, cb) { console.log('Generating "' + project + '" from spec file ' + specRoot + '/' + mappings[project].source); - const generatorPath = args['autorest-java'] - ? `--use=${path.resolve(args['autorest-java'])} ` - : ''; + const generatorPath = autoRestJavaVersion == 'preview' || autoRestJavaVersion == 'latest' + || autoRestJavaVersion.match(/^[0-9]+\.[0-9]+\.[0-9a-zA-Z]+$/) + ? `--use=@microsoft.azure/autorest.java@` + autoRestJavaVersion +` ` + : (autoRestJavaVersion == '' ? '' : `--use=${path.resolve(args['autorest-java'])} `); const regenManager = args['regenerate-manager'] ? ' --regenerate-manager=true ' : ''; diff --git a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml index 424314b65434..56693f502c17 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml @@ -3,20 +3,47 @@ parameters: EnvVars: {} MaxParallel: 0 Matrix: - Win2016: + Linux - Java 8: + OSName: 'Linux' + OSVmImage: 'ubuntu-16.04' + JavaVersion: '1.8' + DisplayName: 'Linux - Java 8' + macOS - Java 8: + OSName: 'macOS' + OSVmImage: 'macOS-10.13' + JavaVersion: '1.8' + DisplayName: 'macOS - Java 8' + Windows - Java 8: + OSName: 'Windows' OSVmImage: 'windows-2019' - DisplayName: 'Run Live tests' + JavaVersion: '1.8' + DisplayName: 'Windows - Java 8' + Linux - Java 11: + OSName: 'Linux' + OSVmImage: 'ubuntu-16.04' + JavaVersion: '1.11' + DisplayName: 'Linux - Java 11' + macOS - Java 11: + OSName: 'macOS' + OSVmImage: 'macOS-10.13' + JavaVersion: '1.11' + DisplayName: 'macOS - Java 11' + Windows - Java 11: + OSName: 'Windows' + OSVmImage: 'windows-2019' + JavaVersion: '1.11' + DisplayName: 'Windows - Java 11' PreRunSteps: [] TestName: LiveTest TimeoutInMinutes: 60 TestStepMavenInputs: - options: '--batch-mode -Dmaven.wagon.http.pool=false -Dsurefire.rerunFailingTestsCount=3 --settings eng/settings.xml' - mavenOptions: '-Xmx3072m -Dorg.slf4j.simpleLogger.defaultLogLevel=error -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' + options: '-Dmaven.wagon.http.pool=false -Dsurefire.rerunFailingTestsCount=3 $(DefaultOptions)' + mavenOptions: '$(MemoryOptions) $(LoggingOptions)' javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' + jdkVersionOption: '$(JavaVersion)' jdkArchitectureOption: 'x64' publishJUnitResults: false - goals: 'test' + goals: 'test' TestResultsFiles: '' jobs: diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/Base64UtilTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/Base64UtilTests.java new file mode 100644 index 000000000000..1e4f2926fb78 --- /dev/null +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/Base64UtilTests.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.util; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class Base64UtilTests { + @Test + public void testEncodeAndDecode() { + byte[] src = new byte[] { 65, 65, 69, 67, 65, 119, 81, 70, 66, 103, 99, 73, 67, 81 }; + byte[] dst = Base64Util.encode(src); + assertTrue(Arrays.equals(Base64Util.decode(dst), src)); + } + + @Test + public void testEncodeNullValue() { + assertNull(Base64Util.encode(null)); + } + + @Test + public void testDecodeNullValue() { + assertNull(Base64Util.decode(null)); + } + + @Test + public void testDecodeString() { + byte[] src = new byte[] { 65, 65, 69, 67, 65, 119, 81, 70, 66, 103, 99, 73, 67, 81 }; + String dstString = Base64Util.encodeToString(src); + assertTrue(Arrays.equals(Base64Util.decodeString(dstString), src)); + } + + @Test + public void testDecodeStringNullValue() { + assertNull(Base64Util.decodeString(null)); + } + + @Test + public void testEncodeURLWithoutPaddingNullValue() { + assertNull(Base64Util.encodeURLWithoutPadding(null)); + } + + @Test + public void testDecodeURLNullValue() { + assertNull(Base64Util.decodeURL(null)); + } +} diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/FluxUtilTest.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/FluxUtilTest.java index 7ed9764670a5..8677ebea8a51 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/FluxUtilTest.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/FluxUtilTest.java @@ -3,6 +3,35 @@ package com.azure.core.util; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.logging.ClientLogger; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -10,8 +39,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import reactor.test.StepVerifier; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; public class FluxUtilTest { @@ -60,6 +91,77 @@ public void toReactorContext() { assertEquals("value2", reactorContext.get("key2")); } + @Test + public void testIsFluxByteBufferInvalidType() { + assertFalse(FluxUtil.isFluxByteBuffer(Mono.class)); + } + + @Test + public void testIsFluxByteBufferValidType() throws Exception { + Method method = FluxUtilTest.class.getMethod("mockReturnType"); + Type returnType = method.getGenericReturnType(); + assertTrue(FluxUtil.isFluxByteBuffer(returnType)); + } + + @Test + public void testToMono() { + String testValue = "some value"; + Response response = new SimpleResponse(new HttpRequest(HttpMethod.GET, "http://www.test.com"), + 202, new HttpHeaders(), testValue); + StepVerifier.create(FluxUtil.toMono(response)) + .assertNext(val -> assertEquals(val, testValue)) + .verifyComplete(); + } + + @Test + public void testMonoError() { + String errMsg = "It is an error message"; + RuntimeException ex = new RuntimeException(errMsg); + ClientLogger logger = new ClientLogger(FluxUtilTest.class); + StepVerifier.create(FluxUtil.monoError(logger, ex)) + .verifyErrorMessage(errMsg); + } + + @Test + public void testFluxError() { + String errMsg = "It is an error message"; + RuntimeException ex = new RuntimeException(errMsg); + ClientLogger logger = new ClientLogger(FluxUtilTest.class); + StepVerifier.create(FluxUtil.fluxError(logger, ex)) + .verifyErrorMessage(errMsg); + } + + @Test + public void testPageFluxError() { + String errMsg = "It is an error message"; + RuntimeException ex = new RuntimeException(errMsg); + ClientLogger logger = new ClientLogger(FluxUtilTest.class); + StepVerifier.create(FluxUtil.pagedFluxError(logger, ex)) + .verifyErrorMessage(errMsg); + } + + @Test + public void testWriteFile() throws Exception { + String toReplace = "test"; + String original = "hello there"; + String target = "testo there"; + + Flux body = Flux.just(ByteBuffer.wrap(toReplace.getBytes(StandardCharsets.UTF_8))); + File file = createFileIfNotExist("target/test1"); + FileOutputStream stream = new FileOutputStream(file); + stream.write(original.getBytes(StandardCharsets.UTF_8)); + stream.close(); + try (AsynchronousFileChannel channel = AsynchronousFileChannel.open(file.toPath(), StandardOpenOption.WRITE)) { + FluxUtil.writeFile(body, channel).block(); + byte[] outputStream = Files.readAllBytes(file.toPath()); + assertTrue(Arrays.equals(outputStream, target.getBytes(StandardCharsets.UTF_8))); + } + } + + public Flux mockReturnType() { + return Flux.just(ByteBuffer.wrap(new byte[0])); + } + private Mono getSingle() { return FluxUtil.withContext(this::serviceCallSingle); } @@ -85,4 +187,13 @@ private Flux serviceCallCollection(Context context) { return Flux.just(msg.split(" ")); } + + private File createFileIfNotExist(String fileName) throws IOException { + File file = new File(fileName); + if (file.getParentFile() != null) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + return file; + } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java index 48454669bbae..be652413517d 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java @@ -150,6 +150,58 @@ public void logExceptionStackTrace() { assertTrue(logValues.contains(runtimeException.getStackTrace()[0].toString())); } + /** + * Tests that logging an exception when the log level is ERROR the stack trace is logged. + */ + @Test + public void logExceptionStackTraceWithErrorLevel() { + String logMessage = "This is an exception"; + String exceptionMessage = "An exception message"; + RuntimeException runtimeException = createRuntimeException(exceptionMessage); + + String originalLogLevel = setupLogLevel(1); + logMessage(new ClientLogger(ClientLoggerTests.class), 4, logMessage, runtimeException); + setPropertyToOriginalOrClear(Configuration.PROPERTY_AZURE_LOG_LEVEL, originalLogLevel); + + String logValues = new String(logCaptureStream.toByteArray(), StandardCharsets.UTF_8); + assertTrue(logValues.contains(logMessage + System.lineSeparator() + runtimeException.getMessage())); + assertTrue(logValues.contains(runtimeException.getStackTrace()[0].toString())); + } + + + /** + * Tests that logging an exception when the log level is ERROR the stack trace is logged. + */ + @Test + public void logExceptionStackTraceWithNoLogLevel() { + String logMessage = "This is an exception"; + String exceptionMessage = "An exception message"; + RuntimeException runtimeException = createRuntimeException(exceptionMessage); + + String originalLogLevel = setupLogLevel(1); + logMessage(new ClientLogger(ClientLoggerTests.class), 5, logMessage, runtimeException); + setPropertyToOriginalOrClear(Configuration.PROPERTY_AZURE_LOG_LEVEL, originalLogLevel); + + String logValues = new String(logCaptureStream.toByteArray(), StandardCharsets.UTF_8); + assertTrue(logValues.isEmpty()); + } + + /** + * Tests that logging an exception when the log level is ERROR the stack trace is logged. + */ + @Test + public void logExceptionWithInvalidLogLevel() { + String logMessage = "This is an exception"; + Object runtimeException = new Object(); + + String originalLogLevel = setupLogLevel(1); + logMessage(new ClientLogger(ClientLoggerTests.class), 3, logMessage, runtimeException); + setPropertyToOriginalOrClear(Configuration.PROPERTY_AZURE_LOG_LEVEL, originalLogLevel); + + String logValues = new String(logCaptureStream.toByteArray(), StandardCharsets.UTF_8); + assertTrue(logValues.contains(logMessage)); + } + /** * Tests that logging an exception as warning won't include the stack trace when the environment log level isn't * VERBOSE. Additionally, this tests that the exception message isn't logged twice as logging an exception uses diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java index 302e7f5acc1f..cb19f309af9c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java +++ b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java @@ -73,7 +73,7 @@ public List selectLeasesToTake(List allLeases) { return new ArrayList(); if (expiredLeases.size() > 0) { - return expiredLeases.subList(0, partitionsNeededForMe); + return expiredLeases.subList(0, Math.min(expiredLeases.size(), partitionsNeededForMe)); } Lease stolenLease = getLeaseToSteal(workerToPartitionCount, target, partitionsNeededForMe, allPartitions); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java index 87328513f8fb..917f071561e3 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java +++ b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java @@ -65,8 +65,10 @@ public Mono run(CancellationToken cancellationToken) { .doOnError(throwable -> { if (throwable instanceof LeaseLostException) { logger.info("Partition {}: renew lease loop failed.", this.lease.getLeaseToken(), throwable); + this.resultException = (LeaseLostException) throwable; } else { logger.error("Partition {}: renew lease loop failed.", this.lease.getLeaseToken(), throwable); + this.resultException = new RuntimeException(throwable); } }); } diff --git a/sdk/storage/azure-storage-blob-batch/pom.xml b/sdk/storage/azure-storage-blob-batch/pom.xml index 237dd555a2f5..a4875c005fa5 100644 --- a/sdk/storage/azure-storage-blob-batch/pom.xml +++ b/sdk/storage/azure-storage-blob-batch/pom.xml @@ -174,6 +174,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -184,6 +185,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -234,6 +236,7 @@ groovy-eclipse-compiler + -warn:-unused 8 @@ -245,6 +248,7 @@ groovy-eclipse-compiler + -warn:-unused 8 diff --git a/sdk/storage/azure-storage-blob-cryptography/pom.xml b/sdk/storage/azure-storage-blob-cryptography/pom.xml index 72336561046c..a69927b10ff6 100644 --- a/sdk/storage/azure-storage-blob-cryptography/pom.xml +++ b/sdk/storage/azure-storage-blob-cryptography/pom.xml @@ -140,6 +140,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -150,6 +151,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -200,6 +202,7 @@ groovy-eclipse-compiler + -warn:-unused 8 @@ -211,6 +214,7 @@ groovy-eclipse-compiler + -warn:-unused 8 diff --git a/sdk/storage/azure-storage-blob/pom.xml b/sdk/storage/azure-storage-blob/pom.xml index da8ef931b0b4..c63cd8296fb4 100644 --- a/sdk/storage/azure-storage-blob/pom.xml +++ b/sdk/storage/azure-storage-blob/pom.xml @@ -175,6 +175,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -185,6 +186,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -235,6 +237,7 @@ groovy-eclipse-compiler + -warn:-unused 8 @@ -246,6 +249,7 @@ groovy-eclipse-compiler + -warn:-unused 8 diff --git a/sdk/storage/azure-storage-file-datalake/pom.xml b/sdk/storage/azure-storage-file-datalake/pom.xml index e3e7d3111eb0..0c0a012962f7 100644 --- a/sdk/storage/azure-storage-file-datalake/pom.xml +++ b/sdk/storage/azure-storage-file-datalake/pom.xml @@ -159,7 +159,10 @@ groovy-eclipse-compiler - -Xlint:unchecked + + -Xlint:unchecked + -warn:-unused + @@ -170,7 +173,10 @@ groovy-eclipse-compiler - -Xlint:unchecked + + -Xlint:unchecked + -warn:-unused + @@ -222,7 +228,10 @@ groovy-eclipse-compiler - -Xlint:unchecked + + -Xlint:unchecked + -warn:-unused + 8 @@ -234,7 +243,10 @@ groovy-eclipse-compiler - -Xlint:unchecked + + -Xlint:unchecked + -warn:-unused + 8 diff --git a/sdk/storage/azure-storage-file-share/pom.xml b/sdk/storage/azure-storage-file-share/pom.xml index 5dbac692cf30..3930627c6295 100644 --- a/sdk/storage/azure-storage-file-share/pom.xml +++ b/sdk/storage/azure-storage-file-share/pom.xml @@ -127,6 +127,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -137,6 +138,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -187,6 +189,7 @@ groovy-eclipse-compiler + -warn:-unused 8 @@ -198,6 +201,7 @@ groovy-eclipse-compiler + -warn:-unused 8 diff --git a/sdk/storage/azure-storage-queue/pom.xml b/sdk/storage/azure-storage-queue/pom.xml index 289f8ba53fb5..f690b2b32f8a 100644 --- a/sdk/storage/azure-storage-queue/pom.xml +++ b/sdk/storage/azure-storage-queue/pom.xml @@ -119,6 +119,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -129,6 +130,7 @@ groovy-eclipse-compiler + -warn:-unused @@ -179,6 +181,7 @@ groovy-eclipse-compiler + -warn:-unused 8 @@ -190,6 +193,7 @@ groovy-eclipse-compiler + -warn:-unused 8