Skip to content

Restore the interrupted thread status in the provided backoff policies #386

Closed
@mlichtblau

Description

@mlichtblau

It is good practice to restore the interrupted flag of the current thread when InterruptedException cannot be thrown.

From Java Concurrency in Practice1:

Sometimes you cannot throw InterruptedException, for instance when your code is part of a Runnable. In these situations, you must catch InterruptedException and restore the interrupted status by calling interrupt on the current thread

The provided backoff policies (e.g. FixedBackOffPolicy, ExponentialBackOffPolicy) throw a BackOffInterruptedException without restoring the flag.

Do you think it is possible to restore the flag before throwing the runtime exception?
I can open a PR.

Thank you!

Footnotes

  1. Google Books

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions