Skip to content

[BUG] WorkersAiEmbeddingModel swallows InterruptedException and loses interrupt status #6482

Description

@huoyu48

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:

  1. Line 202-203: catch (InterruptedException | ExecutionException e) rethrows but never restores the interrupt flag.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions