Skip to content

Commit 93e14e0

Browse files
committed
allow to specify timeout as a string time value (i.e. "2s") when getting from a future
1 parent 9846847 commit 93e14e0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionFuture.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public interface ActionFuture<T> extends Future<T> {
3939
*/
4040
T actionGet() throws ElasticSearchException;
4141

42+
/**
43+
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
44+
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
45+
* cause of the {@link java.util.concurrent.ExecutionException}.
46+
*/
47+
T actionGet(String timeout) throws ElasticSearchException;
48+
4249
/**
4350
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
4451
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual

modules/elasticsearch/src/main/java/org/elasticsearch/action/support/PlainActionFuture.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public PlainActionFuture() {
111111
}
112112
}
113113

114+
@Override public T actionGet(String timeout) throws ElasticSearchException {
115+
return actionGet(TimeValue.parseTimeValue(timeout, null));
116+
}
117+
114118
@Override public T actionGet(long timeoutMillis) throws ElasticSearchException {
115119
return actionGet(timeoutMillis, TimeUnit.MILLISECONDS);
116120
}

0 commit comments

Comments
 (0)