perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.64k stars 1.56k forks source link

404 not found event if the routes are declared and executed correctly. #977

Open comepasto opened 6 years ago

comepasto commented 6 years ago

Issue #909 introduced a side effect. In my case, some APIs do not need to return a body. An http status 200 is enough. To cope with that, I set the flag externalContainer to true. My routes just return null in that case. Then I just decided to upgrade to 2.7.0. Bad idea! All those APIs return a 404 even if they have executed correctly. Logs say : The requested route [{}] has not been mapped in Spark for {}.

Is there a different way to ignore a null body other than returning an empty string?

Thank you.

abhinavsayan commented 6 years ago

You could modify the response in the after filter ?

comepasto commented 6 years ago

Yes, sure. At the end it is the same, I have to return an empty string. And it seems the only issue.

The thing is, the behavior has changed completely. The error message says 404, the route has not been mapped in Spark. However, the route is correctly mapped and executed correctly. Some applications are full rest applications. They do not serve any page. And they do not need to return a body.

I would like to propose a fix, but as I read on the Sparkjava page, 2.7.x is probably the last release before the 3.0.0. And I do not see any branch for that. (I hope it is not the end, sniff)

Horkyze commented 6 years ago

I experience similar issue. I mapped:

post("/abc", ...);
put("/abc", ...);
get("/abc", ...);

POST and GET works fine, but PUT returns 404. However the execution is done correctly, I can see the modified data again via GET.

In logs:

... The requested route [/abc] has not been mapped in Spark for Accept: [*/*]
Bugjudger commented 3 years ago

Hello, I want to try to solve this problem