Browse Source

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
pull/27365/head
Sam Brannen 4 years ago
parent
commit
87d3d1bbd1
  1. 8
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java

8
spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java

@ -86,14 +86,14 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder @@ -86,14 +86,14 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder
/**
* Define the default character encoding to be applied to every response.
* <p>The default implementation of this method ignores the supplied value.
* Concrete implementations are therefore encouraged to override this method.
* <p>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 extends B> T defaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding) {
return (T) this;
throw new UnsupportedOperationException();
}
/**

Loading…
Cancel
Save