kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srihar...@apache.org
Subject kafka git commit: KAFKA-2601; ConsoleProducer tool shows stacktrace on invalid command parameters
Date Mon, 05 Oct 2015 05:04:20 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 401601145 -> f9faf334b


KAFKA-2601; ConsoleProducer tool shows stacktrace on invalid command parameters

Author: GabrielNicolasAvellaneda <avellaneda.gabriel@gmail.com>

Reviewers: Ewen Cheslack-Postava <me@ewencp.org>, Sriharsha Chintalapani <harsha@hortonworks.com>

Closes #269 from GabrielNicolasAvellaneda/KAFKA-2601-fix


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

Branch: refs/heads/trunk
Commit: f9faf334b0f62aec04214236dd10e9ba36fb9567
Parents: 4016011
Author: GabrielNicolasAvellaneda <avellaneda.gabriel@gmail.com>
Authored: Mon Oct 5 00:04:03 2015 -0500
Committer: Sriharsha Chintalapani <harsha@hortonworks.com>
Committed: Mon Oct 5 00:04:03 2015 -0500

----------------------------------------------------------------------
 core/src/main/scala/kafka/tools/ConsoleProducer.scala | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/f9faf334/core/src/main/scala/kafka/tools/ConsoleProducer.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/tools/ConsoleProducer.scala b/core/src/main/scala/kafka/tools/ConsoleProducer.scala
index 6971e6e..de50f65 100644
--- a/core/src/main/scala/kafka/tools/ConsoleProducer.scala
+++ b/core/src/main/scala/kafka/tools/ConsoleProducer.scala
@@ -33,11 +33,11 @@ object ConsoleProducer {
 
   def main(args: Array[String]) {
 
-    val config = new ProducerConfig(args)
-    val reader = Class.forName(config.readerClass).newInstance().asInstanceOf[MessageReader]
-    reader.init(System.in, getReaderProps(config))
-
     try {
+        val config = new ProducerConfig(args)
+        val reader = Class.forName(config.readerClass).newInstance().asInstanceOf[MessageReader]
+        reader.init(System.in, getReaderProps(config))
+
         val producer =
           if(config.useNewProducer) {
             new NewShinyProducer(getNewProducerProps(config))
@@ -58,6 +58,9 @@ object ConsoleProducer {
             producer.send(message.topic, message.key, message.message)
         } while(message != null)
     } catch {
+      case e: joptsimple.OptionException =>
+        System.err.println(e.getMessage)
+        System.exit(1)
       case e: Exception =>
         e.printStackTrace
         System.exit(1)


Mime
View raw message