Scrivio Interview library
DebuggingIntermediate6 min read · updated 12 November 2026

After a teammate overrode configureMessageConverters in a WebMvcConfigurer to add a CSV converter, all JSON endpoints started returning 406 or using a different date format. Explain why, and the correct way to add a converter.

configureMessageConverters is the method for replacing the converter list: Spring MVC registers its default converters only if the list is still empty after every configurer has run, so adding a converter there switches the defaults off. Depending on the setup, that removes the JSON converter entirely (406 responses) or replaces Boot's Jackson converter, built from the configured ObjectMapper, with one using plain defaults (a different date format). The correct way is extendMessageConverters, which receives the already configured list, or, in Spring Boot, simply declaring the converter as a bean; and converter order matters, because the first converter that can write the requested type wins.

Why this question is asked

This is a typical upgrade-week mystery: a small change in one file, a CSV export for one endpoint, and suddenly unrelated JSON endpoints fail or change their output. The cause is a method name that sounds additive but is not. Interviewers ask it because the answer requires knowing how the converter list is built and who contributes to it. In this answer, we will reproduce the problem, follow how Spring builds the converter list to see why the defaults disappear, explain both symptoms, and then fix it the right way and protect it with tests.

1Reproducing the Problem

The teammate's change looked harmless.

Java
@Configuration
class WebConfig implements WebMvcConfigurer {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new CsvHttpMessageConverter()); // for the export endpoint
converters.add(new MappingJackson2HttpMessageConverter()); // "to keep JSON working"
}
}
// Before the change:
// GET /orders/7 Accept: application/json -> 200 {"id":7,"createdAt":"2026-11-05T10:15:30Z"}
// After the change, depending on the service:
// GET /orders/7 Accept: application/json -> 406 Not Acceptable (no JSON converter left)
// GET /orders/7 Accept: application/json -> 200 {"id":7,"createdAt":1793873730.000000000} (plain mapper)

Both symptoms come from the same mistake. Which one a service shows depends on what else is in the list, as we will see.

2How Spring Builds the Converter List

When Spring MVC sets up its infrastructure, it creates an empty list and calls configureMessageConverters(list) on every WebMvcConfigurer. If the list is still empty afterwards, it adds the default converters: byte arrays, strings, resources, forms, and JSON and XML converters for whatever libraries are on the classpath. Then it calls extendMessageConverters(list) on every configurer, which can add, remove or reorder.

So configureMessageConverters means: I am supplying the list myself. The moment it receives any element, the defaults are skipped. That is documented behaviour, not a bug, but the method's name invites people to think it adds.

Spring Boot adds one more layer. Boot builds its own set of converters, including a Jackson converter using the ObjectMapper configured by spring.jackson.* properties and customizers, and contributes them through its own configurer. In a service with @EnableWebMvc, or one where the Boot contribution does not end up in the list, our two converters are all there is.

Step throughHow the converter list is assembled
  1. Start with an empty list
  2. Every configurer's configureMessageConvertersours adds CSV and a new Jackson converter
  3. Is the list still empty?
    Yesadd Spring's default convertersNoskip the defaults
  4. Every configurer's extendMessageConvertersadd, remove or reorder
  5. Final list used for reading and writingfirst match wins

5 steps in order. Play them, or step through them one at a time.

3Explaining the Two Symptoms

406 Not Acceptable means no converter in the list can write the return type as the media type the client accepts. If the final list contains our CSV converter and no working JSON converter, for example because the teammate added only the CSV converter, or because the CSV converter claims application/json requests it cannot actually write, JSON endpoints have nobody to serialise their objects, and Spring answers 406.

The date format change is the subtler case. new MappingJackson2HttpMessageConverter() creates its own ObjectMapper with Spring's builder defaults, not Boot's configured mapper. Boot normally disables writing dates as timestamps and applies every spring.jackson property and customizer; the new mapper has none of that. Because the defaults were skipped, this plain converter is now the JSON converter, and dates come out as numbers. Any other team-wide settings, such as property naming or null handling, change at the same time.

Notice that neither symptom appears at startup. The application starts fine, and only responses change, which is why such a change can pass a quick manual test of the CSV endpoint and still reach production.

4The Correct Way to Add a Converter

In Spring Boot the simplest fix is to declare the converter as a bean and delete the override. Boot collects HttpMessageConverter beans and adds them to its converter list, in front of the defaults, keeping its own Jackson converter.

