Skip to content

Commit 2fcee5a

Browse files
committed
Append unique number to WebFlux server log prefix
Closes gh-22039
1 parent d499e14 commit 2fcee5a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -19,6 +19,7 @@
1919
import java.net.InetSocketAddress;
2020
import java.net.URI;
2121
import java.net.URISyntaxException;
22+
import java.util.concurrent.atomic.AtomicLong;
2223

2324
import javax.net.ssl.SSLSession;
2425

@@ -47,6 +48,9 @@
4748
*/
4849
class ReactorServerHttpRequest extends AbstractServerHttpRequest {
4950

51+
private static final AtomicLong logPrefixIndex = new AtomicLong(0);
52+
53+
5054
private final HttpServerRequest request;
5155

5256
private final NettyDataBufferFactory bufferFactory;
@@ -181,8 +185,11 @@ public <T> T getNativeRequest() {
181185
@Override
182186
@Nullable
183187
protected String initId() {
184-
return this.request instanceof Connection ?
185-
((Connection) this.request).channel().id().asShortText() : null;
188+
if (this.request instanceof Connection) {
189+
return ((Connection) this.request).channel().id().asShortText() +
190+
"-" + logPrefixIndex.incrementAndGet();
191+
}
192+
return null;
186193
}
187194

188195
}

0 commit comments

Comments
 (0)