Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3407

Async change stream cursor should protect against multiple calls to close

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.11.1
    • Affects Version/s: None
    • Component/s: Async
    • Labels:
      None

      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

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: