kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-4775; Fix findbugs warnings in kafka-tools
Date Fri, 17 Feb 2017 09:46:27 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 505af6bfd -> a88737929


KAFKA-4775; Fix findbugs warnings in kafka-tools

Author: Colin P. Mccabe <cmccabe@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #2559 from cmccabe/KAFKA-4775


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/a8873792
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/a8873792
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/a8873792

Branch: refs/heads/trunk
Commit: a88737929e880d5c6892a306d3c9b1358853b76b
Parents: 505af6b
Author: Colin P. Mccabe <cmccabe@confluent.io>
Authored: Fri Feb 17 01:46:14 2017 -0800
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Feb 17 01:46:14 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/kafka/tools/ClientCompatibilityTest.java   | 6 +++---
 .../main/java/org/apache/kafka/tools/ThroughputThrottler.java  | 6 ++----
 .../main/java/org/apache/kafka/tools/VerifiableProducer.java   | 2 +-
 3 files changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/a8873792/tools/src/main/java/org/apache/kafka/tools/ClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/kafka/tools/ClientCompatibilityTest.java b/tools/src/main/java/org/apache/kafka/tools/ClientCompatibilityTest.java
index 0430c2e..663fa4a 100644
--- a/tools/src/main/java/org/apache/kafka/tools/ClientCompatibilityTest.java
+++ b/tools/src/main/java/org/apache/kafka/tools/ClientCompatibilityTest.java
@@ -287,15 +287,15 @@ public class ClientCompatibilityTest {
         consumer.assign(topicPartitions);
         consumer.seekToBeginning(topicPartitions);
         final Iterator<byte[]> iter = new Iterator<byte[]>() {
-            private final int timeoutMs = 10000;
+            private static final int TIMEOUT_MS = 10000;
             private Iterator<ConsumerRecord<byte[], byte[]>> recordIter = null;
             private byte[] next = null;
 
             private byte[] fetchNext() {
                 while (true) {
                     long curTime = Time.SYSTEM.milliseconds();
-                    if (curTime - prodTimeMs > timeoutMs)
-                        throw new RuntimeException("Timed out after " + timeoutMs + " ms.");
+                    if (curTime - prodTimeMs > TIMEOUT_MS)
+                        throw new RuntimeException("Timed out after " + TIMEOUT_MS + " ms.");
                     if (recordIter == null) {
                         ConsumerRecords<byte[], byte[]> records = consumer.poll(100);
                         recordIter = records.iterator();

http://git-wip-us.apache.org/repos/asf/kafka/blob/a8873792/tools/src/main/java/org/apache/kafka/tools/ThroughputThrottler.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/kafka/tools/ThroughputThrottler.java b/tools/src/main/java/org/apache/kafka/tools/ThroughputThrottler.java
index b550484..37ced2d 100644
--- a/tools/src/main/java/org/apache/kafka/tools/ThroughputThrottler.java
+++ b/tools/src/main/java/org/apache/kafka/tools/ThroughputThrottler.java
@@ -103,16 +103,14 @@ public class ThroughputThrottler {
         // If enough sleep deficit has accumulated, sleep a little
         if (sleepDeficitNs >= MIN_SLEEP_NS) {
             long sleepStartNs = System.nanoTime();
-            long currentTimeNs = sleepStartNs;
             try {
                 synchronized (this) {
-                    long elapsed = currentTimeNs - sleepStartNs;
-                    long remaining = sleepDeficitNs - elapsed;
+                    long remaining = sleepDeficitNs;
                     while (!wakeup && remaining > 0) {
                         long sleepMs = remaining / 1000000;
                         long sleepNs = remaining - sleepMs * 1000000;
                         this.wait(sleepMs, (int) sleepNs);
-                        elapsed = System.nanoTime() - sleepStartNs;
+                        long elapsed = System.nanoTime() - sleepStartNs;
                         remaining = sleepDeficitNs - elapsed;
                     }
                     wakeup = false;

http://git-wip-us.apache.org/repos/asf/kafka/blob/a8873792/tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java b/tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java
index 7617689..367d9c2 100644
--- a/tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java
+++ b/tools/src/main/java/org/apache/kafka/tools/VerifiableProducer.java
@@ -235,7 +235,7 @@ public class VerifiableProducer {
     /** Returns a string to publish: ether 'valuePrefix'.'val' or 'val' **/
     public String getValue(long val) {
         if (this.valuePrefix != null) {
-            return String.format("%d.%d", this.valuePrefix.intValue(), val);
+            return String.format("%d.%d", this.valuePrefix, val);
         }
         return String.format("%d", val);
     }


Mime
View raw message