You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2019/07/12 08:05:46 UTC

[pulsar-client-go] branch master updated: Fix runtime error: integer divide by zero (#20)

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

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new e9f77e8  Fix runtime error: integer divide by zero (#20)
e9f77e8 is described below

commit e9f77e8451ad98acb27380af8b66343530e684dc
Author: 冉小龙 <ra...@gmail.com>
AuthorDate: Fri Jul 12 16:05:42 2019 +0800

    Fix runtime error: integer divide by zero (#20)
    
    Signed-off-by: xiaolong.ran <ra...@gmail.com>
---
 pulsar/internal/default_router.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pulsar/internal/default_router.go b/pulsar/internal/default_router.go
index cbdff53..cb391b9 100644
--- a/pulsar/internal/default_router.go
+++ b/pulsar/internal/default_router.go
@@ -63,7 +63,10 @@ func NewDefaultRouter(clock Clock, hashFunc func(string) uint32, maxBatchingDela
 		// of batching of the messages.
 		//
 		//currentMs / maxBatchingDelayMs + startPtnIdx
-		n := uint32(state.clock()/uint64(maxBatchingDelay.Nanoseconds())) + state.shiftIdx
-		return int(n % numPartitions)
+		if maxBatchingDelay.Nanoseconds() != 0 {
+			n := uint32(state.clock()/uint64(maxBatchingDelay.Nanoseconds())) + state.shiftIdx
+			return int(n % numPartitions)
+		}
+		return 0
 	}
 }