You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/07/30 11:32:21 UTC

[servicecomb-java-chassis] branch master updated: [SCB-2052] fix get connection time is 0 when get connection timeout

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a27c59  [SCB-2052] fix get connection time is 0 when get connection timeout
7a27c59 is described below

commit 7a27c595e545ff75c213e752c6811ba6c26b352d
Author: wujimin <wu...@huawei.com>
AuthorDate: Thu Jul 30 17:19:44 2020 +0800

    [SCB-2052] fix get connection time is 0 when get connection timeout
---
 .../foundation/vertx/metrics/metric/DefaultHttpSocketMetric.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/metrics/metric/DefaultHttpSocketMetric.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/metrics/metric/DefaultHttpSocketMetric.java
index 6d98512..dfc5a5f 100644
--- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/metrics/metric/DefaultHttpSocketMetric.java
+++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/metrics/metric/DefaultHttpSocketMetric.java
@@ -16,6 +16,8 @@
  */
 package org.apache.servicecomb.foundation.vertx.metrics.metric;
 
+// if can not get connection from connection pool
+// then both requestBeginTime and requestEndTime will be 0
 public class DefaultHttpSocketMetric extends DefaultTcpSocketMetric {
   private long requestBeginTime;
 
@@ -29,7 +31,7 @@ public class DefaultHttpSocketMetric extends DefaultTcpSocketMetric {
   }
 
   public long getRequestBeginTime() {
-    return requestBeginTime;
+    return requestBeginTime != 0 ? requestBeginTime : System.nanoTime();
   }
 
   public void requestBegin() {
@@ -37,7 +39,7 @@ public class DefaultHttpSocketMetric extends DefaultTcpSocketMetric {
   }
 
   public long getRequestEndTime() {
-    return requestEndTime;
+    return requestEndTime != 0 ? requestEndTime : System.nanoTime();
   }
 
   public void requestEnd() {