Navigation Menu

Skip to content

Commit

Permalink
[#277] @catch annotated method received null pointer arg
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebort committed Oct 12, 2010
1 parent a163e49 commit 707793b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion framework/src/play/mvc/ActionInvoker.java
Expand Up @@ -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);
Expand Down
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 707793b

Please sign in to comment.