From aabedae5bac80a438ca84e8a83199a0bfdba8a9b Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Thu, 18 Jul 2024 12:38:25 +0300 Subject: [PATCH] Initialise ChannelOperations#shortId on demand (#3357) --- .../java/reactor/netty/channel/ChannelOperations.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java b/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java index d34a4568d6..165ed1f31e 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java +++ b/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2011-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,12 +127,12 @@ else if (recorder instanceof ContextAwareChannelMetricsRecorder) { final FluxReceive inbound; final ConnectionObserver listener; final Sinks.Empty onTerminate; - final String shortId; volatile Subscription outboundSubscription; boolean localActive; String longId; + String shortId; protected ChannelOperations(ChannelOperations replaced) { this.connection = replaced.connection; @@ -155,7 +155,6 @@ public ChannelOperations(Connection connection, ConnectionObserver listener) { this.listener = requireNonNull(listener, "listener"); this.onTerminate = Sinks.unsafe().empty(); this.inbound = new FluxReceive(this); - shortId = initShortId(); } @Nullable @@ -594,6 +593,10 @@ public Context currentContext() { @Override public String asShortText() { + if (shortId == null) { + shortId = initShortId(); + } + return shortId; }