Use charset for heath info in HealthFilter
@@ -28,6 +28,7 @@ import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
import reactor.util.annotation.Nullable;
+import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -49,8 +50,7 @@ public final class HealthFilter implements WebFilter {
private Mono<Void> writeHealthInfo(final ServerWebExchange exchange) {
String result = JsonUtils.toJson(new Health.Builder().up().build());
- // TODO this is a risk for error charset coding with getBytes
- DataBuffer dataBuffer = exchange.getResponse().bufferFactory().wrap(result.getBytes());
+ DataBuffer dataBuffer = exchange.getResponse().bufferFactory().wrap(result.getBytes(Charset.forName("UTF-8")));
return exchange.getResponse().writeWith(Mono.just(dataBuffer));
}
}
