Consistent HttpMethod identity comparisons
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,6 @@ import org.springframework.web.server.ServerWebInputException;
|
||||
import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for classes for which {@link RequestMappingInfo} defines
|
||||
* the mapping between a request and a handler method.
|
||||
@@ -358,7 +357,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
private static Set<HttpMethod> initAllowedHttpMethods(Set<HttpMethod> declaredMethods) {
|
||||
if (declaredMethods.isEmpty()) {
|
||||
return EnumSet.allOf(HttpMethod.class).stream()
|
||||
.filter(method -> !method.equals(HttpMethod.TRACE))
|
||||
.filter(method -> method != HttpMethod.TRACE)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,16 +29,8 @@ import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.DELETE;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.HEAD;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.OPTIONS;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.PUT;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RequestMethodsRequestCondition}.
|
||||
@@ -67,7 +59,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
public void getMatchingConditionWithEmptyConditions() throws Exception {
|
||||
RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition();
|
||||
for (RequestMethod method : RequestMethod.values()) {
|
||||
if (!OPTIONS.equals(method)) {
|
||||
if (method != OPTIONS) {
|
||||
ServerWebExchange exchange = getExchange(method.name());
|
||||
assertNotNull(condition.getMatchingCondition(exchange));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user