Skip to content

Commit

Permalink
Internal: AdapterActionFuture should not set currentThread().interrupt()
Browse files Browse the repository at this point in the history
If someone blocks on it and it is interrupted, we throw an ElasticsearchIllegalStateException. We should not set Thread.currentThread().interrupt(); in this case because we already communicate the interrupt through an exception.

Similar to #9001

Closes #9141
  • Loading branch information
bleskes committed Jan 6, 2015
1 parent 1c2b2e7 commit e0c4a64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 15 additions & 15 deletions src/main/java/org/elasticsearch/action/ActionFuture.java
Expand Up @@ -34,9 +34,9 @@
public interface ActionFuture<T> extends Future<T> {

/**
* Similar to {@link #get()}, just catching the {@link InterruptedException} with
* restoring the interrupted state on the thread and throwing an {@link org.elasticsearch.ElasticsearchIllegalStateException},
* and throwing the actual cause of the {@link java.util.concurrent.ExecutionException}.
* Similar to {@link #get()}, just catching the {@link InterruptedException} and throwing
* an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches
* {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.
* <p/>
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
Expand All @@ -45,9 +45,9 @@ public interface ActionFuture<T> extends Future<T> {
T actionGet() throws ElasticsearchException;

/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} with
* restoring the interrupted state on the thread and throwing an {@link org.elasticsearch.ElasticsearchIllegalStateException},
* and throwing the actual cause of the {@link java.util.concurrent.ExecutionException}.
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} and throwing
* an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches
* {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.
* <p/>
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
Expand All @@ -56,9 +56,9 @@ public interface ActionFuture<T> extends Future<T> {
T actionGet(String timeout) throws ElasticsearchException;

/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} with
* restoring the interrupted state on the thread and throwing an {@link org.elasticsearch.ElasticsearchIllegalStateException},
* and throwing the actual cause of the {@link java.util.concurrent.ExecutionException}.
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} and throwing
* an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches
* {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.
* <p/>
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
Expand All @@ -69,9 +69,9 @@ public interface ActionFuture<T> extends Future<T> {
T actionGet(long timeoutMillis) throws ElasticsearchException;

/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} with
* restoring the interrupted state on the thread and throwing an {@link org.elasticsearch.ElasticsearchIllegalStateException},
* and throwing the actual cause of the {@link java.util.concurrent.ExecutionException}.
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} and throwing
* an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches
* {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.
* <p/>
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
Expand All @@ -80,9 +80,9 @@ public interface ActionFuture<T> extends Future<T> {
T actionGet(long timeout, TimeUnit unit) throws ElasticsearchException;

/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} with
* restoring the interrupted state on the thread and throwing an {@link org.elasticsearch.ElasticsearchIllegalStateException},
* and throwing the actual cause of the {@link java.util.concurrent.ExecutionException}.
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just catching the {@link InterruptedException} and throwing
* an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches
* {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.
* <p/>
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
Expand Down
Expand Up @@ -44,7 +44,6 @@ public T actionGet() throws ElasticsearchException {
try {
return get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ElasticsearchIllegalStateException("Future got interrupted", e);
} catch (ExecutionException e) {
throw rethrowExecutionException(e);
Expand Down Expand Up @@ -73,7 +72,6 @@ public T actionGet(long timeout, TimeUnit unit) throws ElasticsearchException {
} catch (TimeoutException e) {
throw new ElasticsearchTimeoutException(e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ElasticsearchIllegalStateException("Future got interrupted", e);
} catch (ExecutionException e) {
throw rethrowExecutionException(e);
Expand Down

0 comments on commit e0c4a64

Please sign in to comment.