Since 0.22.0.RELEASE, links are built relative to the request context. The following test case in ControllerLinkBuildUnitTest runs with success against the previous release, but fails with the current.
@Test
public void createsLinkRelativeToContextRoot() {
request.setContextPath("/ctx");
request.setServletPath("/foo");
request.setRequestURI("/ctx/foo");
assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), endsWith("/ctx/people"));
}
java.lang.AssertionError:
Expected: a string ending with "/ctx/people"
but: was "http://localhost/ctx/foo/people"
Expected :a string ending with "/ctx/people"
This would be a regression to our application due to the invalid links.
I suspect that this behavior was introduced with #519.
Thanks for giving this a spin so quickly. Indeed our migration to the Spring APIs introduced that glitch. I have a fix ready to be polished here. We should be able to craft a release quickly.
0.23.0.BUILD-SNAPSHOT binaries available. Care to give them a spin before I start the machinery?
I am happy to try that out, we also just noticed a similar regression after upgrading to 0.22.0 (as we've been eagerly awaiting the fix for #525 / #511)
Yeah, please go ahead. Sorry for the trouble. I'm pretty puzzled to see that going out unnoticed :(.
The more important parts of #525 / #511 were fixed in Spring Framework 4.3.5. So you should see very decent improvements by just moving to the latter. 4.3.5 has not really been a required release API wise, I just wanted to wait for it so that we can ship a dependency to it to make sure people get the changes that actually fix the reported issues against Spring HATEOAS.
I can confirm that all links in our project that are generated with ControllerLinkBuilder are construced correctly again (i.e. not relative to the path of the incoming request) when using 0.23.0.BUILD-SNAPSHOT.
fb0ba25 LGTM
grml - mea culpa (47cefe6869c9f41fef17d0187377a7cd379a488e)..
Alright. Looks like the issue hasn't appeared downstream as none of the projects (Spring Data) actually use the ControllerLinkBuilder.
@otrosien — Nevermind. We should've had tests for that in the first place.
About to push the buttons…
0.23 is live at the Spring repositories. Maven Central sync seems to have general hickups currently.
Thanks a lot for fixing this so quickly! Everything is working fine with 0.23 - I only had to add the https://repo.spring.io/libs-release repository, as the release indeed doesn't yet seem to be available on maven central.
@olivergierke - also the git tag has not been pushed back to github yet.
The artifacts are now available via Maven Central. However, the search index doesn't seem to list them yet.
Should be up now.
Most helpful comment
Yeah, please go ahead. Sorry for the trouble. I'm pretty puzzled to see that going out unnoticed :(.
The more important parts of #525 / #511 were fixed in Spring Framework 4.3.5. So you should see very decent improvements by just moving to the latter. 4.3.5 has not really been a required release API wise, I just wanted to wait for it so that we can ship a dependency to it to make sure people get the changes that actually fix the reported issues against Spring HATEOAS.