geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r616724 - /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java
Date Wed, 30 Jan 2008 11:23:21 GMT
Author: rickmcguire
Date: Wed Jan 30 03:23:15 2008
New Revision: 616724

URL: http://svn.apache.org/viewvc?rev=616724&view=rev
Log:
GERONIMO-3799 incorrect connect time computation in TimeMonitor

Patch provided by Sangjin Lee. 


Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java?rev=616724&r1=616723&r2=616724&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/util/TimeMonitor.java Wed
Jan 30 03:23:15 2008
@@ -37,7 +37,7 @@
     @Override
     /**
      * Process a notification event.  If this is a 
-     * REQUEST_COMPLETED event, the request timeing 
+     * REQUEST_COMPLETED event, the request timing 
      * information is added to the accumulators to that 
      * average response time can be calculated.
      * 
@@ -49,13 +49,19 @@
         // get the response time
         int type = event.getType();
         if (type == MonitoringEvent.REQUEST_COMPLETED) {
-            requestCount.incrementAndGet();
-            long elapsed = event.getTimeStamp() - event.getRequest().getRequestStartTime();
-            requestTimes.addAndGet(elapsed);
+            long requestStartTime = event.getRequest().getRequestStartTime();
+            if (requestStartTime != 0L) {
+                requestCount.incrementAndGet();
+                long elapsed = event.getTimeStamp() - requestStartTime;
+                requestTimes.addAndGet(elapsed);
+            }
         } else if (type == MonitoringEvent.CONNECTION_SUCCESSFUL) {
-            connectCount.incrementAndGet();
-            long elapsed = event.getTimeStamp() - event.getRequest().getConnectStartTime();
-            connectTimes.addAndGet(elapsed);
+            long connectStartTime = event.getRequest().getConnectStartTime();
+            if (connectStartTime != 0L) {
+                connectCount.incrementAndGet();
+                long elapsed = event.getTimeStamp() - connectStartTime;
+                connectTimes.addAndGet(elapsed);
+            }
         }
     }
     



Mime
View raw message