Skip to content

ConcurrencyThrottleSupport and thread interruption #36167

@ooraini

Description

@ooraini

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...?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions