Spot the bug in the blocking worker

from Exceptions
Java 25 LTS intermediate 4 min 1 issue to find

Find the cancellation bug in this blocking worker helper.

Java
import java.util.concurrent.BlockingQueue;

class Worker {
    static String awaitResult(BlockingQueue<String> results) {
        try {
            return results.take();
        } catch (InterruptedException ignored) {
            return "timeout";
        }
    }
}
Open in playground
Report an error