This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new b2462cfb1c Review "Always de-register upgraded connection
statistics..."
b2462cfb1c is described below
commit b2462cfb1cd2010e228c6dc06fbf716a073c7803
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 2 11:41:07 2026 +0000
Review "Always de-register upgraded connection statistics..."
Avoid double deregistration
---
java/org/apache/coyote/http11/upgrade/UpgradeInfo.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java
b/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java
index 24b9566887..87d9eb1938 100644
--- a/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java
+++ b/java/org/apache/coyote/http11/upgrade/UpgradeInfo.java
@@ -16,6 +16,8 @@
*/
package org.apache.coyote.http11.upgrade;
+import java.util.concurrent.atomic.AtomicReference;
+
/**
* Structure to hold statistical information about connections that have been
established using the HTTP/1.1 upgrade
* mechanism. Bytes sent/received will always be populated. Messages
sent/received will be populated if that makes sense
@@ -32,7 +34,7 @@ public class UpgradeInfo {
/**
* The parent group info for aggregated statistics.
*/
- private UpgradeGroupInfo groupInfo = null;
+ private final AtomicReference<UpgradeGroupInfo> groupInfo = new
AtomicReference<>();
/**
* Counter for bytes sent.
*/
@@ -57,7 +59,7 @@ public class UpgradeInfo {
* @return the group info
*/
public UpgradeGroupInfo getGlobalProcessor() {
- return groupInfo;
+ return groupInfo.get();
}
@@ -68,12 +70,12 @@ public class UpgradeInfo {
*/
public void setGroupInfo(UpgradeGroupInfo groupInfo) {
if (groupInfo == null) {
- if (this.groupInfo != null) {
- this.groupInfo.removeUpgradeInfo(this);
- this.groupInfo = null;
+ UpgradeGroupInfo oldGroupInfo = this.groupInfo.getAndSet(null);
+ if (oldGroupInfo != null) {
+ oldGroupInfo.removeUpgradeInfo(this);
}
} else {
- this.groupInfo = groupInfo;
+ this.groupInfo.set(groupInfo);
groupInfo.addUpgradeInfo(this);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]