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


##########
server/src/main/java/org/apache/druid/query/ResultLevelCachingQueryRunner.java:
##########
@@ -164,6 +165,16 @@
     }
   }
 
+  private boolean mayUseCache(QueryPlus queryPlus)

Review Comment:
   ## Useless parameter
   
   The parameter 'queryPlus' is never used.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6031)



##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -106,20 +109,57 @@
       if (config == null) {
         config = defaultConfig();
       }
-      return base;
+      return new Statement()
+      {
+        @Override
+        public void evaluate() throws Throwable
+        {
+          SqlTestFramework framework = get();

Review Comment:
   ## Unread local variable
   
   Variable 'SqlTestFramework framework' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6030)



##########
server/src/test/java/org/apache/druid/server/EtagProvider.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Key;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.TableDataSource;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public interface EtagProvider
+{
+  static Key<EtagProvider> KEY = Key.get(EtagProvider.class, 
EtagProvider.Annotation.class);
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD})
+  @BindingAnnotation
+  static @interface Annotation

Review Comment:
   ## Class has same name as super class
   
   Annotation has the same name as its supertype 
[java.lang.annotation.Annotation](1).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6028)



##########
server/src/test/java/org/apache/druid/server/QueryStackTests.java:
##########
@@ -113,7 +127,22 @@
     // No instantiation.
   }
 
+  interface TestCacheKey

Review Comment:
   ## Unused classes and interfaces
   
   Unused interface: TestCacheKey is not referenced within this codebase. If 
not used as an external API it should be removed.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6029)



##########
server/src/test/java/org/apache/druid/server/EtagProvider.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Key;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.TableDataSource;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public interface EtagProvider
+{
+  static Key<EtagProvider> KEY = Key.get(EtagProvider.class, 
EtagProvider.Annotation.class);
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD})
+  @BindingAnnotation
+  static @interface Annotation
+  {
+  }
+
+  String getEtagFor(Query<?> query);
+
+  static class EmptyEtagProvider implements EtagProvider
+  {
+    @Override
+    public String getEtagFor(Query<?> query)
+    {
+      return null;
+    }
+  }
+
+  static class AlwaysNewEtagProvider implements EtagProvider
+  {
+    AtomicInteger etagSerial = new AtomicInteger();
+
+    @Override
+    public String getEtagFor(Query<?> query)
+    {
+      if (query.getDataSource().isCacheable(true)) {
+        return "TEST_ETAG-" + etagSerial.incrementAndGet();
+      } else {
+        return null;
+      }
+    }
+  }
+
+  static class ProvideEtagBasedOnDatasource implements EtagProvider
+  {
+    @Override
+    public String getEtagFor(Query<?> query)
+    {
+      if (!query.getDataSource().isCacheable(true)) {
+        return null;
+      }
+      if (!(query.getDataSource() instanceof TableDataSource)) {
+        throw DruidException.defensive("only TableDataSource handled right 
now");
+      }
+      try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+        TableDataSource tableDataSource = (TableDataSource) 
query.getDataSource();
+        baos.write(query.getDataSource().getCacheKey());
+        baos.write(tableDataSource.getName().getBytes(StandardCharsets.UTF_8));
+        return "ETP-" + new String(baos.toByteArray(), StandardCharsets.UTF_8);
+      }
+      catch (IOException e) {
+        throw DruidException.defensive().build("Unexpected IOException", e);

Review Comment:
   ## Unused format argument
   
   This format call refers to 0 argument(s) but supplies 1 argument(s).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6027)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to