diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java
index fe3df32ede..f31a5870e4 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java
@@ -215,11 +215,12 @@ public abstract class AbstractErrorWebExceptionHandler
Date timestamp = (Date) error.get("timestamp");
Object message = error.get("message");
Object trace = error.get("trace");
- Object logPrefix = error.get("logPrefix");
+ Object requestId = error.get("requestId");
builder.append("
This application has no configured error view, so you are seeing this as a fallback.
")
.append("There was an unexpected error (type=")
+ .append("
[").append(requestId)
+ .append("] There was an unexpected error (type=")
.append(htmlEscape(error.get("error"))).append(", status=")
.append(htmlEscape(error.get("status"))).append(").
");
if (message != null) {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
index b0caa27ab5..111b4e42cb 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
@@ -83,7 +83,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
.jsonPath("path").isEqualTo(("/")).jsonPath("message")
.isEqualTo("Expected!").jsonPath("exception").doesNotExist()
- .jsonPath("trace").doesNotExist().jsonPath("logPrefix")
+ .jsonPath("trace").doesNotExist().jsonPath("requestId")
.isEqualTo(this.logIdFilter.getLogId());
this.outputCapture.expect(Matchers.allOf(
containsString("500 Server Error for HTTP GET \"/\""),
@@ -99,7 +99,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.expectBody().jsonPath("status").isEqualTo("404").jsonPath("error")
.isEqualTo(HttpStatus.NOT_FOUND.getReasonPhrase()).jsonPath("path")
.isEqualTo(("/notFound")).jsonPath("exception").doesNotExist()
- .jsonPath("logPrefix").isEqualTo(this.logIdFilter.getLogId());
+ .jsonPath("requestId").isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -128,7 +128,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("path")
.isEqualTo(("/bind")).jsonPath("exception").doesNotExist()
.jsonPath("errors").isArray().jsonPath("message").isNotEmpty()
- .jsonPath("logPrefix").isEqualTo(this.logIdFilter.getLogId());
+ .jsonPath("requestId").isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -145,7 +145,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
.jsonPath("exception")
.isEqualTo(IllegalStateException.class.getName())
- .jsonPath("trace").exists().jsonPath("logPrefix")
+ .jsonPath("trace").exists().jsonPath("requestId")
.isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -161,7 +161,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
.jsonPath("exception")
.isEqualTo(IllegalStateException.class.getName())
- .jsonPath("trace").exists().jsonPath("logPrefix")
+ .jsonPath("trace").exists().jsonPath("requestId")
.isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -177,7 +177,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
.jsonPath("exception")
.isEqualTo(IllegalStateException.class.getName())
- .jsonPath("trace").doesNotExist().jsonPath("logPrefix")
+ .jsonPath("trace").doesNotExist().jsonPath("requestId")
.isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -193,7 +193,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase())
.jsonPath("exception")
.isEqualTo(ResponseStatusException.class.getName())
- .jsonPath("logPrefix").isEqualTo(this.logIdFilter.getLogId());
+ .jsonPath("requestId").isEqualTo(this.logIdFilter.getLogId());
});
}
@@ -326,7 +326,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
@Override
public Mono
filter(ServerWebExchange exchange, WebFilterChain chain) {
- this.logId = exchange.getLogPrefix();
+ this.logId = exchange.getRequest().getId();
return chain.filter(exchange);
}
diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java
index 8699627623..b7f119367d 100644
--- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java
+++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java
@@ -44,6 +44,7 @@ import org.springframework.web.server.ServerWebExchange;
* errors - Any {@link ObjectError}s from a {@link BindingResult} exception
* trace - The exception stack trace
* path - The URL path when the exception was raised
+ * requestId - Unique Id associated with the current request
*
*
* @author Brian Clozel
@@ -86,7 +87,7 @@ public class DefaultErrorAttributes implements ErrorAttributes {
errorAttributes.put("status", errorStatus.value());
errorAttributes.put("error", errorStatus.getReasonPhrase());
errorAttributes.put("message", determineMessage(error));
- errorAttributes.put("logPrefix", request.exchange().getLogPrefix());
+ errorAttributes.put("requestId", request.exchange().getRequest().getId());
handleException(errorAttributes, determineException(error), includeStackTrace);
return errorAttributes;
}
diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java
index 4c34774254..ebd8180686 100644
--- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java
+++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java
@@ -212,8 +212,8 @@ public class DefaultErrorAttributesTests {
ServerRequest serverRequest = buildServerRequest(request, NOT_FOUND);
Map attributes = this.errorAttributes
.getErrorAttributes(serverRequest, false);
- assertThat(attributes.get("logPrefix"))
- .isEqualTo(serverRequest.exchange().getLogPrefix());
+ assertThat(attributes.get("requestId"))
+ .isEqualTo(serverRequest.exchange().getRequest().getId());
}
@Test