Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      Steven Schlansker writes:

      Future.get(int, TimeUnit) is great, it allows you to put a timeout.

      Duration is great, it's a common way to cart a duration around, and some frameworks can parse it for you, say
      you have an injector (Spring in this case) that can handle:

      @Value("my-timeout:PT10s")
      Duration timeout;

      Now, you might obviously try to write:

      myFuture.get(timeout); // ARGH

      only to find out that instead you have to do some convoluted construction like

      myFuture.get(timeout.toMillis(), TimeUnit.MILLISECONDS); // :(

      How about a super simple added method to Future?

      default T get(Duration timeout) throws TimeoutException {
          return get(timeout.toMillis(), TimeUnit.MILLISECONDS); // maybe this should handle nanos, but you get the idea
      }

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: