Skip to content
Permalink
Browse files

[#277] @catch annotated method received null pointer arg

  • Loading branch information...
guillaumebort committed Oct 12, 2010
1 parent 36008c7 commit 78213ceeec7698d7e457c8ff99a80e1768a97f23
@@ -405,7 +405,7 @@ public static Object invokeControllerMethod(Method method) throws Exception {

public static Object invokeControllerMethod(Method method, Object[] forceArgs) throws Exception {
if (Modifier.isStatic(method.getModifiers()) && !method.getDeclaringClass().getName().matches("^controllers\\..*\\$class$")) {
return method.invoke(null, getActionMethodArgs(method, null));
return method.invoke(null, forceArgs == null ? getActionMethodArgs(method, null) : forceArgs);
} else if (Modifier.isStatic(method.getModifiers())) {
Object[] args = getActionMethodArgs(method, null);
args[0] = Http.Request.current().controllerClass.getDeclaredField("MODULE$").get(null);
@@ -7,7 +7,7 @@

public class UsingBefore extends Controller {

@Before(unless = {"a", "onlytest"})
@Before(unless = {"a", "onlytest", "fight"})
static void yop(String name) {
renderText("Yop " + name);
}
@@ -37,4 +37,19 @@ static void beforeonlytest(String name) {
public static void onlytest(String name) {
renderText("onlynotwork : " + name);
}

public static void fight(String name) {
name.toString();
renderText(9/0);
}

@Catch(ArithmeticException.class)
static void catchDivByZero(Exception e) {
renderText("Oops, got " + e);
}

@Catch(NullPointerException.class)
static void catchNull(Exception e) {
renderText("Hey!, got " + e);
}
}

0 comments on commit 78213ce

Please sign in to comment.
You can’t perform that action at this time.