You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2013/01/15 18:45:44 UTC

git commit: ConsoleConsumer throws InvalidConfigException; kafka-697; patched by Swapnil Ghike; reviewed by Jun Rao

Updated Branches:
  refs/heads/0.8 bd5504c05 -> b2eec991d


ConsoleConsumer throws InvalidConfigException; kafka-697; patched by Swapnil Ghike; reviewed by Jun Rao


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

Branch: refs/heads/0.8
Commit: b2eec991d35e7d17b3cfc05438d81637a056aa83
Parents: bd5504c
Author: Jun Rao <ju...@gmail.com>
Authored: Tue Jan 15 09:45:28 2013 -0800
Committer: Jun Rao <ju...@gmail.com>
Committed: Tue Jan 15 09:45:28 2013 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/common/Config.scala      |    6 +++---
 core/src/main/scala/kafka/common/Topic.scala       |    8 +++++---
 .../test/scala/unit/kafka/common/ConfigTest.scala  |    8 ++++----
 .../test/scala/unit/kafka/common/TopicTest.scala   |    4 ++--
 4 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/b2eec991/core/src/main/scala/kafka/common/Config.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/common/Config.scala b/core/src/main/scala/kafka/common/Config.scala
index 53bfcfb..d24fb0d 100644
--- a/core/src/main/scala/kafka/common/Config.scala
+++ b/core/src/main/scala/kafka/common/Config.scala
@@ -23,14 +23,14 @@ import kafka.utils.Logging
 trait Config extends Logging {
 
   def validateChars(prop: String, value: String) {
-    val legalChars = "[a-zA-Z0-9_-]"
+    val legalChars = "[a-zA-Z0-9\\._\\-]"
     val rgx = new Regex(legalChars + "*")
 
     rgx.findFirstIn(value) match {
       case Some(t) =>
         if (!t.equals(value))
-          throw new InvalidConfigException(prop + " " + value + " is illegal, contains a character other than ASCII alphanumerics, _ and -")
-      case None => throw new InvalidConfigException(prop + " " + value + " is illegal, contains a character other than ASCII alphanumerics, _ and -")
+          throw new InvalidConfigException(prop + " " + value + " is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'")
+      case None => throw new InvalidConfigException(prop + " " + value + " is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'")
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/b2eec991/core/src/main/scala/kafka/common/Topic.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/common/Topic.scala b/core/src/main/scala/kafka/common/Topic.scala
index c96ed62..5bd8f6b 100644
--- a/core/src/main/scala/kafka/common/Topic.scala
+++ b/core/src/main/scala/kafka/common/Topic.scala
@@ -20,21 +20,23 @@ package kafka.common
 import util.matching.Regex
 
 object Topic {
-  private val legalChars = "[a-zA-Z0-9_-]"
+  private val legalChars = "[a-zA-Z0-9\\._\\-]"
   private val maxNameLength = 255
   private val rgx = new Regex(legalChars + "+")
 
   def validate(topic: String) {
     if (topic.length <= 0)
       throw new InvalidTopicException("topic name is illegal, can't be empty")
+    else if (topic.equals(".") || topic.equals(".."))
+      throw new InvalidTopicException("topic name cannot be \".\" or \"..\"")
     else if (topic.length > maxNameLength)
       throw new InvalidTopicException("topic name is illegal, can't be longer than " + maxNameLength + " characters")
 
     rgx.findFirstIn(topic) match {
       case Some(t) =>
         if (!t.equals(topic))
-          throw new InvalidTopicException("topic name " + topic + " is illegal, contains a character other than ASCII alphanumerics, _ and -")
-      case None => throw new InvalidTopicException("topic name " + topic + " is illegal,  contains a character other than ASCII alphanumerics, _ and -")
+          throw new InvalidTopicException("topic name " + topic + " is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'")
+      case None => throw new InvalidTopicException("topic name " + topic + " is illegal,  contains a character other than ASCII alphanumerics, '.', '_' and '-'")
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/b2eec991/core/src/test/scala/unit/kafka/common/ConfigTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/common/ConfigTest.scala b/core/src/test/scala/unit/kafka/common/ConfigTest.scala
index 6226dda..74118f4 100644
--- a/core/src/test/scala/unit/kafka/common/ConfigTest.scala
+++ b/core/src/test/scala/unit/kafka/common/ConfigTest.scala
@@ -29,7 +29,7 @@ class ConfigTest {
   @Test
   def testInvalidClientIds() {
     val invalidClientIds = new ArrayBuffer[String]()
-    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', '.', ' ', '\t', '\r', '\n', '=')
+    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
     for (weirdChar <- badChars) {
       invalidClientIds += "Is" + weirdChar + "illegal"
     }
@@ -45,7 +45,7 @@ class ConfigTest {
     }
 
     val validClientIds = new ArrayBuffer[String]()
-    validClientIds += ("valid", "CLIENT", "iDs", "ar6", "VaL1d", "_0-9_", "")
+    validClientIds += ("valid", "CLIENT", "iDs", "ar6", "VaL1d", "_0-9_.", "")
     for (i <- 0 until validClientIds.size) {
       try {
         ProducerConfig.validateClientId(validClientIds(i))
@@ -59,7 +59,7 @@ class ConfigTest {
   @Test
   def testInvalidGroupIds() {
     val invalidGroupIds = new ArrayBuffer[String]()
-    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', '.', ' ', '\t', '\r', '\n', '=')
+    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
     for (weirdChar <- badChars) {
       invalidGroupIds += "Is" + weirdChar + "illegal"
     }
@@ -75,7 +75,7 @@ class ConfigTest {
     }
 
     val validGroupIds = new ArrayBuffer[String]()
-    validGroupIds += ("valid", "GROUP", "iDs", "ar6", "VaL1d", "_0-9_", "")
+    validGroupIds += ("valid", "GROUP", "iDs", "ar6", "VaL1d", "_0-9_.", "")
     for (i <- 0 until validGroupIds.size) {
       try {
         ConsumerConfig.validateGroupId(validGroupIds(i))

http://git-wip-us.apache.org/repos/asf/kafka/blob/b2eec991/core/src/test/scala/unit/kafka/common/TopicTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/common/TopicTest.scala b/core/src/test/scala/unit/kafka/common/TopicTest.scala
index b37553e..c8f8f4d 100644
--- a/core/src/test/scala/unit/kafka/common/TopicTest.scala
+++ b/core/src/test/scala/unit/kafka/common/TopicTest.scala
@@ -32,7 +32,7 @@ class TopicTest {
     for (i <- 1 to 6)
       longName += longName
     invalidTopicNames += longName
-    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', '.')
+    val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
     for (weirdChar <- badChars) {
       invalidTopicNames += "Is" + weirdChar + "illegal"
     }
@@ -48,7 +48,7 @@ class TopicTest {
     }
 
     val validTopicNames = new ArrayBuffer[String]()
-    validTopicNames += ("valid", "TOPIC", "nAmEs", "ar6", "VaL1d", "_0-9_")
+    validTopicNames += ("valid", "TOPIC", "nAmEs", "ar6", "VaL1d", "_0-9_.")
     for (i <- 0 until validTopicNames.size) {
       try {
         Topic.validate(validTopicNames(i))