From 87d3d1bbd1e5620fb8c2583c487507bab9614fb2 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 6 Sep 2021 16:52:23 +0200 Subject: [PATCH] Throw UnsupportedOperationException in defaultResponseCharacterEncoding() This commit updates the defaultResponseCharacterEncoding() `default` method in ConfigurableMockMvcBuilder so that it throws an UnsupportedOperationException instead of silently ignoring the user's request to set the default response character encoding. Note, however, that AbstractMockMvcBuilder already overrides the default method with a concrete implementation which is used by default in MockMvc. See gh-27230 --- .../web/servlet/setup/ConfigurableMockMvcBuilder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java index 43ef6ca954..145dccc8a3 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java @@ -86,14 +86,14 @@ public interface ConfigurableMockMvcBuilderThe default implementation of this method ignores the supplied value. - * Concrete implementations are therefore encouraged to override this method. + *

The default implementation of this method throws an + * {@link UnsupportedOperationException}. Concrete implementations are therefore + * encouraged to override this method. * @param defaultResponseCharacterEncoding the default response character encoding * @since 5.3.10 */ - @SuppressWarnings("unchecked") default T defaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding) { - return (T) this; + throw new UnsupportedOperationException(); } /**