This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch UpdateNotice
in repository 
https://gitbox.apache.org/repos/asf/incubator-datasketches-memory.git

commit 649b1da4223329dcecc80900931e70dd58ff37f9
Author: Lee Rhodes <[email protected]>
AuthorDate: Sat Apr 25 13:38:15 2020 -0700

    add SuppressWarnings
---
 .../org/apache/datasketches/memory/AllocateDirectMap.java     | 11 ++++++-----
 .../memory/AllocateDirectWritableMapMemoryTest.java           |  9 +++++----
 .../datasketches/memory/ExampleMemoryRequestServerTest.java   |  3 ++-
 .../java/org/apache/datasketches/memory/ZeroCapacityTest.java |  2 +-
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java 
b/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
index 5d51281..41cdf46 100644
--- a/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
+++ b/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
@@ -102,12 +102,13 @@ class AllocateDirectMap implements Map {
   final boolean resourceReadOnly;
 
   //called from AllocateDirectWritableMap constructor
+  @SuppressWarnings("resource")
   AllocateDirectMap(final File file, final long fileOffsetBytes, final long 
capacityBytes,
       final boolean localReadOnly) {
     this.capacityBytes = capacityBytes;
     resourceReadOnly = isFileReadOnly(file);
     final long fileLength = file.length();
-    if ((localReadOnly || resourceReadOnly) && ((fileOffsetBytes + 
capacityBytes) > fileLength)) {
+    if ((localReadOnly || resourceReadOnly) && fileOffsetBytes + capacityBytes 
> fileLength) {
       throw new IllegalArgumentException(
           "Read-only mode and requested map length is greater than current 
file length: "
           + "Requested Length = " + (fileOffsetBytes + capacityBytes)
@@ -200,7 +201,7 @@ class AllocateDirectMap implements Map {
     final RandomAccessFile raf;
     try {
       raf = new RandomAccessFile(file, mode);
-      if ((fileOffset + capacityBytes) > raf.length()) {
+      if (fileOffset + capacityBytes > raf.length()) {
         raf.setLength(fileOffset + capacityBytes);
       }
     } catch (final IOException e) {
@@ -262,12 +263,12 @@ class AllocateDirectMap implements Map {
       BaseState.currentDirectMemoryMapAllocations_.incrementAndGet();
       BaseState.currentDirectMemoryMapAllocated_.addAndGet(capacityBytes);
       myRaf = raf;
-      assert (myRaf != null);
+      assert myRaf != null;
       myFc = myRaf.getChannel();
       actualNativeBaseOffset = nativeBaseOffset;
-      assert (actualNativeBaseOffset != 0);
+      assert actualNativeBaseOffset != 0;
       myCapacity = capacityBytes;
-      assert (myCapacity != 0);
+      assert myCapacity != 0;
     }
 
     StepBoolean getValid() {
diff --git 
a/src/test/java/org/apache/datasketches/memory/AllocateDirectWritableMapMemoryTest.java
 
b/src/test/java/org/apache/datasketches/memory/AllocateDirectWritableMapMemoryTest.java
index f1eadc1..bdf361f 100644
--- 
a/src/test/java/org/apache/datasketches/memory/AllocateDirectWritableMapMemoryTest.java
+++ 
b/src/test/java/org/apache/datasketches/memory/AllocateDirectWritableMapMemoryTest.java
@@ -23,9 +23,9 @@
 
 package org.apache.datasketches.memory;
 
-import static org.apache.datasketches.memory.Util.*;
-import static org.apache.datasketches.memory.AllocateDirectMap.isFileReadOnly;
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.datasketches.memory.AllocateDirectMap.isFileReadOnly;
+import static org.apache.datasketches.memory.Util.getResourceFile;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
@@ -94,7 +94,7 @@ public class AllocateDirectWritableMapMemoryTest {
       WritableMemory dstMem = dstHandle.get();
       WritableMemory srcMem = srcHandle.get();
 
-      for (long i = 0; i < (longs); i++) {
+      for (long i = 0; i < longs; i++) {
         srcMem.putLong(i << 3, i); //load source with consecutive longs
       }
 
@@ -103,7 +103,7 @@ public class AllocateDirectWritableMapMemoryTest {
       dstHandle.force(); //push any remaining to the file
 
       //check end value
-      assertEquals(dstMem.getLong((longs - 1L) << 3), longs - 1L);
+      assertEquals(dstMem.getLong(longs - 1L << 3), longs - 1L);
     }
   }
 
@@ -130,6 +130,7 @@ public class AllocateDirectWritableMapMemoryTest {
     }
   }
 
+  @SuppressWarnings("resource")
   @Test(expectedExceptions = RuntimeException.class)
   public void testMapException() throws IOException {
     File dummy = createFile("dummy.txt", ""); //zero length
diff --git 
a/src/test/java/org/apache/datasketches/memory/ExampleMemoryRequestServerTest.java
 
b/src/test/java/org/apache/datasketches/memory/ExampleMemoryRequestServerTest.java
index b047348..f30ccab 100644
--- 
a/src/test/java/org/apache/datasketches/memory/ExampleMemoryRequestServerTest.java
+++ 
b/src/test/java/org/apache/datasketches/memory/ExampleMemoryRequestServerTest.java
@@ -65,6 +65,7 @@ public class ExampleMemoryRequestServerTest {
     }
   }
 
+  @SuppressWarnings("resource")
   @Test(expectedExceptions = IllegalArgumentException.class)
   public void checkZeroCapacity() {
     ExampleMemoryRequestServer svr = new ExampleMemoryRequestServer();
@@ -133,7 +134,7 @@ public class ExampleMemoryRequestServerTest {
     public void requestClose(WritableMemory memToRelease, WritableMemory 
newMemory) {
       if (memToRelease != null) {
         WritableHandle handle = map.get(memToRelease);
-        if ((handle != null) && (handle.get() == memToRelease)) {
+        if (handle != null && handle.get() == memToRelease) {
           handle.close();
         }
       }
diff --git a/src/test/java/org/apache/datasketches/memory/ZeroCapacityTest.java 
b/src/test/java/org/apache/datasketches/memory/ZeroCapacityTest.java
index 4ccda15..2389b91 100644
--- a/src/test/java/org/apache/datasketches/memory/ZeroCapacityTest.java
+++ b/src/test/java/org/apache/datasketches/memory/ZeroCapacityTest.java
@@ -32,7 +32,7 @@ import org.testng.annotations.Test;
 @SuppressWarnings("javadoc")
 public class ZeroCapacityTest {
 
-  @SuppressWarnings("unused")
+  @SuppressWarnings({ "unused", "resource" })
   @Test
   public void checkZeroCapacity() {
     WritableMemory wmem = WritableMemory.allocate(0);


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

Reply via email to