anton-vinogradov commented on code in PR #13296:
URL: https://github.com/apache/ignite/pull/13296#discussion_r3579343004


##########
modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java:
##########
@@ -443,12 +457,16 @@ public ByteBuffer getBuffer() {
     @Override public void beforeNestedWrite() {
         state.forward();
 
-        state.item().stream.setBuffer(buf);
+        curStream = state.item().stream;
+
+        curStream.setBuffer(buf);
     }
 
     /** {@inheritDoc} */
     @Override public void afterNestedWrite(boolean finished) {
         state.backward(finished);
+
+        curStream = state.item().stream;

Review Comment:
   Currently the buffer instance can only change between write attempts, while 
the state stack is fully unwound: the caller invokes `setBuffer()` at the top 
level before each attempt, and the attempt then re-descends through every 
nesting level, so `beforeNestedWrite()` re-propagates the current buffer to 
every inner stream before it is used. So on exit the outer stream cannot hold a 
stale buffer today. But this invariant is non-local (it depends on caller 
behavior), and `DirectByteBufferStream.setBuffer()` is a no-op for the same 
instance (single reference comparison), so the defensive call is effectively 
free — added in 7cbbc8bec3a.



-- 
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