Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nearline-storage: fix NPE on error path
Motivation: The AbstractBlockingNearlineStorage.Task#run uses thread bind-release mechanist to associate a task with a thread. Finally, a catch block is used to process uncaught exception with the bound thread. However, the `release` call between releases the bound thread, which is a source of NPE: ``` try { bind(); // thread = Thread.currentThread() ... release(); // thread = null; } catch( Throwable t) { thread.uncaughtException(thread, e); } ``` java.lang.NullPointerException: null at org.dcache.pool.nearline.AbstractBlockingNearlineStorage$Task.run(AbstractBlockingNearlineStorage.java:390) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Modification: make sure that uncaughtException is executed by current thread, independent of it's binding state. Change the variable name to avoid method variable and class field name conflict. Result: No NPE Ref: #6426 Acked-by: Marina Sahakyan Target: master, 8.2, 8.1, 8.0, 7.2 Require-book: no Require-notes: yes (cherry picked from commit b708a6c) Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
- Loading branch information