github-advanced-security[bot] commented on code in PR #16382:
URL: https://github.com/apache/druid/pull/16382#discussion_r1592570164


##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -37,76 +45,168 @@
 import java.lang.annotation.Target;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
- * Annotation to specify desired framework settings.
+ * Specifies current framework settings.
+ *
+ * Intended usage from tests is via the annotations:
+ *   @SqlTestFrameworkConfig.MinTopNThreshold(33)
  *
- * This class provides junit rule facilities to build the framework accordingly
- * to the annotation. These rules also cache the previously created frameworks.
+ * In case of annotations used; it picks up all annotations from:
+ *  * the method
+ *  * its enclosing class and its parents
+ * if none contains a specific setting the default is being taken.
+ *
+ * All configurable setting should have:
+ *   * an annotation with `value` with the desired type
+ *   * the annotation itself should be annotated with itslef to set the 
default value
+ *   * a field should be added to the main config class
  */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface SqlTestFrameworkConfig
+public class SqlTestFrameworkConfig
 {
-  int numMergeBuffers() default 0;
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD, ElementType.TYPE})
+  @NumMergeBuffers(0)
+  public @interface NumMergeBuffers
+  {
+    static ConfigOptionProcessor<Integer> PROCESSOR = new 
ConfigOptionProcessor<Integer>(NumMergeBuffers.class)
+    {
+      @Override
+      public Integer fromString(String str)
+      {
+        return Integer.valueOf(str);

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/7353)



##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -37,76 +45,168 @@
 import java.lang.annotation.Target;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
- * Annotation to specify desired framework settings.
+ * Specifies current framework settings.
+ *
+ * Intended usage from tests is via the annotations:
+ *   @SqlTestFrameworkConfig.MinTopNThreshold(33)
  *
- * This class provides junit rule facilities to build the framework accordingly
- * to the annotation. These rules also cache the previously created frameworks.
+ * In case of annotations used; it picks up all annotations from:
+ *  * the method
+ *  * its enclosing class and its parents
+ * if none contains a specific setting the default is being taken.
+ *
+ * All configurable setting should have:
+ *   * an annotation with `value` with the desired type
+ *   * the annotation itself should be annotated with itslef to set the 
default value
+ *   * a field should be added to the main config class
  */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface SqlTestFrameworkConfig
+public class SqlTestFrameworkConfig
 {
-  int numMergeBuffers() default 0;
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD, ElementType.TYPE})
+  @NumMergeBuffers(0)
+  public @interface NumMergeBuffers
+  {
+    static ConfigOptionProcessor<Integer> PROCESSOR = new 
ConfigOptionProcessor<Integer>(NumMergeBuffers.class)
+    {
+      @Override
+      public Integer fromString(String str)
+      {
+        return Integer.valueOf(str);
+      }
+    };
 
-  int minTopNThreshold() default TopNQueryConfig.DEFAULT_MIN_TOPN_THRESHOLD;
+    int value();
+  }
 
-  ResultCacheMode resultCache() default ResultCacheMode.DISABLED;
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD, ElementType.TYPE})
+  @MinTopNThreshold(TopNQueryConfig.DEFAULT_MIN_TOPN_THRESHOLD)
+  public @interface MinTopNThreshold
+  {
+    static ConfigOptionProcessor<Integer> PROCESSOR = new 
ConfigOptionProcessor<Integer>(MinTopNThreshold.class)
+    {
+      @Override
+      public Integer fromString(String str)
+      {
+        return Integer.valueOf(str);

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/7354)



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to