Append unique number to WebFlux server log prefix
Closes gh-22039
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.http.server.reactive;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
@@ -47,6 +48,9 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private static final AtomicLong logPrefixIndex = new AtomicLong(0);
|
||||
|
||||
|
||||
private final HttpServerRequest request;
|
||||
|
||||
private final NettyDataBufferFactory bufferFactory;
|
||||
@@ -181,8 +185,11 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Override
|
||||
@Nullable
|
||||
protected String initId() {
|
||||
return this.request instanceof Connection ?
|
||||
((Connection) this.request).channel().id().asShortText() : null;
|
||||
if (this.request instanceof Connection) {
|
||||
return ((Connection) this.request).channel().id().asShortText() +
|
||||
"-" + logPrefixIndex.incrementAndGet();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user