--- miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/invocations/AnnotatedInvocation.java 2017/09/18 18:06:48 3211 +++ miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/invocations/AnnotatedInvocation.java 2017/12/28 09:34:47 3212 @@ -22,7 +22,7 @@ import dk.thoerup.circuitbreaker.CircuitInvocation; -public class AnnotatedInvocation implements CircuitInvocation { +public class AnnotatedInvocation implements CircuitInvocation { public static class CBAnnotationException extends Exception { public CBAnnotationException() { @@ -38,7 +38,8 @@ this.obj = obj; } - public Object proceed() throws Exception { + @SuppressWarnings("unchecked") + public T proceed() throws Exception { Method methods[] = obj.getClass().getMethods(); for(Method current : methods) { @@ -47,7 +48,7 @@ if (anno != null ) { try { - return current.invoke(obj, (Object[])null); //invoke the first method annotated + return (T) current.invoke(obj, (Object[])null); //invoke the first method annotated } catch (InvocationTargetException e) { throw (Exception) e.getCause(); //unwrap any exception from InvocationTargetException }