From e5d1ed24c76da2be9629129e8d5b270ca1e9630d Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 01:08:59 +0530 Subject: [PATCH 01/12] fix: InputStreamContent closes caller InputStream between retry attempts Signed-off-by: Arnab Nandy --- .../implementation/http/rest/LengthValidatingInputStream.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java index b97552d93c7b..6f4d4215069a 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java @@ -81,7 +81,8 @@ public int available() throws IOException { @Override public void close() throws IOException { - inner.close(); + // No-op. The user/caller is responsible for closing the underlying stream's lifecycle, + // in line with the BinaryData.fromStream contract. Closing it here breaks stream replayability on retries. } @Override From 40b38d6206b5c2ccfd7907f141db2fa03e8e4b60 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 01:24:14 +0530 Subject: [PATCH 02/12] [core] Add unit test for LengthValidatingInputStream close behavior Signed-off-by: Arnab Nandy --- .../http/rest/RestProxyUtilsTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index 076c28fc8cde..0a99c3d019bb 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -210,6 +210,25 @@ public void expectedBodyLengthSync() throws IOException { } } + @Test + public void lengthValidatingInputStreamCloseDoesNotCloseUnderlying() throws IOException { + final boolean[] closed = new boolean[1]; + InputStream innerStream = new ByteArrayInputStream(EXPECTED) { + @Override + public void close() throws IOException { + closed[0] = true; + super.close(); + } + }; + + LengthValidatingInputStream validatingStream = new LengthValidatingInputStream(innerStream, EXPECTED.length); + + validatingStream.close(); + + // Assert that the underlying stream is still open (not closed) + assertTrue(!closed[0]); + } + private static Mono validateAndCollectRequestAsync(HttpRequest request) { return RestProxyUtils.validateLengthAsync(request) .flatMap(r -> FluxUtil.collectBytesInByteBufferStream(r.getBody())); From d5ff1a21023465826807e34f55f3742977e1427e Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 01:31:14 +0530 Subject: [PATCH 03/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../http/rest/RestProxyUtilsTests.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index 0a99c3d019bb..a26c94e14028 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -213,20 +213,22 @@ public void expectedBodyLengthSync() throws IOException { @Test public void lengthValidatingInputStreamCloseDoesNotCloseUnderlying() throws IOException { final boolean[] closed = new boolean[1]; - InputStream innerStream = new ByteArrayInputStream(EXPECTED) { + + try (InputStream innerStream = new ByteArrayInputStream(EXPECTED) { @Override public void close() throws IOException { closed[0] = true; super.close(); } - }; - - LengthValidatingInputStream validatingStream = new LengthValidatingInputStream(innerStream, EXPECTED.length); + }) { + LengthValidatingInputStream validatingStream = new LengthValidatingInputStream(innerStream, EXPECTED.length); - validatingStream.close(); + validatingStream.close(); - // Assert that the underlying stream is still open (not closed) - assertTrue(!closed[0]); + // Validate that closing the wrapper does not close the underlying stream. + org.junit.jupiter.api.Assertions.assertFalse(closed[0], + "LengthValidatingInputStream.close() must not close the underlying stream."); + } } private static Mono validateAndCollectRequestAsync(HttpRequest request) { From 9cb4ce564f76b1f2394b9e581393e30bb8dccb07 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 01:41:55 +0530 Subject: [PATCH 04/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../core/implementation/http/rest/RestProxyUtilsTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index a26c94e14028..c07164ffc056 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -226,8 +226,7 @@ public void close() throws IOException { validatingStream.close(); // Validate that closing the wrapper does not close the underlying stream. - org.junit.jupiter.api.Assertions.assertFalse(closed[0], - "LengthValidatingInputStream.close() must not close the underlying stream."); + assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); } } From c93628411c683dd62178402c91fe6dde4b9acbc1 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 01:59:42 +0530 Subject: [PATCH 05/12] [core] Add CHANGELOG entry for LengthValidatingInputStream bug fix Signed-off-by: Arnab Nandy --- sdk/core/azure-core/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index a65de8736a2b..810b7d54ec38 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fixed a bug where `InputStreamContent` wrapped in `LengthValidatingInputStream` could prematurely close the underlying stream between retry attempts, breaking stream replayability. ([#49650](https://github.com/Azure/azure-sdk-for-java/pull/49650)) + ### Other Changes ## 1.58.1 (2026-06-08) From c909ffd071f86d0b0acc2a0725756e097123fbf5 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 02:04:57 +0530 Subject: [PATCH 06/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../core/implementation/http/rest/RestProxyUtilsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index c07164ffc056..5c4035818827 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -226,7 +226,7 @@ public void close() throws IOException { validatingStream.close(); // Validate that closing the wrapper does not close the underlying stream. - assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); + org.junit.jupiter.api.Assertions.assertFalse(closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); } } From 6d852c0a980121021fa7526a5b5312243d826b45 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 02:11:05 +0530 Subject: [PATCH 07/12] [core] Update CHANGELOG and resolve flakiness in UrlBuilderTests Signed-off-by: Arnab Nandy --- sdk/core/azure-core/CHANGELOG.md | 2 +- .../core/implementation/http/rest/RestProxyUtilsTests.java | 6 ++++-- .../src/test/java/com/azure/core/util/UrlBuilderTests.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 810b7d54ec38..ae8bccc04b14 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -8,7 +8,7 @@ ### Bugs Fixed -- Fixed a bug where `InputStreamContent` wrapped in `LengthValidatingInputStream` could prematurely close the underlying stream between retry attempts, breaking stream replayability. ([#49650](https://github.com/Azure/azure-sdk-for-java/pull/49650)) +- Fixed a bug where retrying requests with bodies created from a mark/reset-capable `InputStream` could fail because the stream was closed between retry attempts. ([#49650](https://github.com/Azure/azure-sdk-for-java/pull/49650)) ### Other Changes diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index 5c4035818827..2c7dfad12e93 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -221,12 +221,14 @@ public void close() throws IOException { super.close(); } }) { - LengthValidatingInputStream validatingStream = new LengthValidatingInputStream(innerStream, EXPECTED.length); + LengthValidatingInputStream validatingStream + = new LengthValidatingInputStream(innerStream, EXPECTED.length); validatingStream.close(); // Validate that closing the wrapper does not close the underlying stream. - org.junit.jupiter.api.Assertions.assertFalse(closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); + org.junit.jupiter.api.Assertions.assertFalse(closed[0], + "LengthValidatingInputStream.close() must not close the underlying stream."); } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java index fb72aec976f8..d2eef68379b5 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java @@ -707,7 +707,7 @@ public void parallelParsing() throws InterruptedException { return UrlBuilder.parse("https://example" + i + ".com"); }).collect(Collectors.toCollection(() -> new ArrayList<>(20000))); - List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 10, TimeUnit.SECONDS); + List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 60, TimeUnit.SECONDS); for (Future future : futures) { assertTrue(future.isDone()); assertDoesNotThrow(() -> future.get()); @@ -726,7 +726,7 @@ public void fluxParallelParsing() { return UrlBuilder.parse("https://example" + i + ".com"); }) .then() - .timeout(Duration.ofSeconds(10)); + .timeout(Duration.ofSeconds(60)); StepVerifier.create(mono).verifyComplete(); assertEquals(20000, callCount.get()); From c705ea0a788581a4d6ffdbc598d6a54d9ee0351d Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 16:48:13 +0530 Subject: [PATCH 08/12] Adhered to all the review comments from copilot --- .../rest/LengthValidatingInputStream.java | 4 +- .../http/rest/RestProxyUtilsTests.java | 43 ++++++++++++++++--- .../com/azure/core/util/UrlBuilderTests.java | 4 +- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java index 6f4d4215069a..0e1ef8cdf438 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java @@ -81,8 +81,8 @@ public int available() throws IOException { @Override public void close() throws IOException { - // No-op. The user/caller is responsible for closing the underlying stream's lifecycle, - // in line with the BinaryData.fromStream contract. Closing it here breaks stream replayability on retries. + // No-op. RestProxy length validation can wrap InputStreamContent during retryable requests. Closing the + // wrapper must not prematurely close the underlying stream between retry attempts. } @Override diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index 2c7dfad12e93..adfd8f203c48 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -29,6 +29,7 @@ import static com.azure.core.CoreTestUtils.assertArraysEqual; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -214,21 +215,53 @@ public void expectedBodyLengthSync() throws IOException { public void lengthValidatingInputStreamCloseDoesNotCloseUnderlying() throws IOException { final boolean[] closed = new boolean[1]; - try (InputStream innerStream = new ByteArrayInputStream(EXPECTED) { + try (InputStream innerStream = new InputStream() { + private final ByteArrayInputStream delegate = new ByteArrayInputStream(EXPECTED); + + private void ensureOpen() throws IOException { + if (closed[0]) { + throw new IOException("Stream closed"); + } + } + @Override public void close() throws IOException { closed[0] = true; - super.close(); + delegate.close(); + } + + @Override + public synchronized int read() throws IOException { + ensureOpen(); + return delegate.read(); + } + + @Override + public synchronized void mark(int readlimit) { + delegate.mark(readlimit); + } + + @Override + public synchronized void reset() throws IOException { + ensureOpen(); + delegate.reset(); + } + + @Override + public boolean markSupported() { + return delegate.markSupported(); } }) { LengthValidatingInputStream validatingStream = new LengthValidatingInputStream(innerStream, EXPECTED.length); + validatingStream.mark(EXPECTED.length); + assertEquals(EXPECTED[0], validatingStream.read()); validatingStream.close(); + validatingStream.reset(); - // Validate that closing the wrapper does not close the underlying stream. - org.junit.jupiter.api.Assertions.assertFalse(closed[0], - "LengthValidatingInputStream.close() must not close the underlying stream."); + assertFalse(closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); + assertEquals(EXPECTED[0], validatingStream.read()); } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java index d2eef68379b5..fb72aec976f8 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java @@ -707,7 +707,7 @@ public void parallelParsing() throws InterruptedException { return UrlBuilder.parse("https://example" + i + ".com"); }).collect(Collectors.toCollection(() -> new ArrayList<>(20000))); - List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 60, TimeUnit.SECONDS); + List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 10, TimeUnit.SECONDS); for (Future future : futures) { assertTrue(future.isDone()); assertDoesNotThrow(() -> future.get()); @@ -726,7 +726,7 @@ public void fluxParallelParsing() { return UrlBuilder.parse("https://example" + i + ".com"); }) .then() - .timeout(Duration.ofSeconds(60)); + .timeout(Duration.ofSeconds(10)); StepVerifier.create(mono).verifyComplete(); assertEquals(20000, callCount.get()); From d86ff466686c81f0698b061e220be77e8d1e7fba Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 17:52:15 +0530 Subject: [PATCH 09/12] Review fixes --- .../http/rest/RestProxyUtilsTests.java | 21 ++++++++++++------- .../com/azure/core/util/UrlBuilderTests.java | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index adfd8f203c48..debacd135d53 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -253,15 +253,22 @@ public boolean markSupported() { } }) { LengthValidatingInputStream validatingStream - = new LengthValidatingInputStream(innerStream, EXPECTED.length); - + = new LengthValidatingInputStream(innerStream, EXPECTED.length);; + // Simulate the retry scenario: the wrapper is closed after an attempt, then the pipeline tries to reset. validatingStream.mark(EXPECTED.length); - assertEquals(EXPECTED[0], validatingStream.read()); - validatingStream.close(); - validatingStream.reset(); + assertTrue(validatingStream.read() != -1); - assertFalse(closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); - assertEquals(EXPECTED[0], validatingStream.read()); + validatingStream.close(); + + try { + validatingStream.reset(); + } catch (IOException e) { + fail("Expected LengthValidatingInputStream.reset() to succeed after close(), but it failed.", e); + } + byte[] actual = new byte[EXPECTED.length]; + assertEquals(EXPECTED.length, validatingStream.read(actual)); + assertArraysEqual(EXPECTED, actual); + assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java index fb72aec976f8..d2eef68379b5 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java @@ -707,7 +707,7 @@ public void parallelParsing() throws InterruptedException { return UrlBuilder.parse("https://example" + i + ".com"); }).collect(Collectors.toCollection(() -> new ArrayList<>(20000))); - List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 10, TimeUnit.SECONDS); + List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 60, TimeUnit.SECONDS); for (Future future : futures) { assertTrue(future.isDone()); assertDoesNotThrow(() -> future.get()); @@ -726,7 +726,7 @@ public void fluxParallelParsing() { return UrlBuilder.parse("https://example" + i + ".com"); }) .then() - .timeout(Duration.ofSeconds(10)); + .timeout(Duration.ofSeconds(60)); StepVerifier.create(mono).verifyComplete(); assertEquals(20000, callCount.get()); From c2591a07384abfccd92a267d6da7407ef229de0e Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 18:18:07 +0530 Subject: [PATCH 10/12] Fix RestProxyUtilsTests formatting Apply Spotless formatting to the strengthened close/reset regression test and remove an accidental duplicate semicolon. --- .../http/rest/RestProxyUtilsTests.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index debacd135d53..2219bd879167 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -253,22 +253,22 @@ public boolean markSupported() { } }) { LengthValidatingInputStream validatingStream - = new LengthValidatingInputStream(innerStream, EXPECTED.length);; + = new LengthValidatingInputStream(innerStream, EXPECTED.length); // Simulate the retry scenario: the wrapper is closed after an attempt, then the pipeline tries to reset. validatingStream.mark(EXPECTED.length); assertTrue(validatingStream.read() != -1); validatingStream.close(); - + try { - validatingStream.reset(); - } catch (IOException e) { - fail("Expected LengthValidatingInputStream.reset() to succeed after close(), but it failed.", e); - } - byte[] actual = new byte[EXPECTED.length]; - assertEquals(EXPECTED.length, validatingStream.read(actual)); - assertArraysEqual(EXPECTED, actual); - assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); + validatingStream.reset(); + } catch (IOException e) { + fail("Expected LengthValidatingInputStream.reset() to succeed after close(), but it failed.", e); + } + byte[] actual = new byte[EXPECTED.length]; + assertEquals(EXPECTED.length, validatingStream.read(actual)); + assertArraysEqual(EXPECTED, actual); + assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); } } From 2f36e12314844f43125d96562be5628c105449b7 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 18:23:56 +0530 Subject: [PATCH 11/12] Address latest stream retry review comments Document caller-owned stream handling in LengthValidatingInputStream, use assertFalse in the close/reset regression test, and revert unrelated UrlBuilder timeout increases. --- .../implementation/http/rest/LengthValidatingInputStream.java | 4 ++-- .../core/implementation/http/rest/RestProxyUtilsTests.java | 2 +- .../src/test/java/com/azure/core/util/UrlBuilderTests.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java index 0e1ef8cdf438..c7eb7bdc1bf8 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java @@ -81,8 +81,8 @@ public int available() throws IOException { @Override public void close() throws IOException { - // No-op. RestProxy length validation can wrap InputStreamContent during retryable requests. Closing the - // wrapper must not prematurely close the underlying stream between retry attempts. + // No-op. RestProxy length validation can wrap caller-owned InputStreamContent. Closing this wrapper must not + // close the underlying stream, including between retry attempts where the caller-owned stream needs to be reset. } @Override diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java index 2219bd879167..858df651ec36 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/implementation/http/rest/RestProxyUtilsTests.java @@ -268,7 +268,7 @@ public boolean markSupported() { byte[] actual = new byte[EXPECTED.length]; assertEquals(EXPECTED.length, validatingStream.read(actual)); assertArraysEqual(EXPECTED, actual); - assertTrue(!closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); + assertFalse(closed[0], "LengthValidatingInputStream.close() must not close the underlying stream."); } } diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java index d2eef68379b5..fb72aec976f8 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/UrlBuilderTests.java @@ -707,7 +707,7 @@ public void parallelParsing() throws InterruptedException { return UrlBuilder.parse("https://example" + i + ".com"); }).collect(Collectors.toCollection(() -> new ArrayList<>(20000))); - List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 60, TimeUnit.SECONDS); + List> futures = SharedExecutorService.getInstance().invokeAll(tasks, 10, TimeUnit.SECONDS); for (Future future : futures) { assertTrue(future.isDone()); assertDoesNotThrow(() -> future.get()); @@ -726,7 +726,7 @@ public void fluxParallelParsing() { return UrlBuilder.parse("https://example" + i + ".com"); }) .then() - .timeout(Duration.ofSeconds(60)); + .timeout(Duration.ofSeconds(10)); StepVerifier.create(mono).verifyComplete(); assertEquals(20000, callCount.get()); From a16b24926e2b5fc783a5442c9c0c6ff7c8a2efde Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 27 Jun 2026 18:45:57 +0530 Subject: [PATCH 12/12] Removed unnecessary exception --- .../implementation/http/rest/LengthValidatingInputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java index c7eb7bdc1bf8..ad72cc5493b7 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/LengthValidatingInputStream.java @@ -80,7 +80,7 @@ public int available() throws IOException { } @Override - public void close() throws IOException { + public void close() { // No-op. RestProxy length validation can wrap caller-owned InputStreamContent. Closing this wrapper must not // close the underlying stream, including between retry attempts where the caller-owned stream needs to be reset. }