private <T> T callWithTimeLimit(Callable<T> callable, LockRequestSpecification specification) throws InterruptedException { try { return timeLimiter.callWithTimeout(callable, blockingTimeLimitMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { // In this case, the thread was interrupted for some other reason, perhaps because we lost leadership. log.info("Lock service was interrupted when servicing {} for client \"{}\"; request was {}", SafeArg.of("method", specification.method()), SafeArg.of("client", specification.client()), UnsafeArg.of("lockRequest", specification.lockRequest()), e); throw e; } catch (TimeoutException e) { // This is the legitimate timeout case we're trying to catch. throw logAndHandleTimeout(specification); } catch (Exception e) { // We don't know, and would prefer not to throw checked exceptions apart from InterruptedException. throw Throwables.propagate(e); } }
private <T> T callWithTimeLimit(Callable<T> callable, LockRequestSpecification specification) throws InterruptedException { try { return timeLimiter.callWithTimeout(callable, blockingTimeLimitMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { // In this case, the thread was interrupted for some other reason, perhaps because we lost leadership. log.info("Lock service was interrupted when servicing {} for client \"{}\"; request was {}", SafeArg.of("method", specification.method()), SafeArg.of("client", specification.client()), UnsafeArg.of("lockRequest", specification.lockRequest()), e); throw e; } catch (TimeoutException e) { // This is the legitimate timeout case we're trying to catch. throw logAndHandleTimeout(specification); } catch (Exception e) { // We don't know, and would prefer not to throw checked exceptions apart from InterruptedException. throw Throwables.propagate(e); } }