Skip to content

Commit

Permalink
Throw UnsupportedOperationException in defaultResponseCharacterEncodi…
Browse files Browse the repository at this point in the history
…ng()

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 spring-projectsgh-27230
  • Loading branch information
sbrannen committed Sep 6, 2021
1 parent 1b3fd9e commit 87d3d1b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 87d3d1b

Please sign in to comment.