From f574213cc877082d732cccff69bc57b2d5d1393b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Mar 2019 08:30:31 +0000 Subject: [PATCH] Mark log file endpoint as producing text/plain Closes gh-16188 --- .../boot/actuate/logging/LogFileWebEndpoint.java | 4 ++-- .../LogFileWebEndpointWebIntegrationTests.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 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 d0e00c66cc..f5ea0eafbf 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class LogFileWebEndpoint { this(environment, null); } - @ReadOperation + @ReadOperation(produces = "text/plain") 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 7c713c3610..b8f8c2ba8a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.FileCopyUtils; @@ -71,6 +72,14 @@ public class LogFileWebEndpointWebIntegrationTests { .expectBody(String.class).isEqualTo("--TEST--"); } + @Test + public void getRequestThatAcceptsTextPlainProducesResponseWithLogFile() { + 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--"); + } + @Configuration static class TestConfiguration {