Skip to content

Commit

Permalink
FIX: Handling interrupt exception when blocking by future get.
Browse files Browse the repository at this point in the history
  • Loading branch information
brido4125 committed Oct 6, 2023
1 parent 7874b97 commit c378476
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 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
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

0 comments on commit c378476

Please sign in to comment.