mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Merge branch '6.2.x'
This commit is contained in:
+1
-1
@@ -188,7 +188,7 @@ public abstract class JdbcTransactionObjectSupport implements SavepointManager,
|
||||
}
|
||||
// ignore Microsoft SQLServerException: This operation is not supported.
|
||||
String msg = ex.getMessage();
|
||||
if (msg == null || !msg.contains("not supported")) {
|
||||
if (msg == null || (!msg.contains("not supported") && !msg.contains("3B001"))) {
|
||||
throw new TransactionSystemException("Could not explicitly release JDBC savepoint", ex);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -123,7 +123,7 @@ public class ExceptionHandlerMethodResolver {
|
||||
if (exceptions.isEmpty()) {
|
||||
throw new IllegalStateException("No exception types mapped to " + method);
|
||||
}
|
||||
Set<MediaType> mediaTypes = new HashSet<>();
|
||||
Set<MediaType> mediaTypes = new LinkedHashSet<>();
|
||||
for (String mediaType : exceptionHandler.produces()) {
|
||||
try {
|
||||
mediaTypes.add(MediaType.parseMediaType(mediaType));
|
||||
|
||||
+16
-8
@@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.BindException;
|
||||
import java.net.SocketException;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -100,14 +101,21 @@ class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenAmbiguousExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(AmbiguousController.class));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(AmbiguousController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenNoExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(NoExceptionController.class));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(NoExceptionController.class));
|
||||
}
|
||||
|
||||
@Test // gh-35587
|
||||
void shouldRetainOriginalOrderOfProducibleMediaTypes() {
|
||||
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class);
|
||||
Set<MediaType> producibleTypes = resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getProducibleTypes();
|
||||
assertThat(MediaType.toString(producibleTypes)).isEqualTo("text/html, */*");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,15 +139,15 @@ class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenInvalidMediaTypeMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(InvalidMediaTypeController.class))
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(InvalidMediaTypeController.class))
|
||||
.withMessageContaining("Invalid media type [invalid-mediatype] declared on @ExceptionHandler");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenAmbiguousMediaTypeMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(AmbiguousMediaTypeController.class))
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(AmbiguousMediaTypeController.class))
|
||||
.withMessageContaining("Ambiguous @ExceptionHandler method mapped for [ExceptionHandler{exceptionType=java.lang.IllegalArgumentException, mediaType=application/json}]")
|
||||
.withMessageContaining("AmbiguousMediaTypeController.handleJson()")
|
||||
.withMessageContaining("AmbiguousMediaTypeController.handleJsonToo()");
|
||||
|
||||
Reference in New Issue
Block a user