Skip to content

Commit eeac636

Browse files
committed
fix issue: it respond back 404 when before handler return null with Result as return type
1 parent 371e134 commit eeac636

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/main/java/act/controller/meta/HandlerMethodMetaInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ public Type returnType() {
158158
return returnType.type();
159159
}
160160

161+
public ReturnTypeInfo returnTypeInfo() {
162+
return returnType;
163+
}
164+
161165
public Type returnComponentType() {
162166
return returnType.componentType();
163167
}

src/main/java/act/handler/builtin/controller/impl/ReflectedHandlerInvoker.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ private Result invoke(M handlerMetaInfo, ActionContext context, Object controlle
295295
throw (Exception) cause;
296296
}
297297
}
298-
if (null == result && handler.hasReturn()) {
298+
if (null == result && handler.hasReturn() && !handler.returnTypeInfo().isResult()) {
299+
// ActFramework respond 404 Not Found when
300+
// handler invoker return `null`
301+
// and there are return type of the action method signature
302+
// and the return type is **NOT** Result
299303
return NotFound.INSTANCE;
300304
}
301305
boolean hasTemplate = checkTemplate(context);

src/main/java/act/sys/meta/ReturnTypeInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package act.sys.meta;
22

33
import act.asm.Type;
4+
import act.util.AsmTypes;
45

56
public class ReturnTypeInfo {
67
private Type type;
@@ -31,6 +32,10 @@ public boolean hasReturn() {
3132
return type != Type.VOID_TYPE;
3233
}
3334

35+
public boolean isResult() {
36+
return AsmTypes.RESULT_TYPE.equals(type);
37+
}
38+
3439
public static ReturnTypeInfo of(Type type) {
3540
return new ReturnTypeInfo(type);
3641
}

0 commit comments

Comments
 (0)