From 02b24b6ed3e5a72bb999d2c77130ba362cb0978f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 2 Apr 2019 10:52:18 +0100 Subject: [PATCH] Specify that log file endpoint's response is UTF-8 encoded Closes gh-16189 --- .../boot/actuate/logging/LogFileWebEndpoint.java | 2 +- .../logging/LogFileWebEndpointWebIntegrationTests.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java index 8cb0389ace..1b897a8a15 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java @@ -55,7 +55,7 @@ public class LogFileWebEndpoint { this(environment, null); } - @ReadOperation(produces = "text/plain") + @ReadOperation(produces = "text/plain; charset=UTF-8") public Resource logFile() { Resource logFileResource = getLogFileResource(); if (logFileResource == null || !logFileResource.isReadable()) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java index 5cb08de718..4302e3f1c3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java @@ -69,6 +69,7 @@ public class LogFileWebEndpointWebIntegrationTests { TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath()) .applyTo(context); client.get().uri("/actuator/logfile").exchange().expectStatus().isOk() + .expectHeader().contentType("text/plain; charset=UTF-8") .expectBody(String.class).isEqualTo("--TEST--"); } @@ -77,7 +78,9 @@ public class LogFileWebEndpointWebIntegrationTests { TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath()) .applyTo(context); client.get().uri("/actuator/logfile").accept(MediaType.TEXT_PLAIN).exchange() - .expectStatus().isOk().expectBody(String.class).isEqualTo("--TEST--"); + .expectStatus().isOk().expectHeader() + .contentType("text/plain; charset=UTF-8").expectBody(String.class) + .isEqualTo("--TEST--"); } @Configuration