This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new c59a08d9de8 HDDS-14013. Release stream resources in
StreamBlockInputStream properly (#9374)
c59a08d9de8 is described below
commit c59a08d9de86547e156046fbc5b2a93f0c1bb17e
Author: Chung En Lee <[email protected]>
AuthorDate: Wed Nov 26 18:31:40 2025 +0800
HDDS-14013. Release stream resources in StreamBlockInputStream properly
(#9374)
---
.../org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java | 4 ++--
.../apache/hadoop/hdds/scm/storage/TestStreamBlockInputStream.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java
index cb2f80ca7c8..223ce65881f 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java
@@ -345,8 +345,8 @@ public ByteBuffer readNext() throws IOException {
}
private void releaseResources() {
- boolean wasNotYetComplete = semaphoreReleased.getAndSet(true);
- if (wasNotYetComplete) {
+ // release resources only if it was not yet completed
+ if (semaphoreReleased.compareAndSet(false, true)) {
releaseStreamResources(response);
}
}
diff --git
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestStreamBlockInputStream.java
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestStreamBlockInputStream.java
index b2cb3fb865c..83784499110 100644
---
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestStreamBlockInputStream.java
+++
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestStreamBlockInputStream.java
@@ -193,7 +193,7 @@ public void testErrorThrownIfStreamReturnsError() throws
IOException, Interrupte
return null;
}).when(xceiverClient).streamRead(any(), any());
assertThrows(IOException.class, () -> blockStream.read());
- verify(xceiverClient, times(0)).completeStreamRead(any());
+ verify(xceiverClient, times(1)).completeStreamRead(any());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]