Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Handling interrupt exception when blocking by future get invoked. #683

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/net/spy/memcached/MemcachedClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ public <T> CASResponse cas(String key, long casId, int exp, T value,
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.cancel(true);
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -996,6 +997,7 @@ public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.cancel(true);
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -1038,6 +1040,7 @@ public <T> T get(String key, Transcoder<T> tc) {
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.cancel(true);
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -1387,6 +1390,7 @@ public <T> Map<String, T> getBulk(Collection<String> keys,
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.cancel(true);
throw new RuntimeException("Interrupted getting bulk values", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -1460,6 +1464,7 @@ public <T> Map<String, CASValue<T>> getsBulk(Collection<String> keys,
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.cancel(true);
throw new RuntimeException("Interrupted getting bulk values", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -1555,6 +1560,7 @@ public void complete() {
try {
rv = future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted waiting for versions", e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -1628,6 +1634,7 @@ public void complete() {
try {
rv = future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted waiting for stats", e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -1658,6 +1665,7 @@ public void complete() {
throw new OperationTimeoutException(operationTimeout, TimeUnit.MILLISECONDS, op);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
op.cancel("by applcation.");
throw new RuntimeException("Interrupted", e);
}
Expand Down Expand Up @@ -1762,6 +1770,7 @@ private long mutateWithDefault(Mutator t, String key,
assert rv != -1 : "Failed to mutate or init value";
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
f.cancel(true);
throw new RuntimeException("Interrupted waiting for store", e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -2132,6 +2141,7 @@ public void complete() {
// and the check retried.
return latch.await(timeout, unit);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted waiting for queues", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public Element<E> getElement() {
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new OperationTimeoutException(e);
Expand Down
Loading