Uploaded image for project: 'Reactive Streams Java Driver'
  1. Reactive Streams Java Driver
  2. JAVARS-189

Possible race condition when initializing client

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.11
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      See attached file. When I create a connection and then immediately try to query it, I get a null pointer (stack trace below). But when I add a 1 second delay after before querying, it works as expected. It seems like the initialization is done asynchronously, but then the client attempts to do work before it's fully initialized.

      java.lang.NullPointerException 
      at com.mongodb.async.client.ClientSessionHelper.getServerDescriptionListToConsiderForSessionSupport(ClientSessionHelper.java:107)
      at com.mongodb.async.client.ClientSessionHelper.createClientSession(ClientSessionHelper.java:63)
      at com.mongodb.async.client.ClientSessionHelper.withClientSession(ClientSessionHelper.java:51)
      at com.mongodb.async.client.OperationExecutorImpl.execute(OperationExecutorImpl.java:66) at com.mongodb.async.client.FindIterableImpl.first(FindIterableImpl.java:198) 
      at com.mongodb.reactivestreams.client.internal.FindPublisherImpl$1.apply(FindPublisherImpl.java:47)
      at com.mongodb.reactivestreams.client.internal.FindPublisherImpl$1.apply(FindPublisherImpl.java:44)
      at com.mongodb.async.client.SingleResultCallbackSubscription.requestInitialData(SingleResultCallbackSubscription.java:38) at com.mongodb.async.client.AbstractSubscription.tryRequestInitialData(AbstractSubscription.java:151)
      at com.mongodb.async.client.AbstractSubscription.request(AbstractSubscription.java:84)
      at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1$1.request(ObservableToPublisher.java:50) at com.iseecars.mongotest.Main$1.onSubscribe(Main.java:31) 
      at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1.onSubscribe(ObservableToPublisher.java:39) at com.mongodb.async.client.SingleResultCallbackSubscription.<init>(SingleResultCallbackSubscription.java:33)
      at com.mongodb.async.client.Observables$2.subscribe(Observables.java:78) 
      at com.mongodb.reactivestreams.client.internal.ObservableToPublisher.subscribe(ObservableToPublisher.java:36) 
      at com.iseecars.mongotest.Main.main(Main.java:50)
      

       

       

        Attachments

        1. Main.java
          1 kB
          Mike Baranczak

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              mike@iseecars.com Mike Baranczak
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: