I was trying to use this, in Java, to return a (Future) String if getDownload() takes less than 5 secs, and return / throw an exception if getDownload() takes more than 5 seconds.
Future<String> futureDownload = getDownload(); return futureDownload.within(DefaultTimer.twitter(), Duration.fromSeconds(5));
I cannot get it to work. If getDownload() takes, for example, 15 secs, it returns after 15 secs.
What am I missing?
In your case you should use Await.result instead.