[JAVA-3407] Async change stream cursor should protect against multiple calls to close Created: 27/Aug/19  Updated: 28/Oct/23  Resolved: 03/Sep/19

Status: Closed
Project: Java Driver
Component/s: Async
Affects Version/s: None
Fix Version/s: 3.11.1

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

AsyncChangeStreamBatchCursor#close doesn't protect against being called multiple times, which on the second invocation results in an extra release of the AsyncReadBinding.  

java.lang.IllegalStateException: Attempted to decrement the reference count below 0
	at com.mongodb.internal.binding.AbstractReferenceCounted.release(AbstractReferenceCounted.java:39)
	at com.mongodb.async.client.ClientSessionBinding.release(ClientSessionBinding.java:140)
	at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor.close(AsyncChangeStreamBatchCursor.java:87)
	at com.mongodb.async.client.MongoIterableSubscription.postTerminate(MongoIterableSubscription.java:69)
	at com.mongodb.async.client.AbstractSubscription.unsubscribe(AbstractSubscription.java:59)
	at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1$1.cancel(ObservableToPublisher.java:58)
	at com.mongodb.reactivestreams.client.syncadapter.SyncMongoCursor.close(SyncMongoCursor.java:78)
	at com.mongodb.reactivestreams.client.syncadapter.SyncChangeStreamIterable$1.close(SyncChangeStreamIterable.java:53)
	at com.mongodb.client.AbstractChangeStreamsTest.shouldPassAllOutcomes(AbstractChangeStreamsTest.java:120)

The close method should be protected, as it is in the synchronous driver



 Comments   
Comment by Githook User [ 10/Oct/19 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: Protect AsyncChangeStreamBatchCursor against multiple calls to close

JAVA-3407
Branch: 3.11.x
https://github.com/mongodb/mongo-java-driver/commit/5cf64ba9c44ea7cd99d9e4901cebcb4f01669214

Comment by Githook User [ 03/Sep/19 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: Protect AsyncChangeStreamBatchCursor against multiple calls to close

JAVA-3407
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/eb0e4acc435e95139e2c651538045149163c9252

Comment by Jeffrey Yemin [ 29/Aug/19 ]

Removed from epic since this is existing behavior.

Generated at Thu Feb 08 08:59:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.