(
final T target,
Class<T> interfaceType,
final long timeoutDuration,
final TimeUnit timeoutUnit)
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public <T> T newProxy( |
| 83 | final T target, |
| 84 | Class<T> interfaceType, |
| 85 | final long timeoutDuration, |
| 86 | final TimeUnit timeoutUnit) { |
| 87 | checkNotNull(target); |
| 88 | checkNotNull(interfaceType); |
| 89 | checkNotNull(timeoutUnit); |
| 90 | checkArgument(timeoutDuration > 0, "bad timeout: %s", timeoutDuration); |
| 91 | checkArgument(interfaceType.isInterface(), "interfaceType must be an interface type"); |
| 92 | final Set<Method> interruptibleMethods = findInterruptibleMethods(interfaceType); |
| 93 | InvocationHandler handler = new InvocationHandler() { |
| 94 | @Override |
| 95 | public Object invoke(Object obj, final Method method, final Object[] args) throws Throwable { |
| 96 | Callable<Object> callable = new Callable<Object>() { |
| 97 | @Override |
| 98 | public Object call() throws Exception { |
| 99 | try { |
| 100 | return method.invoke(target, args); |
| 101 | } catch (InvocationTargetException e) { |
| 102 | throw throwCause(e, false); |
| 103 | } |
| 104 | } |
| 105 | }; |
| 106 | return callWithTimeout(callable, timeoutDuration, timeoutUnit, interruptibleMethods.contains(method)); |
| 107 | } |
| 108 | }; |
| 109 | return newProxy(interfaceType, handler); |
| 110 | } |
| 111 | |
| 112 | // TODO: should this actually throw only ExecutionException? |
| 113 |
nothing calls this directly
no test coverage detected