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

[pulsar] branch master updated: Fix ArrayIndexOutOfBoundsException in PerformanceProducer. (#5786)

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

zhaijia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 54ec194  Fix ArrayIndexOutOfBoundsException in PerformanceProducer. (#5786)
54ec194 is described below

commit 54ec19423883e6c1ab3db828ab13ef92aba511a5
Author: lipenghui <pe...@apache.org>
AuthorDate: Sat Dec 7 17:05:28 2019 +0800

    Fix ArrayIndexOutOfBoundsException in PerformanceProducer. (#5786)
    
    Fixes #5760
    
    ### Motivation
    
    We use `org.HdrHistogram.Recorder` to record write latency and `highestTrackableValue` is `TimeUnit.SECONDS.toMicros(120000)`, but we record the value in micros, the error happens when the latency in micros is a very large number, so this PR change the `highestTrackableValue` of Recorder to `TimeUnit.SECONDS.toMicros(120000)`
---
 .../java/org/apache/pulsar/testclient/PerformanceProducer.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
index 9d7e4b9..0bd40c3 100644
--- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
+++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
@@ -87,8 +87,8 @@ public class PerformanceProducer {
     private static final LongAdder totalMessagesSent = new LongAdder();
     private static final LongAdder totalBytesSent = new LongAdder();
 
-    private static Recorder recorder = new Recorder(TimeUnit.SECONDS.toMillis(120000), 5);
-    private static Recorder cumulativeRecorder = new Recorder(TimeUnit.SECONDS.toMillis(120000), 5);
+    private static Recorder recorder = new Recorder(TimeUnit.SECONDS.toMicros(120000), 5);
+    private static Recorder cumulativeRecorder = new Recorder(TimeUnit.SECONDS.toMicros(120000), 5);
 
     static class Arguments {
 
@@ -521,6 +521,11 @@ public class PerformanceProducer {
                             cumulativeRecorder.recordValue(latencyMicros);
                         }
                     }).exceptionally(ex -> {
+                        // Ignore the exception of recorder since a very large latencyMicros will lead
+                        // ArrayIndexOutOfBoundsException in AbstractHistogram
+                        if (ex.getCause() instanceof ArrayIndexOutOfBoundsException) {
+                            return null;
+                        }
                         log.warn("Write error on message", ex);
                         messagesFailed.increment();
                         if (arguments.exitOnFailure) {