Skip to content

webflux handler fails in case invalid method was requested [SPR-15545] #20104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue May 14, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 14, 2017

Maksim Kostromin opened SPR-15545 and commented

this:

@Bean
public RouterFunction<ServerResponse> routes(final TaskRepository taskRepository,
                                             final ActivityRepository activityRepository) {
  return
      route(
          DELETE("/tasks"),
          request -> ok().body(
              Mono.fromCallable(() -> {
                activityRepository.deleteAll();
                taskRepository.deleteAll();
                return "done.";
              }).subscribe(), String.class));
}

on invalid http method call (correct one is: delete)

$ http del :8080/tasks
HTTP/1.1 500 Internal Server Error

will fails with logs No enum constant HttpMethod.xxx:

2017-05-14 22:03:14.985 ERROR 25071 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter : Failed to handle request

java.lang.IllegalArgumentException: No enum constant org.springframework.http.HttpMethod.DEL
at java.lang.Enum.valueOf(Enum.java:238) ~[na:1.8.0_102]
at org.springframework.http.HttpMethod.valueOf(HttpMethod.java:31) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.http.server.reactive.ReactorServerHttpRequest.getMethod(ReactorServerHttpRequest.java:90) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.DefaultServerRequest.method(DefaultServerRequest.java:80) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RequestPredicates$HttpMethodPredicate.test(RequestPredicates.java:319) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RequestPredicates$AndRequestPredicate.test(RequestPredicates.java:417) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RouterFunctions.lambda$route$1(RouterFunctions.java:98) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RouterFunction.lambda$and$1(RouterFunction.java:50) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RouterFunction.lambda$and$1(RouterFunction.java:50) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RouterFunction.lambda$and$1(RouterFunction.java:50) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.reactive.function.server.RouterFunctions.lambda$toHttpHandler$10(RouterFunctions.java:229) ~[spring-webflux-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.handler.WebHandlerDecorator.handle(WebHandlerDecorator.java:49) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.handler.WebHandlerDecorator.handle(WebHandlerDecorator.java:49) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.handler.FilteringWebHandler.handle(FilteringWebHandler.java:65) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.handler.WebHandlerDecorator.handle(WebHandlerDecorator.java:49) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.handler.ExceptionHandlingWebHandler.handle(ExceptionHandlingWebHandler.java:60) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.web.server.adapter.HttpWebHandlerAdapter.handle(HttpWebHandlerAdapter.java:133) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:59) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:37) ~[spring-web-5.0.0.RC1.jar:5.0.0.RC1]
at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:381) ~[reactor-netty-0.6.3.RELEASE.jar:0.6.3.RELEASE]
at reactor.ipc.netty.http.server.HttpServerOperations.onHandlerStart(HttpServerOperations.java:354) ~[reactor-netty-0.6.3.RELEASE.jar:0.6.3.RELEASE]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[netty-common-4.1.11.Final.jar:4.1.11.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) ~[netty-common-4.1.11.Final.jar:4.1.11.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) ~[netty-transport-4.1.11.Final.jar:4.1.11.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) ~[netty-common-4.1.11.Final.jar:4.1.11.Final]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_102]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoError] :
reactor.core.publisher.Mono.error(Mono.java:263)
org.springframework.web.server.handler.ExceptionHandlingWebHandler.handle(ExceptionHandlingWebHandler.java:63)
org.springframework.web.server.adapter.HttpWebHandlerAdapter.handle(HttpWebHandlerAdapter.java:133)
org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:59)
org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:37)
reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:381)
reactor.ipc.netty.http.server.HttpServerOperations.onHandlerStart(HttpServerOperations.java:354)
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
Error has been observed by the following operator(s):
|_ Mono.error(ExceptionHandlingWebHandler.java:63)


Affects: 5.0 RC1

Issue Links:

Referenced from: commits a5b94f3, 630fc19

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Arjen Poutsma, I think routes should decide how to deal with an invalid (or possibly unknown/custom) HTTP method. I don't think there is much we can do in the ServerHttpRequest parsing code. so I'm assigning to you.

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Fixed in 630fc19 and a5b94f3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants