-
Type: Task
-
Resolution: Done
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
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.