This is an automated email from the ASF dual-hosted git repository.

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new a5490281e [#1472] fix(client): IlegalReferenceCountException for 
clientReadHandler.readShuffleData (#1536)
a5490281e is described below

commit a5490281ee122cc3b6aa1c50e5cfc0e53bba0f77
Author: RickyMa <[email protected]>
AuthorDate: Sat Feb 24 16:21:21 2024 +0800

    [#1472] fix(client): IlegalReferenceCountException for 
clientReadHandler.readShuffleData (#1536)
    
    ### What changes were proposed in this pull request?
    
    Fix IllegalReferenceCountException issues when exceptions happened in 
clientReadHandler.readShuffleData().
    
    ### Why are the changes needed?
    
    A follow-up PR for: https://github.com/apache/incubator-uniffle/pull/1522
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UTs.
---
 .../java/org/apache/uniffle/client/impl/ShuffleReadClientImpl.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/client/src/main/java/org/apache/uniffle/client/impl/ShuffleReadClientImpl.java
 
b/client/src/main/java/org/apache/uniffle/client/impl/ShuffleReadClientImpl.java
index e1fbb9fec..28318124f 100644
--- 
a/client/src/main/java/org/apache/uniffle/client/impl/ShuffleReadClientImpl.java
+++ 
b/client/src/main/java/org/apache/uniffle/client/impl/ShuffleReadClientImpl.java
@@ -270,6 +270,10 @@ public class ShuffleReadClientImpl implements 
ShuffleReadClient {
     // because PlatformDependent.freeDirectBuffer can only release the 
ByteBuffer with cleaner.
     if (sdr != null) {
       sdr.release();
+      // We set sdr to null here to prevent IllegalReferenceCountException 
that could occur
+      // if sdr.release() is called multiple times in the close() method,
+      // when an exception is thrown by clientReadHandler.readShuffleData().
+      sdr = null;
     }
     sdr = clientReadHandler.readShuffleData();
     readDataTime.addAndGet(System.currentTimeMillis() - start);

Reply via email to