mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Allow resolution of optional HandlerMethod
Closes gh-35067
This commit is contained in:
+14
@@ -18,6 +18,7 @@ package org.springframework.web.method.support;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -25,6 +26,7 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.testfixture.method.ResolvableMethod;
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
|
||||
@@ -105,6 +107,14 @@ class InvocableHandlerMethodTests {
|
||||
assertThat(value).isEqualTo("2-value2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveHandlerMethodArgToNull() throws Exception {
|
||||
Object value = getInvocable(HandlerMethod.class).invokeForRequest(request, null);
|
||||
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).isEqualTo("success");
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionInResolvingArg() {
|
||||
this.composite.addResolver(new ExceptionRaisingArgumentResolver());
|
||||
@@ -184,6 +194,10 @@ class InvocableHandlerMethodTests {
|
||||
public void handleWithException(Throwable ex) throws Throwable {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
public String handleHandlerMethod(@Nullable HandlerMethod handlerMethod) {
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user