Describe the bug
Found while reading #6481 — the same class of interrupt-handling bug exists in a different module.
In WorkersAiEmbeddingModel.embedAll() (module langchain4j-workers-ai), there are two problems:
- Line 202-203:
catch (InterruptedException | ExecutionException e) rethrows but never restores the interrupt flag.
- Line 210-212 (the
finally block): catch (InterruptedException e) { executor.shutdownNow(); } swallows the exception entirely — no flag restore, no rethrow, no logging.
Log and Stack trace
Nothing gets logged. The interrupt status is silently cleared, same as described in #6481.
To Reproduce
No runtime reproduction yet — found by code inspection while reading #6481.
Call embedAll() on a WorkersAiEmbeddingModel and interrupt the calling thread while the request is in flight, then check Thread.currentThread().isInterrupted() in the catch block. It is false.
Expected behavior
The interrupt flag should be restored via Thread.currentThread().interrupt() so callers relying on Thread.interrupted() can observe the interruption, following the pattern used in the fix for #6411 (DockerMcpTransport).
Note the fix should also split the combined catch (InterruptedException | ExecutionException e) into two blocks — only InterruptedException should restore the flag, since ExecutionException means the task itself failed and the thread was not interrupted.
Please complete the following information:
- LangChain4j version: main branch (current)
- LLM(s) used: N/A (not LLM-specific)
- Java version: 17
- Spring Boot version (if applicable): N/A
Additional context
Happy to open a PR for this. Also happy to coordinate with anyone already working on it — just let me know.
Describe the bug
Found while reading #6481 — the same class of interrupt-handling bug exists in a different module.
In
WorkersAiEmbeddingModel.embedAll()(modulelangchain4j-workers-ai), there are two problems:catch (InterruptedException | ExecutionException e)rethrows but never restores the interrupt flag.finallyblock):catch (InterruptedException e) { executor.shutdownNow(); }swallows the exception entirely — no flag restore, no rethrow, no logging.Log and Stack trace
Nothing gets logged. The interrupt status is silently cleared, same as described in #6481.
To Reproduce
No runtime reproduction yet — found by code inspection while reading #6481.
Call
embedAll()on a WorkersAiEmbeddingModel and interrupt the calling thread while the request is in flight, then checkThread.currentThread().isInterrupted()in the catch block. It isfalse.Expected behavior
The interrupt flag should be restored via
Thread.currentThread().interrupt()so callers relying onThread.interrupted()can observe the interruption, following the pattern used in the fix for #6411 (DockerMcpTransport).Note the fix should also split the combined
catch (InterruptedException | ExecutionException e)into two blocks — onlyInterruptedExceptionshould restore the flag, sinceExecutionExceptionmeans the task itself failed and the thread was not interrupted.Please complete the following information:
Additional context
Happy to open a PR for this. Also happy to coordinate with anyone already working on it — just let me know.