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 } ``` -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org