ConcurrencyThrottleSupport and thread interruption
ConcurrencyThrottleSupport handles interruption when waiting on its concurrencyCondition by re-interrupting the thread and throwing an IllegalStateException. This makes things slightly awkward to handle up the stack.
Suggestion: re-interrupt but don't throw IllegalStateException, instead return normally and let higher level clients handle it. In the case of ConcurrencyThrottleInterceptor it would do this:
@Override public @Nullable Object invoke(MethodInvocation methodInvocation) throws Throwable { beforeAccess(); if (Thread.interrupted()) { // clear throw new InterruptedException(); // not my problem } try { return methodInvocation.proceed(); } finally { afterAccess(); } }
As is right now it makes things awkward to deal with. I just wrote the following code:
catch (IllegalStateException e) { if (Thread.currentThread().isInterrupted() && Thread.interrupted()) { // clear; VERY IMPORTANT interrupted = true; } // handle e }
I think this is a bug...?