From 809112cd5fd945481654d4575f57eb59e7475e69 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Tue, 25 Apr 2017 13:03:00 +0900 Subject: [PATCH] DirectDruidClient: Fix division by zero. (#4206) * DirectDruidClient: Fix division by zero. Introduced in #3954 when some floating math was changed to integer math. This patch restores the old math. * Added comment. --- server/src/main/java/io/druid/client/DirectDruidClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index d8dc7882a74..c3311798a5a 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -269,13 +269,14 @@ public class DirectDruidClient implements QueryRunner { long stopTimeNs = System.nanoTime(); long nodeTimeNs = stopTimeNs - responseStartTimeNs; + final long nodeTimeMs = TimeUnit.NANOSECONDS.toMillis(nodeTimeNs); log.debug( "Completed queryId[%s] request to url[%s] with %,d bytes returned in %,d millis [%,f b/s].", query.getId(), url, byteCount.get(), - TimeUnit.NANOSECONDS.toMillis(nodeTimeNs), - byteCount.get() / TimeUnit.NANOSECONDS.toSeconds(nodeTimeNs) + nodeTimeMs, + byteCount.get() / (0.001 * nodeTimeMs) // Floating math; division by zero will yield Inf, not exception ); queryMetrics.reportNodeTime(nodeTimeNs); queryMetrics.reportNodeBytes(byteCount.get());