Skip to content

Commit 30339ac

Browse files
committed
Never release store using CancellableThreads
1 parent 67a81ab commit 30339ac

File tree

5 files changed

+148
-136
lines changed

5 files changed

+148
-136
lines changed

server/src/main/java/org/elasticsearch/common/util/CancellableThreads.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,12 @@ public interface OnCancel {
206206
*/
207207
void onCancel(String reason, @Nullable Exception beforeCancelException);
208208
}
209+
210+
/**
211+
* Returns {@code true} if the current thread is being executed using {@link CancellableThreads} or was interrupted.
212+
*/
213+
public synchronized boolean isCurrentThreadCancellable() {
214+
final Thread currentThread = Thread.currentThread();
215+
return currentThread.isInterrupted() || threads.contains(currentThread);
216+
}
209217
}

0 commit comments

Comments
 (0)