Compare commits

..

2 Commits

Author SHA1 Message Date
Gustavo Henrique Miranda d6caa1b1d7
Merge 5ce8f4ca2a into 9c3a1126a7 2025-11-29 15:33:16 -03:00
Gustavo Henrique Santos Souza de Miranda 5ce8f4ca2a Improve `DelegateActionManager` error handling for invalid handlers
- Add validation to ensure classes annotated with `@Action` implement `ActionHandler`, throwing `IllegalArgumentException` for mismatches.
- Fix minor formatting issue in `@Action` annotation for `GetGenreByIdHandler`.
2025-11-29 15:33:08 -03:00
2 changed files with 6 additions and 3 deletions

View File

@ -66,14 +66,17 @@ public class DelegateActionManager {
@SuppressWarnings("unchecked")
private ActionHandler instantiateHandler(Class<?> clazz) throws Exception {
if(!ActionHandler.class.isAssignableFrom(clazz)){
throw new IllegalArgumentException(
clazz.getName() + " is annotated with @Action but does not implement ActionHandler");
}
logger.debug("Attempting to instantiate handler: {}", clazz.getSimpleName());
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
// Sort constructors by parameter count (descending) to prefer DI constructors
java.util.Arrays.sort(constructors, (c1, c2) ->
Integer.compare(c2.getParameterCount(), c1.getParameterCount()));