This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 2614f440f RATIS-1963. Restore ZeroCopyMessageMarhaller#popStream (#984)
2614f440f is described below
commit 2614f440f5d4098a30664e58ec3e01e66b6bfa6a
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Mon Dec 11 18:58:52 2023 +0100
RATIS-1963. Restore ZeroCopyMessageMarhaller#popStream (#984)
---
.../apache/ratis/grpc/util/ZeroCopyMessageMarshaller.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git
a/ratis-grpc/src/main/java/org/apache/ratis/grpc/util/ZeroCopyMessageMarshaller.java
b/ratis-grpc/src/main/java/org/apache/ratis/grpc/util/ZeroCopyMessageMarshaller.java
index f415fb006..bb8183a24 100644
---
a/ratis-grpc/src/main/java/org/apache/ratis/grpc/util/ZeroCopyMessageMarshaller.java
+++
b/ratis-grpc/src/main/java/org/apache/ratis/grpc/util/ZeroCopyMessageMarshaller.java
@@ -118,7 +118,7 @@ public class ZeroCopyMessageMarshaller<T extends
MessageLite> implements Prototy
/** Release the underlying buffers in the given message. */
public void release(T message) {
- final InputStream stream = unclosedStreams.remove(message);
+ final InputStream stream = popStream(message);
if (stream == null) {
return;
}
@@ -213,4 +213,13 @@ public class ZeroCopyMessageMarshaller<T extends
MessageLite> implements Prototy
throw e;
}
}
-}
\ No newline at end of file
+
+ /**
+ * Application can call this function to get the stream for the message, and,
+ * possibly later, must call {@link InputStream#close()} to release buffers.
+ * Alternatively, use {@link #release(T)} to do both in one step.
+ */
+ public InputStream popStream(T message) {
+ return unclosedStreams.remove(message);
+ }
+}