AlexanderSaydakov commented on code in PR #172:
URL: 
https://github.com/apache/datasketches-memory/pull/172#discussion_r1091153106


##########
datasketches-memory-java8/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectMapMemoryTest.java:
##########
@@ -74,107 +71,72 @@ public void simpleMap2() throws Exception {
       println("");
       Memory mem2 = mem.region(43 + 76, 20);
       println("Mem Cap:       " + mem2.getCapacity());
-      println("Native Off:    " + ((BaseStateImpl)mem).getNativeBaseOffset());
+      println("Native Off:    " + ((ResourceImpl)mem).getNativeBaseOffset());
       println("Offset:        " + mem.getTotalOffset());
-      println("Cum Offset:    " + 
((BaseStateImpl)mem2).getCumulativeOffset(0));
+      println("Cum Offset:    " + ((ResourceImpl)mem2).getCumulativeOffset(0));
       println("Total Offset: " + mem2.getTotalOffset());
       StringBuilder sb2 = new StringBuilder();
       mem2.getCharsFromUtf8(0, 12, sb2);
       println(sb2.toString());
-
-      rh.close();
     }
   }
 
   @Test
-  public void testIllegalArguments() throws Exception {
+  public void testIllegalArguments() {
     File file = getResourceFile("GettysburgAddress.txt");
-    try (MapHandle rh = Memory.map(file, -1, Integer.MAX_VALUE, 
ByteOrder.nativeOrder())) {
-      fail("Failed: testIllegalArgumentException: Position was negative.");
+    try (Memory mem = Memory.map(file, -1, Integer.MAX_VALUE, 
ByteOrder.nativeOrder())) {
+      fail("Failed: Position was negative.");
     } catch (IllegalArgumentException e) {
       //ok
     }
 
-    try (MapHandle rh = Memory.map(file, 0, -1, ByteOrder.nativeOrder())) {
-      fail("Failed: testIllegalArgumentException: Size was negative.");
+    try (Memory mem = Memory.map(file, 0, -1, ByteOrder.nativeOrder())) {
+      fail("Failed: Size was negative.");
     } catch (IllegalArgumentException e) {
       //ok
     }
   }
 
   @Test
-  public void testMapAndMultipleClose() throws Exception {
+  public void testMapAndMultipleClose() {
     File file = getResourceFile("GettysburgAddress.txt");
     long memCapacity = file.length();
-    try (MapHandle rh = Memory.map(file, 0, memCapacity, 
ByteOrder.nativeOrder())) {
-      Memory map = rh.get();
-      assertEquals(memCapacity, map.getCapacity());
-      rh.close();
-      rh.close();
-      map.getCapacity(); //throws assertion error
-    } catch (AssertionError e) {
-      //OK
+    try (Memory mem = Memory.map(file, 0, memCapacity, 
ByteOrder.nativeOrder())) {
+      assertEquals(memCapacity, mem.getCapacity());
     }
-  }
-
-  @Test
-  public void testReadFailAfterClose() throws Exception {
-    File file = getResourceFile("GettysburgAddress.txt");
-    long memCapacity = file.length();
-    try (MapHandle rh = Memory.map(file, 0, memCapacity, 
ByteOrder.nativeOrder())) {
-      Memory mmf = rh.get();
-      rh.close();
-      mmf.getByte(0);
-    } catch (AssertionError e) {
-      //OK
+    try {
+      Memory mem = Memory.map(file, 0, memCapacity, ByteOrder.nativeOrder());
+      mem.close();
+      mem.close(); //redundant close
+    } catch (MemoryCloseException e) { /* OK */ }
+    try {
+      Memory mem = Memory.map(file, 0, memCapacity, ByteOrder.nativeOrder());
+      mem.close();
+      mem.getCapacity(); //already closed

Review Comment:
   so? should this throw or something?



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