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


##########
processing/src/main/java/org/apache/druid/query/rowsandcols/StorageAdapterRowsAndColumns.java:
##########
@@ -98,45 +95,36 @@
   @Nonnull
   private static RowsAndColumns materialize(StorageAdapter as)
   {
-    final Sequence<Cursor> cursors = as.makeCursors(
-        null,
-        Intervals.ETERNITY,
-        VirtualColumns.EMPTY,
-        Granularities.ALL,
-        false,
-        null
-    );
-
-    RowSignature rowSignature = as.getRowSignature();
-
-    FrameWriter writer = cursors.accumulate(null, (accumulated, in) -> {
-      if (accumulated != null) {
-        // We should not get multiple cursors because we set the granularity 
to ALL.  So, this should never
-        // actually happen, but it doesn't hurt us to defensive here, so we 
test against it.
-        throw new ISE("accumulated[%s] non-null, why did we get multiple 
cursors?", accumulated);
+    try (final CursorMaker maker = 
as.asCursorMaker(CursorBuildSpec.FULL_SCAN)) {
+      final Cursor cursor = maker.makeCursor();
+
+      if (cursor == null) {
+        return new EmptyRowsAndColumns();
       }
+      
+      final RowSignature rowSignature = as.getRowSignature();
 
-      final ColumnSelectorFactory columnSelectorFactory = 
in.getColumnSelectorFactory();
+      final ColumnSelectorFactory columnSelectorFactory = 
cursor.getColumnSelectorFactory();
 
       final FrameWriterFactory frameWriterFactory = 
FrameWriters.makeColumnBasedFrameWriterFactory(
           new ArenaMemoryAllocatorFactory(200 << 20), // 200 MB, because, why 
not?
           rowSignature,
           Collections.emptyList()
       );
 
-      final FrameWriter frameWriter = 
frameWriterFactory.newFrameWriter(columnSelectorFactory);
-      while (!in.isDoneOrInterrupted()) {
-        frameWriter.addSelection();
-        in.advance();
+      try(final FrameWriter writer = 
frameWriterFactory.newFrameWriter(columnSelectorFactory)) {
+        while (!cursor.isDoneOrInterrupted()) {
+          writer.addSelection();

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [writer](1) may be null at this access as suggested by [this](2) 
null guard.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/7620)



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