Skip to content

Commit f574213

Browse files
committed
Mark log file endpoint as producing text/plain
Closes gh-16188
1 parent 7153525 commit f574213

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public LogFileWebEndpoint(Environment environment) {
5555
this(environment, null);
5656
}
5757

58-
@ReadOperation
58+
@ReadOperation(produces = "text/plain")
5959
public Resource logFile() {
6060
Resource logFileResource = getLogFileResource();
6161
if (logFileResource == null || !logFileResource.isReadable()) {

Diff for: spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.context.annotation.Bean;
3232
import org.springframework.context.annotation.Configuration;
3333
import org.springframework.core.env.Environment;
34+
import org.springframework.http.MediaType;
3435
import org.springframework.test.web.reactive.server.WebTestClient;
3536
import org.springframework.util.FileCopyUtils;
3637

@@ -71,6 +72,14 @@ public void getRequestProducesResponseWithLogFile() {
7172
.expectBody(String.class).isEqualTo("--TEST--");
7273
}
7374

75+
@Test
76+
public void getRequestThatAcceptsTextPlainProducesResponseWithLogFile() {
77+
TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath())
78+
.applyTo(context);
79+
client.get().uri("/actuator/logfile").accept(MediaType.TEXT_PLAIN).exchange()
80+
.expectStatus().isOk().expectBody(String.class).isEqualTo("--TEST--");
81+
}
82+
7483
@Configuration
7584
static class TestConfiguration {
7685

0 commit comments

Comments
 (0)