Prechádzať zdrojové kódy

Add empty topic error handling

Simon Eskildsen 12 rokov pred
rodič
commit
aa086bfe0b
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      client.go

+ 3 - 0
client.go

@@ -184,6 +184,9 @@ func (client *Client) disconnectBroker(broker *Broker) {
 }
 }
 
 
 func (client *Client) refreshMetadata(topics []string, retries int) error {
 func (client *Client) refreshMetadata(topics []string, retries int) error {
+	// Kafka will throw exceptions on an empty topic and not return a proper
+	// error. This handles the case by returning an error instead of sending it
+	// off to Kafka. See: https://github.com/Shopify/sarama/pull/38#issuecomment-26362310
 	for _, topic := range topics {
 	for _, topic := range topics {
 		if len(topic) == 0 {
 		if len(topic) == 0 {
 			return NoSuchTopic
 			return NoSuchTopic