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 cd251f23a9 HDDS-11438. Ensure DataInputBuffer is closed in 
OMPBHelper#convert (#7182)
cd251f23a9 is described below

commit cd251f23a9f660ab514973b87668e00c9564faca
Author: len548 <[email protected]>
AuthorDate: Wed Sep 11 18:02:11 2024 +0200

    HDDS-11438. Ensure DataInputBuffer is closed in OMPBHelper#convert (#7182)
---
 .../java/org/apache/hadoop/ozone/protocolPB/OMPBHelper.java  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/protocolPB/OMPBHelper.java
 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/protocolPB/OMPBHelper.java
index ccb2080a87..e28c9477f2 100644
--- 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/protocolPB/OMPBHelper.java
+++ 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/protocolPB/OMPBHelper.java
@@ -242,11 +242,13 @@ public final class OMPBHelper {
     DataOutputBuffer buf = new DataOutputBuffer();
     checksum.write(buf);
     byte[] bytes = buf.getData();
-    DataInputBuffer buffer = new DataInputBuffer();
-    buffer.reset(bytes, 0, bytes.length);
-    int bytesPerCRC = buffer.readInt();
-    long crcPerBlock = buffer.readLong();
-    buffer.close();
+    int bytesPerCRC;
+    long crcPerBlock;
+    try (DataInputBuffer buffer = new DataInputBuffer()) {
+      buffer.reset(bytes, 0, bytes.length);
+      bytesPerCRC = buffer.readInt();
+      crcPerBlock = buffer.readLong();
+    }
 
     int offset = Integer.BYTES + Long.BYTES;
     ByteString byteString = ByteString.copyFrom(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to