This is an automated email from the ASF dual-hosted git repository.

markt 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 7257f98007 Use LongAdder for processing time - prompted by Coverity 
scan report
7257f98007 is described below

commit 7257f98007f7750daab26706146cc1a4ba8984f0
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Aug 14 17:48:39 2023 +0100

    Use LongAdder for processing time - prompted by Coverity scan report
---
 java/org/apache/catalina/core/StandardWrapperValve.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index 80da74e13a..fadf923731 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -63,7 +63,7 @@ final class StandardWrapperValve extends ValveBase {
     // Some JMX statistics. This valve is associated with a StandardWrapper.
     // We expose the StandardWrapper as JMX ( j2eeType=Servlet ). The fields
     // are here for performance.
-    private volatile long processingTime;
+    private final LongAdder processingTime = new LongAdder();
     private volatile long maxTime;
     private volatile long minTime = Long.MAX_VALUE;
     private final AtomicInteger requestCount = new AtomicInteger(0);
@@ -238,7 +238,7 @@ final class StandardWrapperValve extends ValveBase {
             long t2 = System.currentTimeMillis();
 
             long time = t2 - t1;
-            processingTime += time;
+            processingTime.add(time);
             if (time > maxTime) {
                 maxTime = time;
             }
@@ -279,7 +279,7 @@ final class StandardWrapperValve extends ValveBase {
     }
 
     public long getProcessingTime() {
-        return processingTime;
+        return processingTime.sum();
     }
 
     public long getMaxTime() {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to