spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.55k stars 40.54k forks source link

Matrix parameters early in URL lead to 404 with spring-data-rest with 1.3.0.M* #3934

Closed timtebeek closed 9 years ago

timtebeek commented 9 years ago

Hi all,

Not sure if this is a Boot 1.3.0.M5 issue or a Spring-Data Gosling issue, but it's hard to test Spring-Data Gosling with Spring boot 1.2.5, so here goes:

I'm using a javax.servlet.Filter to parse a passed matrix parameter like this: https://github.com/timtebeek/routing-filter/blob/master/src/main/java/com/github/timtebeek/routing/filter/RoutingFilter.java This filter is used to set a ThreadLocal value for a routing datasource as suggested here: http://stackoverflow.com/questions/25083710/combine-dynamic-datasource-routing-with-spring-data-rest

When using spring-boot 1.2.5.RELASE as parent I can pass the matrix variable anywhere in the url, as per the tests here: https://github.com/timtebeek/routing-filter/blob/master/src/test/java/com/github/timtebeek/routing/filter/RoutingFilterTest.java

After switching to 1.3.0.M5 only the calls with the projection passed last keep working, while the other URLs lead to either 404 of 500 status codes, breaking backwards compatibility with my present URL structure.

Example project here: https://github.com/timtebeek/routing-filter Test results available here: https://travis-ci.org/timtebeek/routing-filter

What can be done to ensure the old URLs with the matrix variable values passed in early keep working after switching to spring-boot 1.3.0.M5?

snicoll commented 9 years ago

cc @olivergierke

odrotbohm commented 9 years ago

Looking into it.

odrotbohm commented 9 years ago

Although my initial reaction is: Spring Data REST is hypermedia based, so all you basically need to do is follow the links it provides. If you let clients mess with the URI structures, you shouldn't be expect it to work in the first place. The service returns URIs it can handle. :)

That said, what's the reason for this rather extraordinary URI setup?

timtebeek commented 9 years ago

That's to get it to work with dynamic database routing for multiple tenants each using their own database, without a fallback value. Or is there another suggested way to get that to work? On 9 Sep 2015 19:00, "Oliver Gierke" notifications@github.com wrote:

Although my initial reaction is: Spring Data REST is hypermedia based, so all you basically need to do is follow the links it provides. If you let clients mess with the URI structures, you shouldn't be expect it to work in the first place. The service returns URIs it can handle. :)

That said, what's the reason for this rather extraordinary URI setup?

— Reply to this email directly or view it on GitHub https://github.com/spring-projects/spring-boot/issues/3934#issuecomment-138975657 .

odrotbohm commented 9 years ago

I've identified an issue in Spring Framework 4.2 which unfortunately now returns /books//1 where it previously returned /books/1.

Spring Data REST currently isn't prepared to deal with the double slashes. I've created DATAREST-674 to track and guard Spring Data REST against that. With that in place we should be able to get your sample work.

Summarizing: not an issue with Boot itself, I think this one can be closed.

timtebeek commented 9 years ago

Thanks for looking into this! I'll start tracking the other issues hoping for a fix.. On 9 Sep 2015 20:10, "Oliver Gierke" notifications@github.com wrote:

I've identified an issue in Spring Framework 4.2 https://jira.spring.io/browse/SPR-13455 which unfortunately now returns /books//1 where it previously returned /books/1.

Spring Data REST currently isn't prepared to deal with the double slashes. I've created DATAREST-674 https://jira.spring.io/browse/DATAREST-674 to track and guard Spring Data REST against that. With that in place we should be able to get your sample work.

Summarizing: not an issue with Boot itself, I think this one can be closed.

— Reply to this email directly or view it on GitHub https://github.com/spring-projects/spring-boot/issues/3934#issuecomment-138994778 .

philwebb commented 9 years ago

Thanks @olivergierke !