Fix regression introduced in 4.3 snapshot

Commit ccd17d introduced a regression where a custom HTTP method
would no longer match for an empty @RequestMapping condition.

The previous behavior should now be restored. Effectively
RequestMethodRequestCondition as before will now match to any HTTP
method (even unknown/custom ones) if the methods condition is empty.
The only exception is HTTP OPTIONS for which we provide default
handling as a fallback (i.e. when not mapped explicitly).

Issue: SPR-13130
This commit is contained in:
Rossen Stoyanchev
2016-02-18 14:37:36 -05:00
parent 1c2ac49f2a
commit 08eb623c41
2 changed files with 14 additions and 12 deletions

View File

@@ -82,12 +82,13 @@ public class RequestMethodsRequestConditionTests {
}
@Test
public void noDeclaredMethodsMatchesAllMethodsExceptOptions() {
public void emptyMatchesAnythingExceptHttpOptions() {
RequestCondition condition = new RequestMethodsRequestCondition();
assertNotNull(condition.getMatchingCondition(new MockHttpServletRequest("GET", "")));
assertNotNull(condition.getMatchingCondition(new MockHttpServletRequest("POST", "")));
assertNotNull(condition.getMatchingCondition(new MockHttpServletRequest("HEAD", "")));
assertNotNull(condition.getMatchingCondition(new MockHttpServletRequest("CUSTOM", "")));
assertNull(condition.getMatchingCondition(new MockHttpServletRequest("OPTIONS", "")));
}