From 9090e0381f0042de0acff46e7c908788afd18386 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 5 Jan 2015 16:23:38 +0100 Subject: [PATCH] Internal: AdapterActionFuture should not set currentThread().interrupt() 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 --- .../elasticsearch/action/ActionFuture.java | 30 +++++++++---------- .../action/support/AdapterActionFuture.java | 2 -- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/ActionFuture.java b/src/main/java/org/elasticsearch/action/ActionFuture.java index 3848536b0d1..bca3730b61b 100644 --- a/src/main/java/org/elasticsearch/action/ActionFuture.java +++ b/src/main/java/org/elasticsearch/action/ActionFuture.java @@ -34,9 +34,9 @@ import java.util.concurrent.TimeUnit; public interface ActionFuture extends Future { /** - * 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. *

*

Note, the actual cause is unwrapped to the actual failure (for example, unwrapped * from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is @@ -45,9 +45,9 @@ public interface ActionFuture extends Future { 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. *

*

Note, the actual cause is unwrapped to the actual failure (for example, unwrapped * from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is @@ -56,9 +56,9 @@ public interface ActionFuture extends Future { 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. *

*

Note, the actual cause is unwrapped to the actual failure (for example, unwrapped * from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is @@ -69,9 +69,9 @@ public interface ActionFuture extends Future { 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. *

*

Note, the actual cause is unwrapped to the actual failure (for example, unwrapped * from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is @@ -80,9 +80,9 @@ public interface ActionFuture extends Future { 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. *

*

Note, the actual cause is unwrapped to the actual failure (for example, unwrapped * from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is diff --git a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java index f5acc4f0427..1aa0ead9217 100644 --- a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java +++ b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java @@ -44,7 +44,6 @@ public abstract class AdapterActionFuture extends BaseFuture implements try { return get(); } catch (InterruptedException e) { - Thread.currentThread().interrupt(); throw new ElasticsearchIllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { throw rethrowExecutionException(e); @@ -73,7 +72,6 @@ public abstract class AdapterActionFuture extends BaseFuture implements } 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);