-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Change Streams
-
None
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.
- is duplicated by
-
JAVA-3291 ChangeStreamBatchCursor is not interruptable
- Closed