[ 
https://issues.apache.org/jira/browse/HDFS-17749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17936874#comment-17936874
 ] 

ASF GitHub Bot commented on HDFS-17749:
---------------------------------------

KeeProMise commented on PR #7466:
URL: https://github.com/apache/hadoop/pull/7466#issuecomment-2737145924

   > ### Description of PR
   > May get wrong results due to the wrong usage of asyncComplete(null). Fix 
below RPCs : getMountPointStatus、getListing、getFileInfoAll、mkdirs
   > 
   > The root cause is as below:
   > 
   > ```java
   > asyncComplete(null);  // Handler thread
   > asyncApply(() -> {
   >      getFileInfo();  // issue a rpc request.
   >      asyncApply(); // AsyncRepsonder thread.
   > });
   > asyncApply(() -> {
   >   //do something.
   > });  // Handler thread, current thread's CompletableFuture object is in 
complete status.
   > ```
   > 
   > ### How was this patch tested?
   > Add unit tests TestRouterAsyncMountTable.java.
   > 
   > ### How to reproduce?
   > Use original codes to run TestRouterAsyncMountTable.java Some of unit 
tests will not pass due to the inaccurate results.
   ```java
   asyncComplete(null);  // Handler thread
   asyncApply(() -> {
        getFileInfo();  // issue a rpc request.
        asyncApply(); // AsyncRepsonder thread.
   });    // The handler thread variable will be set to the CompletableFuture 
object after the execution of asyncApply.
   ```
   look AsyncUtil#asyncApply(...)
   ```java
     public static <T, R> void asyncApply(ApplyFunction<T, R> function) {
       CompletableFuture<T> completableFuture =
           (CompletableFuture<T>) CUR_COMPLETABLE_FUTURE.get();
       assert completableFuture != null;
       CompletableFuture<R> result = function.apply(completableFuture);
       CUR_COMPLETABLE_FUTURE.set((CompletableFuture<Object>) result); // will 
reset CUR_COMPLETABLE_FUTURE use the CompletableFuture object after the 
execution
     }
   ```
   
   
   




> [ARR] Fix wrong results due to the wrong usage of asyncComplete(null)
> ---------------------------------------------------------------------
>
>                 Key: HDFS-17749
>                 URL: https://issues.apache.org/jira/browse/HDFS-17749
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: rbf
>            Reporter: farmmamba
>            Assignee: farmmamba
>            Priority: Major
>              Labels: pull-request-available
>
> Fix below RPCs : getMountPointStatus、getListing、getFIleinfoAll、mkdirs



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to