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

Replace Timeout API with lambdas

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Java Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      It is too easy to encounter a race with the current methods, or to supply an incorrect infinite timeout value (0, -1) when calling an external method. This proposes to replace the existing Timeout non-static methods with a single "run" method. Usage example:

              return timeout.run(MILLISECONDS, (ms) ->

      {             collection.setTimeout(ms, MS);         }

      , () ->

      { // infinite:             collection.setTimeout(MS);         }

      , () ->

      {             throw new MongoOperationTimeoutException(DEFAULT_TIMEOUT_MESSAGE);         }

      );

       

      This should also remove TimePoint#hasExpired calling elapsed twice.

            Assignee:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Reporter:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: