github-advanced-security[bot] commented on code in PR #576:
URL: https://github.com/apache/datasketches-java/pull/576#discussion_r1706054867


##########
src/test/java/org/apache/datasketches/quantiles/DirectQuantilesMemoryRequestTest.java:
##########
@@ -47,35 +46,30 @@
     final int initBytes = ((2 * k) + 4) << 3; //just the BB
 
     //########## Owning Implementation
-    // This part would actually be part of the Memory owning implemention so 
it is faked here
-    try (WritableHandle wdh = WritableMemory.allocateDirect(initBytes,
-            ByteOrder.nativeOrder(), new DefaultMemoryRequestServer())) {
-      final WritableMemory wmem = wdh.getWritable();
-      println("Initial mem size: " + wmem.getCapacity());
-
-      //########## Receiving Application
-      // The receiving application has been given wmem to use for a sketch,
-      // but alas, it is not ultimately large enough.
-      final UpdateDoublesSketch usk1 = 
DoublesSketch.builder().setK(k).build(wmem);
-      assertTrue(usk1.isEmpty());
-
-      //Load the sketch
-      for (int i = 0; i < u; i++) {
-        // The sketch uses The MemoryRequest, acquired from wmem, to acquire 
more memory as
-        // needed, and requests via the MemoryRequest to free the old 
allocations.
-        usk1.update(i);
-      }
-      final double result = usk1.getQuantile(0.5);
-      println("Result: " + result);
-      assertEquals(result, u / 2.0, 0.05 * u); //Success
-
-      //########## Owning Implementation
-      //The actual Memory has been re-allocated several times,
-      // so the above wmem reference is invalid.
-      println("\nFinal mem size: " + wmem.getCapacity());
-    } catch (Exception e) {
-      throw new RuntimeException(e);
+    // This part would actually be part of the Memory owning implementation so 
it is faked here
+    WritableMemory wmem = WritableMemory.allocateDirect(initBytes, 
ByteOrder.nativeOrder(), new DefaultMemoryRequestServer());
+    println("Initial mem size: " + wmem.getCapacity());
+
+    //########## Receiving Application
+    // The receiving application has been given wmem to use for a sketch,
+    // but alas, it is not ultimately large enough.
+    final UpdateDoublesSketch usk1 = 
DoublesSketch.builder().setK(k).build(wmem);
+    assertTrue(usk1.isEmpty());
+
+    //Load the sketch
+    for (int i = 0; i < u; i++) {
+      // The sketch uses The MemoryRequest, acquired from wmem, to acquire 
more memory as
+      // needed, and requests via the MemoryRequest to free the old 
allocations.
+      usk1.update(i);
     }
+    final double result = usk1.getQuantile(0.5);
+    println("Result: " + result);
+    assertEquals(result, u / 2.0, 0.05 * u); //Success
+
+    //The actual Memory has been re-allocated several times,
+    // so the the wmem reference is invalid. Use the sketch to get the last 
memory reference.
+    WritableMemory lastMem = usk1.getMemory();

Review Comment:
   ## Unread local variable
   
   Variable 'WritableMemory lastMem' is never read.
   
   [Show more 
details](https://github.com/apache/datasketches-java/security/code-scanning/735)



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