Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ private void checkConverterSupports(HttpMessageConverter<?> converter, MediaType
throw new IllegalArgumentException("converter should support '" + mediaType + "'");
}

void addCustomMessageConverter(HttpMessageConverter<?> customConverter) {
void addCustomMessageConverter(int index, HttpMessageConverter<?> customConverter) {
Assert.notNull(customConverter, "'customConverter' must not be null");
this.customConverters.add(customConverter);
this.customConverters.add(index, customConverter);
}

void addMessageConverterConfigurer(Consumer<HttpMessageConverter<?>> configurer) {
Expand Down Expand Up @@ -432,7 +432,13 @@ public ClientBuilder withYamlConverter(HttpMessageConverter<?> yamlConverter) {

@Override
public ClientBuilder addCustomConverter(HttpMessageConverter<?> customConverter) {
addCustomMessageConverter(customConverter);
addCustomConverter(0, customConverter);
return this;
}

@Override
public ClientBuilder addCustomConverter(int index, HttpMessageConverter<?> customConverter) {
addCustomMessageConverter(index, customConverter);
return this;
}

Expand Down Expand Up @@ -529,7 +535,13 @@ public ServerBuilder withYamlConverter(HttpMessageConverter<?> yamlConverter) {

@Override
public ServerBuilder addCustomConverter(HttpMessageConverter<?> customConverter) {
addCustomMessageConverter(customConverter);
addCustomMessageConverter(0, customConverter);
return this;
}

@Override
public ServerBuilder addCustomConverter(int index, HttpMessageConverter<?> customConverter) {
addCustomMessageConverter(0, customConverter);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ interface Builder<T extends Builder<T>> {
*/
T addCustomConverter(HttpMessageConverter<?> customConverter);


/**
* Add a custom {@code HttpMessageConverter} to the list of converters, at the specified index, pushing all existing message converters forward one.
* @param customConverter the converter instance to add
*/
T addCustomConverter(int index, HttpMessageConverter<?> customConverter);

/**
* Add a consumer for configuring the selected message converters.
* @param configurer the configurer to use
Expand Down