diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java index 2aaaedf5e..58cfd4e05 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java @@ -103,6 +103,8 @@ public class BaseUri { Assert.notNull(lookupPath, "Lookup path must not be null!"); + lookupPath = trimTrailingCharacter(lookupPath, '/'); + if (!baseUri.isAbsolute()) { String uri = baseUri.toString(); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ResourceMetadataHandlerMethodArgumentResolver.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ResourceMetadataHandlerMethodArgumentResolver.java index 3ad208be6..bd0b91847 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ResourceMetadataHandlerMethodArgumentResolver.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ResourceMetadataHandlerMethodArgumentResolver.java @@ -94,6 +94,6 @@ public class ResourceMetadataHandlerMethodArgumentResolver implements HandlerMet } } - return null; + throw new IllegalArgumentException(String.format("Could not resolve repository metadata for %s.", repositoryKey)); } } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java index d36c6953d..5ec028625 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java @@ -59,7 +59,7 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("foo/")); assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), is("/")); + assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); } /** @@ -71,7 +71,7 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("/foo")); assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), is("/")); + assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); } /** @@ -83,8 +83,8 @@ public class BaseUriUnitTests { BaseUri uri = new BaseUri(URI.create("http://localhost:8080/foo/")); assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString()); - assertThat(uri.getRepositoryLookupPath("/foo/"), is("/")); + assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString()); assertThat(uri.getRepositoryLookupPath("/foo/people"), is("/people")); - assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people/")); + assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people")); } }