[
https://issues.apache.org/jira/browse/KAFKA-1618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133254#comment-14133254
]
Neha Narkhede commented on KAFKA-1618:
--------------------------------------
[[email protected]] To answer your question -
{noformat}
nnarkhed-mn1:tools nnarkhed$ pwd
/Users/nnarkhed/Projects/kafka-git-idea/core/src/main/scala/kafka/tools
nnarkhed-mn1:tools nnarkhed$ grep -R "broker-list" *
ConsoleProducer.scala: val brokerListOpt = parser.accepts("broker-list",
"REQUIRED: The broker list string in the form HOST1:PORT1,HOST2:PORT2.")
ConsoleProducer.scala: .describedAs("broker-list")
GetOffsetShell.scala: val brokerListOpt = parser.accepts("broker-list",
"REQUIRED: The list of hostname and port of the server to connect to.")
ProducerPerformance.scala: val brokerListOpt = parser.accepts("broker-list",
"REQUIRED: broker info (the list of broker host and port for bootstrap.")
ReplayLogProducer.scala: val brokerListOpt = parser.accepts("broker-list",
"REQUIRED: the broker list must be specified.")
ReplicaVerificationTool.scala: val brokerListOpt =
parser.accepts("broker-list", "REQUIRED: The list of hostname and port of the
server to connect to.")
SimpleConsumerShell.scala: val brokerListOpt = parser.accepts("broker-list",
"REQUIRED: The list of hostname and port of the server to connect to.")
{noformat}
Few review comments -
1. In lines 222-227, options.valueOf(brokerListOpt) is repeated several times.
It will be great if you can extract the value in a local variable and use that.
2. I'm actually a -1 on guessing anything and hardcoding it. Currently, the
defaults we have for the broker port are inconsistent and exist in 2 different
places (KafkaConfig and server.properties). Since the users can start Kafka on
a different port anyways, the behavior of the tools would be more confusing if
we attempt to guess the port ineffectively. I'd prefer exiting after giving a
clear error message instead.
> Exception thrown when running console producer with no port number for the
> broker
> ---------------------------------------------------------------------------------
>
> Key: KAFKA-1618
> URL: https://issues.apache.org/jira/browse/KAFKA-1618
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.8.1.1
> Reporter: Gwen Shapira
> Assignee: Gwen Shapira
> Labels: newbie
> Fix For: 0.8.2
>
> Attachments: KAFKA-1618.patch
>
>
> When running console producer with just "localhost" as the broker list, I get
> ArrayIndexOutOfBounds exception.
> I expect either a clearer error about arguments or for the producer to
> "guess" a default port.
> [root@shapira-1 bin]# ./kafka-console-producer.sh --topic rufus1
> --broker-list localhost
> java.lang.ArrayIndexOutOfBoundsException: 1
> at
> kafka.client.ClientUtils$$anonfun$parseBrokerList$1.apply(ClientUtils.scala:102)
> at
> kafka.client.ClientUtils$$anonfun$parseBrokerList$1.apply(ClientUtils.scala:97)
> at
> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
> at
> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
> at
> scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
> at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
> at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
> at scala.collection.AbstractTraversable.map(Traversable.scala:105)
> at kafka.client.ClientUtils$.parseBrokerList(ClientUtils.scala:97)
> at
> kafka.producer.BrokerPartitionInfo.<init>(BrokerPartitionInfo.scala:32)
> at
> kafka.producer.async.DefaultEventHandler.<init>(DefaultEventHandler.scala:41)
> at kafka.producer.Producer.<init>(Producer.scala:59)
> at kafka.producer.ConsoleProducer$.main(ConsoleProducer.scala:158)
> at kafka.producer.ConsoleProducer.main(ConsoleProducer.scala)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)