Consistent ordering in MethodNotAllowedException
This caused random failures in a newly added test. Also remove defensive check in ResponseStatusExceptionResolver. See gh-24944
This commit is contained in:
@@ -18,7 +18,7 @@ package org.springframework.web.server;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class MethodNotAllowedException extends ResponseStatusException {
|
||||
supportedMethods = Collections.emptySet();
|
||||
}
|
||||
this.method = method;
|
||||
this.httpMethods = Collections.unmodifiableSet(new HashSet<>(supportedMethods));
|
||||
this.httpMethods = Collections.unmodifiableSet(new LinkedHashSet<>(supportedMethods));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -130,11 +130,8 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
|
||||
protected ModelAndView resolveResponseStatusException(ResponseStatusException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws Exception {
|
||||
|
||||
ex.getResponseHeaders().forEach((name, values) -> {
|
||||
if (response.getHeader(name) == null) {
|
||||
values.forEach(value -> response.addHeader(name, value));
|
||||
}
|
||||
});
|
||||
ex.getResponseHeaders().forEach((name, values) ->
|
||||
values.forEach(value -> response.addHeader(name, value)));
|
||||
|
||||
int statusCode = ex.getStatus().value();
|
||||
String reason = ex.getReason();
|
||||
|
||||
Reference in New Issue
Block a user