Skip to content

Commit

Permalink
[fix] Invalid characters (CR/LF) in response header caused by customi…
Browse files Browse the repository at this point in the history
…zed Jackson ObjectMapper

Due to the fact that a user can customize the Jackson ObjectMapper bean (e.g. spring.jackson.serialization.indent-output=true) in Spring Boot, this leads to unwanted errors when it comes to serializing. Therefore, we no longer rely on this ObjectMapper.
  • Loading branch information
xhaggi committed May 31, 2024
1 parent b6aedd2 commit 83d56c0
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.wimdeblauwe.htmx.spring.boot.mvc;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand All @@ -26,14 +27,13 @@ public class HtmxMvcAutoConfiguration implements WebMvcRegistrations, WebMvcConf
private final ObjectMapper objectMapper;

HtmxMvcAutoConfiguration(@Qualifier("viewResolver") ObjectFactory<ViewResolver> resolver,
ObjectFactory<LocaleResolver> locales,
ObjectMapper objectMapper) {
ObjectFactory<LocaleResolver> locales) {
Assert.notNull(resolver, "ViewResolver must not be null!");
Assert.notNull(locales, "LocaleResolver must not be null!");

this.resolver = resolver;
this.locales = locales;
this.objectMapper = objectMapper;
this.objectMapper = JsonMapper.builder().build();
}

@Override
Expand Down

0 comments on commit 83d56c0

Please sign in to comment.