reswqa commented on code in PR #20371:
URL: https://github.com/apache/flink/pull/20371#discussion_r931996374


##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/HsBufferContext.java:
##########
@@ -97,24 +97,34 @@ public Optional<CompletableFuture<Void>> getSpilledFuture() 
{
         return Optional.ofNullable(spilledFuture);
     }
 
+    /** Mark buffer status to release. */
     public void release() {
-        checkState(!released, "Release buffer repeatedly is unexpected.");
+        if (isReleased()) {
+            return;
+        }
         released = true;
         // decrease ref count when buffer is released from memory.
         buffer.recycleBuffer();
     }
 
-    public void startSpilling(CompletableFuture<Void> spilledFuture) {
-        checkState(!released, "Buffer is already released.");
-        checkState(
-                !spillStarted && this.spilledFuture == null,
-                "Spill buffer repeatedly is unexpected.");
+    /**
+     * Mark buffer status to startSpilling.
+     *
+     * @param spilledFuture completable future of this buffer's spilling 
operation.
+     * @return {@link Optional#empty()}, if spilling of the buffer has been 
started before or the
+     *     buffer has been released already; Optional of this buffer context, 
otherwise.
+     */
+    public Optional<HsBufferContext> startSpilling(CompletableFuture<Void> 
spilledFuture) {

Review Comment:
   Changed to return boolean.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to