Suppress OPTIONS handling for an ERROR dispatch

Issue: SPR-14410
This commit is contained in:
Rossen Stoyanchev
2016-06-30 12:34:54 -04:00
parent 16949941f8
commit 9c29ed75f8
2 changed files with 18 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.mvc.condition;
import java.util.Collections;
import javax.servlet.DispatcherType;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.springframework.web.bind.annotation.RequestMethod.DELETE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@@ -87,6 +89,18 @@ public class RequestMethodsRequestConditionTests {
assertNull(new RequestMethodsRequestCondition(DELETE).getMatchingCondition(request));
}
@Test // SPR-14410
public void getMatchingConditionWithHttpOptionsInErrorDispatch() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/path");
request.setDispatcherType(DispatcherType.ERROR);
RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition();
RequestMethodsRequestCondition result = condition.getMatchingCondition(request);
assertNotNull(result);
assertSame(condition, result);
}
@Test
public void compareTo() {
RequestMethodsRequestCondition c1 = new RequestMethodsRequestCondition(GET, HEAD);