34
34
import java .util .List ;
35
35
import java .util .Map ;
36
36
import java .util .Set ;
37
+ import java .util .concurrent .CancellationException ;
37
38
import java .util .concurrent .ConcurrentHashMap ;
38
39
import java .util .concurrent .ConcurrentLinkedQueue ;
39
40
import java .util .concurrent .ConcurrentMap ;
@@ -558,6 +559,7 @@ public <T> CASResponse cas(String key, long casId, T value,
558
559
* @param tc the transcoder to serialize and unserialize the value
559
560
* @return a CASResponse
560
561
* @throws OperationTimeoutException if global operation timeout is exceeded
562
+ * @throws CancellationException if operation was canceled
561
563
* @throws IllegalStateException in the rare circumstance where queue is too
562
564
* full to accept any more requests
563
565
*/
@@ -573,7 +575,11 @@ public <T> CASResponse cas(String key, long casId, int exp, T value,
573
575
} catch (InterruptedException e ) {
574
576
throw new RuntimeException ("Interrupted waiting for value" , e );
575
577
} catch (ExecutionException e ) {
576
- throw new RuntimeException ("Exception waiting for value" , e );
578
+ if (e .getCause () instanceof CancellationException ) {
579
+ throw (CancellationException ) e .getCause ();
580
+ } else {
581
+ throw new RuntimeException ("Exception waiting for value" , e );
582
+ }
577
583
} catch (TimeoutException e ) {
578
584
throw new OperationTimeoutException ("Timeout waiting for value" , e );
579
585
}
@@ -922,6 +928,7 @@ public OperationFuture<CASValue<Object>> asyncGets(final String key) {
922
928
* @param tc the transcoder to serialize and unserialize value
923
929
* @return the result from the cache and CAS id (null if there is none)
924
930
* @throws OperationTimeoutException if global operation timeout is exceeded
931
+ * @throws CancellationException if operation was canceled
925
932
* @throws IllegalStateException in the rare circumstance where queue is too
926
933
* full to accept any more requests
927
934
*/
@@ -931,7 +938,11 @@ public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
931
938
} catch (InterruptedException e ) {
932
939
throw new RuntimeException ("Interrupted waiting for value" , e );
933
940
} catch (ExecutionException e ) {
934
- throw new RuntimeException ("Exception waiting for value" , e );
941
+ if (e .getCause () instanceof CancellationException ) {
942
+ throw (CancellationException ) e .getCause ();
943
+ } else {
944
+ throw new RuntimeException ("Exception waiting for value" , e );
945
+ }
935
946
} catch (TimeoutException e ) {
936
947
throw new OperationTimeoutException ("Timeout waiting for value" , e );
937
948
}
@@ -947,6 +958,7 @@ public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
947
958
* @return the result from the cache (null if there is none)
948
959
* @throws OperationTimeoutException if the global operation timeout is
949
960
* exceeded
961
+ * @throws CancellationException if operation was canceled
950
962
* @throws IllegalStateException in the rare circumstance where queue is too
951
963
* full to accept any more requests
952
964
*/
@@ -957,7 +969,11 @@ public <T> CASValue<T> getAndTouch(String key, int exp, Transcoder<T> tc) {
957
969
} catch (InterruptedException e ) {
958
970
throw new RuntimeException ("Interrupted waiting for value" , e );
959
971
} catch (ExecutionException e ) {
960
- throw new RuntimeException ("Exception waiting for value" , e );
972
+ if (e .getCause () instanceof CancellationException ) {
973
+ throw (CancellationException ) e .getCause ();
974
+ } else {
975
+ throw new RuntimeException ("Exception waiting for value" , e );
976
+ }
961
977
} catch (TimeoutException e ) {
962
978
throw new OperationTimeoutException ("Timeout waiting for value" , e );
963
979
}
@@ -1001,6 +1017,7 @@ public CASValue<Object> gets(String key) {
1001
1017
* @return the result from the cache (null if there is none)
1002
1018
* @throws OperationTimeoutException if the global operation timeout is
1003
1019
* exceeded
1020
+ * @throws CancellationException if operation was canceled
1004
1021
* @throws IllegalStateException in the rare circumstance where queue is too
1005
1022
* full to accept any more requests
1006
1023
*/
@@ -1010,7 +1027,11 @@ public <T> T get(String key, Transcoder<T> tc) {
1010
1027
} catch (InterruptedException e ) {
1011
1028
throw new RuntimeException ("Interrupted waiting for value" , e );
1012
1029
} catch (ExecutionException e ) {
1013
- throw new RuntimeException ("Exception waiting for value" , e );
1030
+ if (e .getCause () instanceof CancellationException ) {
1031
+ throw (CancellationException ) e .getCause ();
1032
+ } else {
1033
+ throw new RuntimeException ("Exception waiting for value" , e );
1034
+ }
1014
1035
} catch (TimeoutException e ) {
1015
1036
throw new OperationTimeoutException ("Timeout waiting for value" , e );
1016
1037
}
@@ -1294,6 +1315,7 @@ public void gotData(String k, int flags, long cas, byte[] data) {
1294
1315
* @return a map of the values (for each value that exists)
1295
1316
* @throws OperationTimeoutException if the global operation timeout is
1296
1317
* exceeded
1318
+ * @throws CancellationException if operation was canceled
1297
1319
* @throws IllegalStateException in the rare circumstance where queue is too
1298
1320
* full to accept any more requests
1299
1321
*/
@@ -1305,9 +1327,13 @@ public <T> Map<String, T> getBulk(Iterator<String> keyIter,
1305
1327
} catch (InterruptedException e ) {
1306
1328
throw new RuntimeException ("Interrupted getting bulk values" , e );
1307
1329
} catch (ExecutionException e ) {
1308
- throw new RuntimeException ("Failed getting bulk values" , e );
1330
+ if (e .getCause () instanceof CancellationException ) {
1331
+ throw (CancellationException ) e .getCause ();
1332
+ } else {
1333
+ throw new RuntimeException ("Exception waiting for bulk values" , e );
1334
+ }
1309
1335
} catch (TimeoutException e ) {
1310
- throw new OperationTimeoutException ("Timeout waiting for bulkvalues " , e );
1336
+ throw new OperationTimeoutException ("Timeout waiting for bulk values " , e );
1311
1337
}
1312
1338
}
1313
1339
@@ -1681,7 +1707,11 @@ private long mutateWithDefault(Mutator t, String key, long by, long def,
1681
1707
} catch (InterruptedException e ) {
1682
1708
throw new RuntimeException ("Interrupted waiting for store" , e );
1683
1709
} catch (ExecutionException e ) {
1684
- throw new RuntimeException ("Failed waiting for store" , e );
1710
+ if (e .getCause () instanceof CancellationException ) {
1711
+ throw (CancellationException ) e .getCause ();
1712
+ } else {
1713
+ throw new RuntimeException ("Failed waiting for store" , e );
1714
+ }
1685
1715
} catch (TimeoutException e ) {
1686
1716
throw new OperationTimeoutException ("Timeout waiting to mutate or init"
1687
1717
+ " value" , e );
0 commit comments