Java
@Configuration
class ConverterConfig {
@Bean
HttpMessageConverter<?> csvConverter() {
return new CsvHttpMessageConverter(); // supports text/csv only
}
}
// GET /orders/7 Accept: application/json -> 200 {"id":7,"createdAt":"2026-11-05T10:15:30Z"}
// GET /orders/export Accept: text/csv -> 200 id,createdAt / 7,2026-11-05T10:15:30Z

Outside Boot, or when we need to control the position precisely, we use extendMessageConverters, which receives the fully configured list, defaults included.

5Order Matters

When writing a response, Spring walks the converter list and uses the first converter that can write the return type as an acceptable media type. If a generic converter comes first, it can win requests meant for a specific one. So specific converters go before generic ones, and each converter should declare only the media types it truly supports: our CSV converter should support text/csv and nothing else, never */*.

Java
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(0, new CsvHttpMessageConverter()); // specific, so first; text/csv only
// Boot's Jackson converter stays in the list with its configured ObjectMapper
}

If the CSV converter claimed */*, a client sending Accept: */*, which is what many HTTP tools send by default, could receive CSV from an endpoint everyone expects to return JSON.

6Protecting It With Tests

The change slipped through because nothing checked the JSON endpoints' output format. A small set of web tests fixes that: for each kind of endpoint, assert the content type and one formatted field.

Java
@WebMvcTest(OrderController.class)
class ConverterContractTest {
@Autowired MockMvc mvc;
@Test
void jsonKeepsIsoDates() throws Exception {
mvc.perform(get("/orders/7").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.createdAt").value("2026-11-05T10:15:30Z")); // fails with the plain mapper
}
@Test
void csvExport() throws Exception {
mvc.perform(get("/orders/export").accept("text/csv"))
.andExpect(content().contentTypeCompatibleWith("text/csv"));
}
}

@WebMvcTest loads the WebMvcConfigurer beans and Boot's converter setup, so these tests would have failed on the teammate's change before it was merged.

7Follow-up questions

When is configureMessageConverters the right choice?

When we really want to define the whole list ourselves, for example a service that must only ever speak one format with a specially configured converter. Then we should add every converter we need explicitly, and document that the defaults are intentionally gone.

Why did adding a new Jackson converter not keep things working?

Because a converter created with new uses its own ObjectMapper with framework defaults, not the one Spring Boot configured from spring.jackson properties and customizers. If a Jackson converter must be created by hand, it should be given Boot's ObjectMapper bean, but usually the better answer is not to create one at all.

Does Spring Boot 4 change this?

The ideas are the same, but Spring Framework 7 and Boot 4 move to Jackson 3, with new converter classes, and Boot's converter registration has changed shape. The advice holds: add converters through the extension mechanism Boot documents for your version rather than replacing the list.

8Conclusion

In this answer, we saw that configureMessageConverters replaces the converter list: Spring adds its defaults only if the list is empty after all configurers have run, so any converter added there switches them off. That produces either 406 responses, when no JSON converter remains, or a changed date format, when a plain Jackson converter replaces Boot's configured one. The fix is to declare the converter as a bean in Boot or use extendMessageConverters, place specific converters first with narrow media types, and pin the output formats with web tests.

What to say in the interviewAbout 90 seconds aloud

Open with

The issue is that configureMessageConverters doesn't add to the list, it defines it. Spring MVC calls it on every configurer with an empty list, and only if the list is still empty afterwards does it register the defaults.

Then, if they want more

So as soon as my teammate added the CSV converter there, the defaults were skipped. That explains both symptoms. If no usable JSON converter is left, or the CSV converter wrongly claims JSON, Spring can't write the objects as application/json and returns 406.

And if they also added new MappingJackson2HttpMessageConverter to keep JSON working, that converter has its own ObjectMapper with plain defaults, not Boot's mapper configured from the spring.jackson properties. Boot normally writes dates as ISO strings; the plain one writes them as numbers, and other settings like naming or null handling change too.

Nothing fails at startup, which is why it slipped through. The fix in Boot is simplest: delete the override and declare the CSV converter as an HttpMessageConverter bean, and Boot adds it alongside its own converters. Outside Boot, or to control position, use extendMessageConverters, which gets the configured list with defaults.

Order matters because the first converter that can write the type for the accepted media type wins, so specific converters go first and the CSV one should support text/csv only, never */*. And I'd add @WebMvcTest tests asserting content type and a date field for JSON and CSV endpoints.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "After a teammate overrode configureMessageConverters in a WebMvcConfigurer to add a CSV...": https://scrivio-interview-library.netlify.app/spring-boot/mvc-architecture/dcf1b7ac9b/