amazon-archives / kinesis-storm-spout

Kinesis spout for Storm
Other
106 stars 64 forks source link

bugfix ZookeeperShardState:IOException is never thrown #5

Closed nmatsui closed 8 years ago

nmatsui commented 10 years ago

ZookeeperSharedState can't be compiled because it has unnecessary try-catch clause.

[info] Compiling 28 Java sources to /home/vagrant/kinesis-storm-spout/target/scala-2.10/classes...
[error] /home/vagrant/kinesis-storm-spout/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java:67: error: exception IOException is never thrown in body of corresponding try statement
[error]         } catch (IOException e) {
[error]           ^
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
christiangda commented 8 years ago

Hi nmatsui, I fixed that, doing the following

 git diff origin/master -- /home/christian/Git/kinesis-storm-spout/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java

diff --git a/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java b/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java
index 1b4a72f..a42f0c2 100644
--- a/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java
+++ b/src/main/java/com/amazonaws/services/kinesis/stormspout/state/zookeeper/ZookeeperShardState.java
@@ -64,11 +64,11 @@ class ZookeeperShardState {
         try {
             zk = CuratorFrameworkFactory.newClient(config.getZookeeperConnectionString(),
                     new ExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_NUM_RETRIES));
-        } catch (IOException e) {
+           zk.start();
+        } catch (Exception e) {
             LOG.error("Could not connect to ZooKeeper", e);
             throw new KinesisSpoutException(e);
         }
-        zk.start();
     }

     /**