Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
None
-
None
Description
This should interrupt the change stream:
final Thread t = |
new Thread( |
() -> {
|
try { |
for (final ChangeStreamDocument<Document> doc : collection.watch()) { |
System.out.println(doc);
|
}
|
} catch (final MongoInterruptedException e) { |
System.out.println("interrupted"); |
}
|
});
|
|
|
t.start();
|
|
|
Thread.sleep(1000); |
|
|
t.interrupt();
|
t.join();
|
but it doesn't.
The workaround is to instead close the MongoCursor, but that's more awkward than just interrupting a thread.
There are a number of reasons why this doesn't work now:
- Sockets are not interruptible, so Thread.interrupt() is ignored when waiting on Socket.read
- Even if they were, MongoInterruptedException is treated as a retryable error for change streams. It should not be.
Attachments
Issue Links
- is duplicated by
-
JAVA-3291 ChangeStreamBatchCursor is not interruptable
-
- Closed
-