strea
* Collects ByteBuffers returned in a network response into a byte array.
*
* The {@code headers} are inspected for containing an {@code Content-Length} which determines if a size hinted
- * collection, {@link #collectBytesInByteBufferStream(Flux, int)}, or default collection,
- * {@link #collectBytesInByteBufferStream(Flux)}, will be used.
+ * collection, {@link #collectBytesInByteBufferStream(Flux, int)}, or default collection, {@link
+ * #collectBytesInByteBufferStream(Flux)}, will be used.
*
* @param stream A network response ByteBuffer stream.
* @param headers The HTTP headers of the response.
@@ -201,7 +202,7 @@ public static Flux toFluxByteBuffer(InputStream inputStream, int chu
}
/**
- * This method converts the incoming {@code subscriberContext} from {@link reactor.util.context.Context Reactor
+ * This method converts the incoming {@code deferContextual} from {@link reactor.util.context.Context Reactor
* Context} to {@link Context Azure Context} and calls the given lambda function with this context and returns a
* single entity of type {@code T}
*
@@ -220,7 +221,7 @@ public static Mono withContext(Function> serviceCall) {
}
/**
- * This method converts the incoming {@code subscriberContext} from {@link reactor.util.context.Context Reactor
+ * This method converts the incoming {@code deferContextual} from {@link reactor.util.context.Context Reactor
* Context} to {@link Context Azure Context}, adds the specified context attributes and calls the given lambda
* function with this context and returns a single entity of type {@code T}
*
@@ -235,22 +236,20 @@ public static Mono withContext(Function> serviceCall) {
*/
public static Mono withContext(Function> serviceCall,
Map contextAttributes) {
- return Mono.subscriberContext()
- .map(context -> {
- final Context[] azureContext = new Context[]{Context.NONE};
+ return Mono.deferContextual(context -> {
+ final Context[] azureContext = new Context[]{Context.NONE};
- if (!CoreUtils.isNullOrEmpty(contextAttributes)) {
- contextAttributes.forEach((key, value) -> azureContext[0] = azureContext[0].addData(key, value));
- }
+ if (!CoreUtils.isNullOrEmpty(contextAttributes)) {
+ contextAttributes.forEach((key, value) -> azureContext[0] = azureContext[0].addData(key, value));
+ }
- if (!context.isEmpty()) {
- context.stream().forEach(entry ->
- azureContext[0] = azureContext[0].addData(entry.getKey(), entry.getValue()));
- }
+ if (!context.isEmpty()) {
+ context.stream().forEach(entry ->
+ azureContext[0] = azureContext[0].addData(entry.getKey(), entry.getValue()));
+ }
- return azureContext[0];
- })
- .flatMap(serviceCall);
+ return serviceCall.apply(azureContext[0]);
+ });
}
/**
@@ -301,7 +300,7 @@ public static PagedFlux pagedFluxError(ClientLogger logger, RuntimeExcept
}
/**
- * This method converts the incoming {@code subscriberContext} from {@link reactor.util.context.Context Reactor
+ * This method converts the incoming {@code deferContextual} from {@link reactor.util.context.Context Reactor
* Context} to {@link Context Azure Context} and calls the given lambda function with this context and returns a
* collection of type {@code T}
*
@@ -316,9 +315,7 @@ public static PagedFlux pagedFluxError(ClientLogger logger, RuntimeExcept
* @return The response from service call
*/
public static Flux fluxContext(Function> serviceCall) {
- return Mono.subscriberContext()
- .map(FluxUtil::toAzureContext)
- .flatMapMany(serviceCall);
+ return Flux.deferContextual(context -> serviceCall.apply(toAzureContext(context)));
}
/**
@@ -328,7 +325,7 @@ public static Flux fluxContext(Function> serviceCall) {
* @param context The reactor context
* @return The azure context
*/
- private static Context toAzureContext(reactor.util.context.Context context) {
+ private static Context toAzureContext(ContextView context) {
final Context[] azureContext = new Context[]{Context.NONE};
if (!context.isEmpty()) {
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedFluxTest.java b/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedFluxTest.java
index 92b7f32fe978b..a6ca696a7c0c3 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedFluxTest.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/http/rest/PagedFluxTest.java
@@ -191,7 +191,7 @@ public void testPagedFluxWithContext() throws Exception {
CountDownLatch multiPageLatch = new CountDownLatch(2);
pagedFlux
.byPage()
- .subscriberContext(Context.of("hello", "context"))
+ .contextWrite(Context.of("hello", "context"))
.subscribe(pagedResponse -> assertTrue(pagedResponse instanceof PagedResponse));
boolean completed = singlePageLatch.await(1, TimeUnit.SECONDS);
@@ -219,7 +219,7 @@ public void testPagedFluxWithContext() throws Exception {
pagedFlux
.byPage()
- .subscriberContext(Context.of("hello", "context"))
+ .contextWrite(Context.of("hello", "context"))
.subscribe(pagedResponse -> assertTrue(pagedResponse instanceof PagedResponse));
completed = multiPageLatch.await(1, TimeUnit.SECONDS);
assertTrue(completed);
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/serializer/HttpResponseBodyDecoderTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/serializer/HttpResponseBodyDecoderTests.java
index 4bdc4e05a0ec4..ee6b918b84e47 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/serializer/HttpResponseBodyDecoderTests.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/serializer/HttpResponseBodyDecoderTests.java
@@ -61,13 +61,16 @@ public class HttpResponseBodyDecoderTests {
private static final HttpRequest GET_REQUEST = new HttpRequest(HttpMethod.GET, "https://localhost");
private static final HttpRequest HEAD_REQUEST = new HttpRequest(HttpMethod.HEAD, "https://localhost");
+ private AutoCloseable openMocks;
+
@BeforeEach
public void prepareForMocking() {
- MockitoAnnotations.initMocks(this);
+ this.openMocks = MockitoAnnotations.openMocks(this);
}
@AfterEach
- public void clearMocks() {
+ public void clearMocks() throws Exception {
+ openMocks.close();
Mockito.framework().clearInlineMocks();
}
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/AuthorizationChallengeHandlerTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/AuthorizationChallengeHandlerTests.java
index a8b97b7947315..d5d1c47c12f19 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/util/AuthorizationChallengeHandlerTests.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/AuthorizationChallengeHandlerTests.java
@@ -4,6 +4,7 @@
package com.azure.core.util;
import com.azure.core.http.HttpMethod;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -46,9 +47,16 @@ public class AuthorizationChallengeHandlerTests {
private static final String EXPECTED_BASIC = "Basic " + Base64.getEncoder()
.encodeToString(String.format("%s:%s", DEFAULT_USERNAME, DEFAULT_PASSWORD).getBytes(StandardCharsets.UTF_8));
+ private AutoCloseable openMocks;
+
@BeforeEach
public void prepareForTest() {
- MockitoAnnotations.initMocks(this);
+ this.openMocks = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ public void clearMocks() throws Exception {
+ openMocks.close();
}
/**
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 fe7d0fa7352c7..d469b7f74d7b9 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
@@ -46,7 +46,7 @@ public class FluxUtilTest {
@Test
public void testCallWithContextGetSingle() {
String response = getSingle()
- .subscriberContext(reactor.util.context.Context.of("FirstName", "Foo", "LastName", "Bar"))
+ .contextWrite(reactor.util.context.Context.of("FirstName", "Foo", "LastName", "Bar"))
.block();
assertEquals("Hello, Foo Bar", response);
}
@@ -56,7 +56,7 @@ public void testCallWithContextGetCollection() {
List expectedLines = Arrays.asList("Hello,", "Foo", "Bar");
List actualLines = new ArrayList<>();
getCollection()
- .subscriberContext(reactor.util.context.Context.of("FirstName", "Foo", "LastName", "Bar"))
+ .contextWrite(reactor.util.context.Context.of("FirstName", "Foo", "LastName", "Bar"))
.doOnNext(actualLines::add)
.subscribe();
assertEquals(expectedLines, actualLines);
@@ -65,7 +65,7 @@ public void testCallWithContextGetCollection() {
@Test
public void testCallWithDefaultContextGetSingle() {
String response = getSingleWithContextAttributes()
- .subscriberContext(reactor.util.context.Context.of("FirstName", "Foo"))
+ .contextWrite(reactor.util.context.Context.of("FirstName", "Foo"))
.block();
assertEquals("Hello, Foo additionalContextValue", response);
}
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/polling/PollerTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/polling/PollerTests.java
index 3f7ca34106cf4..6e8a77c6d76dc 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/util/polling/PollerTests.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/polling/PollerTests.java
@@ -53,13 +53,16 @@ public class PollerTests {
@Mock
private BiFunction, PollResponse, Mono> cancelOperation;
+ private AutoCloseable openMocks;
+
@BeforeEach
public void beforeTest() {
- MockitoAnnotations.initMocks(this);
+ this.openMocks = MockitoAnnotations.openMocks(this);
}
@AfterEach
- public void afterTest() {
+ public void afterTest() throws Exception {
+ openMocks.close();
Mockito.framework().clearInlineMocks();
}
diff --git a/sdk/cosmos/azure-cosmos-benchmark/pom.xml b/sdk/cosmos/azure-cosmos-benchmark/pom.xml
index af7fbf750e287..9f20c6e80ecb5 100644
--- a/sdk/cosmos/azure-cosmos-benchmark/pom.xml
+++ b/sdk/cosmos/azure-cosmos-benchmark/pom.xml
@@ -79,13 +79,13 @@ Licensed under the MIT License.
io.micrometer
micrometer-registry-azure-monitor
- 1.5.6
+ 1.6.1
io.micrometer
micrometer-registry-graphite
- 1.5.6
+ 1.6.1
@@ -115,13 +115,13 @@ Licensed under the MIT License.
org.apache.commons
commons-lang3
- 3.10
+ 3.11
org.assertj
assertj-core
- 3.16.1
+ 3.18.1
test
@@ -228,9 +228,9 @@ Licensed under the MIT License.
com.google.guava:guava:[25.0-jre]
io.dropwizard.metrics:metrics-graphite:[4.1.0]
io.dropwizard.metrics:metrics-jvm:[4.1.0]
- io.micrometer:micrometer-registry-azure-monitor:[1.5.6]
- io.micrometer:micrometer-registry-graphite:[1.5.6]
- org.apache.commons:commons-lang3:[3.10]
+ io.micrometer:micrometer-registry-azure-monitor:[1.6.1]
+ io.micrometer:micrometer-registry-graphite:[1.6.1]
+ org.apache.commons:commons-lang3:[3.11]
org.apache.logging.log4j:log4j-api:[2.13.3]
org.apache.logging.log4j:log4j-core:[2.13.3]
org.apache.logging.log4j:log4j-slf4j-impl:[2.13.3]
diff --git a/sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml b/sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml
index 6de2345d36d43..389ad4a875f0e 100644
--- a/sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml
+++ b/sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml
@@ -89,7 +89,7 @@ Licensed under the MIT License.
org.assertj
assertj-core
- 3.16.1
+ 3.18.1
test
@@ -182,9 +182,9 @@ Licensed under the MIT License.
com.google.guava:guava:[25.0-jre]
io.dropwizard.metrics:metrics-graphite:[4.1.0]
io.dropwizard.metrics:metrics-jvm:[4.1.0]
- io.micrometer:micrometer-registry-azure-monitor:[1.5.6]
- io.micrometer:micrometer-registry-graphite:[1.5.6]
- org.apache.commons:commons-lang3:[3.10]
+ io.micrometer:micrometer-registry-azure-monitor:[1.6.1]
+ io.micrometer:micrometer-registry-graphite:[1.6.1]
+ org.apache.commons:commons-lang3:[3.11]
org.apache.logging.log4j:log4j-api:[2.13.3]
org.apache.logging.log4j:log4j-core:[2.13.3]
org.apache.logging.log4j:log4j-slf4j-impl:[2.13.3]
diff --git a/sdk/cosmos/azure-cosmos-encryption/pom.xml b/sdk/cosmos/azure-cosmos-encryption/pom.xml
index 19c8d884a12fe..a2b2f76fa8afd 100644
--- a/sdk/cosmos/azure-cosmos-encryption/pom.xml
+++ b/sdk/cosmos/azure-cosmos-encryption/pom.xml
@@ -95,7 +95,7 @@ Licensed under the MIT License.
org.assertj
assertj-core
- 3.16.1
+ 3.18.1
test
@@ -130,7 +130,7 @@ Licensed under the MIT License.
io.projectreactor
reactor-test
- 3.3.12.RELEASE
+ 3.4.3
test
@@ -144,7 +144,7 @@ Licensed under the MIT License.
org.mockito
mockito-core
- 3.3.3
+ 3.6.0
test
diff --git a/sdk/cosmos/azure-cosmos/pom.xml b/sdk/cosmos/azure-cosmos/pom.xml
index b31abb778cc4b..7bfa57223454c 100644
--- a/sdk/cosmos/azure-cosmos/pom.xml
+++ b/sdk/cosmos/azure-cosmos/pom.xml
@@ -65,7 +65,7 @@ Licensed under the MIT License.
com.azure
azure-core
- 1.13.0
+ 1.14.0-beta.1
com.azure
@@ -77,7 +77,7 @@ Licensed under the MIT License.
com.azure
azure-core-http-netty
- 1.8.0
+ 1.9.0-beta.1
com.azure
@@ -149,7 +149,7 @@ Licensed under the MIT License.
org.assertj
assertj-core
- 3.16.1
+ 3.18.1
test
@@ -190,13 +190,13 @@ Licensed under the MIT License.
io.micrometer
micrometer-core
- 1.5.6
+ 1.6.1
io.projectreactor
reactor-test
- 3.3.12.RELEASE
+ 3.4.3
test
@@ -274,7 +274,7 @@ Licensed under the MIT License.
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:[2.12.1]
com.fasterxml.jackson.module:jackson-module-afterburner:[2.12.1]
io.dropwizard.metrics:metrics-core:[4.1.0]
- io.micrometer:micrometer-core:[1.5.6]
+ io.micrometer:micrometer-core:[1.6.1]
org.slf4j:slf4j-api:[1.7.30]
org.hdrhistogram:HdrHistogram:[2.1.12]