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


##########
processing/src/main/java/org/apache/druid/java/util/common/MemoryBoundLinkedBlockingQueue.java:
##########
@@ -61,12 +92,56 @@
     return ret;
   }
 
+  public Stream<ObjectContainer<T>> stream()
+  {
+    return queue.stream();
+  }
+
+  public int drain(Collection<? super ObjectContainer<T>> buffer, int 
bytesToDrain, long timeout, TimeUnit unit)
+      throws InterruptedException
+  {
+    Preconditions.checkNotNull(buffer);
+    long deadline = System.nanoTime() + unit.toNanos(timeout);
+    int added = 0;
+    int bytesAdded = 0;
+    while (bytesAdded < bytesToDrain) {
+      ObjectContainer<T> e = queue.poll(deadline - System.nanoTime(), 
TimeUnit.NANOSECONDS);
+      if (e == null) {
+        break;
+      }
+      currentMemory.addAndGet(-e.getSize());
+      buffer.add(e);
+      ++added;
+      bytesAdded += e.getSize();

Review Comment:
   ## Implicit narrowing conversion in compound assignment
   
   Implicit cast of source type long to narrower destination type int.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/6012)



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