ccaominh commented on a change in pull request #8465: disallow whitespace 
characters in data source names
URL: https://github.com/apache/incubator-druid/pull/8465#discussion_r321408099
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/segment/indexing/DataSchema.java
 ##########
 @@ -98,6 +98,19 @@ public DataSchema(
     this.aggregators = aggregators == null ? new AggregatorFactory[]{} : 
aggregators;
   }
 
+  static void validateDatasourceName(String dataSource)
+  {
+    Preconditions.checkArgument(
+        !Strings.isNullOrEmpty(dataSource),
+        "dataSource cannot be null or empty. Please provide a dataSource."
+    );
+    Preconditions.checkArgument(!dataSource.contains("/"), "dataSource cannot 
contain the '/' character.");
+    Preconditions.checkArgument(
+        !dataSource.matches("(?s)(.*)\\s(.*)"),
 
 Review comment:
   The forbidden apis check is flagging an error here:
   
   > [ERROR] Forbidden method invocation: 
java.lang.String#matches(java.lang.String) [Use startsWith(), endsWith(), 
contains(), or compile and cache a Pattern explicitly]
   
   The regex also looks more complicated than necessary and is causing test 
failures:
   
   https://travis-ci.org/apache/incubator-druid/builds/580987987
   ```
   [ERROR] testIsTaskCurrent[numThreads = 
1](org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorTest)  Time 
elapsed: 0.142 s  <<< ERROR!
   
   java.lang.IllegalArgumentException: dataSource cannot contain whitespace 
character.
   
        at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:125)
   
        at 
org.apache.druid.segment.indexing.DataSchema.validateDatasourceName(DataSchema.java:108)
   
        at 
org.apache.druid.segment.indexing.DataSchema.<init>(DataSchema.java:76)
   
        at 
org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorTest.getDataSchema(KafkaSupervisorTest.java:3636)
   
        at 
org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorTest.testIsTaskCurrent(KafkaSupervisorTest.java:3099)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to