kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [1/4] kafka git commit: MINOR: A bunch of clean-ups related to usage of unused variables
Date Tue, 25 Oct 2016 02:17:44 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 1fc450fdb -> d09267383


http://git-wip-us.apache.org/repos/asf/kafka/blob/d0926738/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala b/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
index 7ef4550..d8f0de4 100644
--- a/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
+++ b/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
@@ -40,8 +40,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       zkUtils.createPersistentPath(path)
       fail("Failed to throw ConfigException for missing zookeeper root node")
     } catch {
-      case configException: ConfigException =>
-      case exception: Throwable => fail("Should have thrown ConfigException")
+      case _: ConfigException =>
     }
     zkUtils.close()
   }
@@ -50,13 +49,8 @@ class ZKPathTest extends ZooKeeperTestHarness {
   def testCreatePersistentPath {
     val config = new ConsumerConfig(TestUtils.createConsumerProperties(zkConnect, "test",
"1"))
     val zkUtils = ZkUtils(zkConnect, zkSessionTimeoutMs, config.zkConnectionTimeoutMs, false)
-    try {
-      ZkPath.resetNamespaceCheckedState
-      zkUtils.createPersistentPath(path)
-    } catch {
-      case exception: Throwable => fail("Failed to create persistent path")
-    }
-
+    ZkPath.resetNamespaceCheckedState
+    zkUtils.createPersistentPath(path)
     assertTrue("Failed to create persistent path", zkUtils.pathExists(path))
     zkUtils.close()
   }
@@ -70,8 +64,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       zkUtils.makeSurePersistentPathExists(path)
       fail("Failed to throw ConfigException for missing zookeeper root node")
     } catch {
-      case configException: ConfigException =>
-      case exception: Throwable => fail("Should have thrown ConfigException")
+      case _: ConfigException =>
     }
     zkUtils.close()
   }
@@ -80,13 +73,8 @@ class ZKPathTest extends ZooKeeperTestHarness {
   def testMakeSurePersistsPathExists {
     val config = new ConsumerConfig(TestUtils.createConsumerProperties(zkConnect, "test",
"1"))
     val zkUtils = ZkUtils(zkConnect, zkSessionTimeoutMs, config.zkConnectionTimeoutMs, false)
-    try {
-      ZkPath.resetNamespaceCheckedState
-      zkUtils.makeSurePersistentPathExists(path)
-    } catch {
-      case exception: Throwable => fail("Failed to create persistent path")
-    }
-
+    ZkPath.resetNamespaceCheckedState
+    zkUtils.makeSurePersistentPathExists(path)
     assertTrue("Failed to create persistent path", zkUtils.pathExists(path))
     zkUtils.close()
   }
@@ -100,8 +88,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       zkUtils.createEphemeralPathExpectConflict(path, "somedata")
       fail("Failed to throw ConfigException for missing zookeeper root node")
     } catch {
-      case configException: ConfigException =>
-      case exception: Throwable => fail("Should have thrown ConfigException")
+      case _: ConfigException =>
     }
     zkUtils.close()
   }
@@ -110,13 +97,8 @@ class ZKPathTest extends ZooKeeperTestHarness {
   def testCreateEphemeralPathExists {
     val config = new ConsumerConfig(TestUtils.createConsumerProperties(zkConnect, "test",
"1"))
     val zkUtils = ZkUtils(zkConnect, zkSessionTimeoutMs, config.zkConnectionTimeoutMs, false)
-    try {
-      ZkPath.resetNamespaceCheckedState
-      zkUtils.createEphemeralPathExpectConflict(path, "somedata")
-    } catch {
-      case exception: Throwable => fail("Failed to create ephemeral path")
-    }
-
+    ZkPath.resetNamespaceCheckedState
+    zkUtils.createEphemeralPathExpectConflict(path, "somedata")
     assertTrue("Failed to create ephemeral path", zkUtils.pathExists(path))
     zkUtils.close()
   }
@@ -131,8 +113,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       zkUtils.createSequentialPersistentPath(path)
       fail("Failed to throw ConfigException for missing zookeeper root node")
     } catch {
-      case configException: ConfigException =>
-      case exception: Throwable => fail("Should have thrown ConfigException")
+      case _: ConfigException =>
     }
     zkUtils.close()
   }
@@ -141,15 +122,8 @@ class ZKPathTest extends ZooKeeperTestHarness {
   def testCreatePersistentSequentialExists {
     val config = new ConsumerConfig(TestUtils.createConsumerProperties(zkConnect, "test",
"1"))
     val zkUtils = ZkUtils(zkConnect, zkSessionTimeoutMs, config.zkConnectionTimeoutMs, false)
-
-    var actualPath: String = ""
-    try {
-      ZkPath.resetNamespaceCheckedState
-      actualPath = zkUtils.createSequentialPersistentPath(path)
-    } catch {
-      case exception: Throwable => fail("Failed to create persistent path")
-    }
-
+    ZkPath.resetNamespaceCheckedState
+    val actualPath = zkUtils.createSequentialPersistentPath(path)
     assertTrue("Failed to create persistent path", zkUtils.pathExists(actualPath))
     zkUtils.close()
   }

http://git-wip-us.apache.org/repos/asf/kafka/blob/d0926738/core/src/test/scala/unit/kafka/zk/ZkFourLetterWords.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/zk/ZkFourLetterWords.scala b/core/src/test/scala/unit/kafka/zk/ZkFourLetterWords.scala
index 6eaee70..bd0b257 100644
--- a/core/src/test/scala/unit/kafka/zk/ZkFourLetterWords.scala
+++ b/core/src/test/scala/unit/kafka/zk/ZkFourLetterWords.scala
@@ -39,7 +39,7 @@ object ZkFourLetterWords {
       outStream.write("stat".getBytes)
       outStream.flush()
     } catch {
-      case e: SocketTimeoutException => throw new IOException("Exception while sending
4lw")
+      case e: SocketTimeoutException => throw new IOException("Exception while sending
4lw", e)
     } finally {
       sock.close
     }

http://git-wip-us.apache.org/repos/asf/kafka/blob/d0926738/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBKeyValueStoreTest.java
----------------------------------------------------------------------
diff --git a/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBKeyValueStoreTest.java
b/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBKeyValueStoreTest.java
index 25e0620..7dcd63d 100644
--- a/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBKeyValueStoreTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBKeyValueStoreTest.java
@@ -52,7 +52,7 @@ public class RocksDBKeyValueStoreTest extends AbstractKeyValueStoreTest
{
     @SuppressWarnings("unchecked")
     private <K, V> KeyValueStore<K, V> createStore(final ProcessorContext context,
final Class<K> keyClass, final Class<V> valueClass, final boolean useContextSerdes,
final boolean enableCaching) {
 
-        Stores.PersistentKeyValueFactory<?, ?> factory = null;
+        Stores.PersistentKeyValueFactory<?, ?> factory;
         if (useContextSerdes) {
             factory = Stores
                     .create("my-store")


Mime
View raw message