You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2022/06/05 01:57:03 UTC

[datasketches-memory17] branch main updated: Fixed SpotBugs warnings

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 701b0a7  Fixed SpotBugs warnings
701b0a7 is described below

commit 701b0a7da1c4dbb93e1c3970b621fc156971adc6
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sat Jun 4 18:56:57 2022 -0700

    Fixed SpotBugs warnings
---
 .../org/apache/datasketches/memory/Memory.java     | 29 +++++++++++---
 .../apache/datasketches/memory/WritableMemory.java | 31 ++++++++++++---
 .../memory/internal/BaseWritableBufferImpl.java    |  9 ++---
 .../memory/internal/BaseWritableMemoryImpl.java    | 31 +++++++++------
 .../AllocateDirectWritableMapMemoryTest.java       | 46 ++++++++++++----------
 .../memory/internal/BaseStateTest.java             |  1 -
 .../memory/internal/BufferBoundaryCheckTest.java   | 30 +++++++-------
 .../datasketches/memory/internal/LeafImplTest.java |  8 +---
 .../datasketches/memory/internal/MemoryTest.java   |  3 +-
 .../memory/internal/SpecificLeafTest.java          |  8 +---
 .../datasketches/memory/internal/UtilTest.java     | 12 +-----
 tools/FindBugsExcludeFilter.xml                    | 10 +++++
 12 files changed, 131 insertions(+), 87 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/memory/Memory.java b/src/main/java/org/apache/datasketches/memory/Memory.java
index 85f9993..5222a01 100644
--- a/src/main/java/org/apache/datasketches/memory/Memory.java
+++ b/src/main/java/org/apache/datasketches/memory/Memory.java
@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.nio.file.InvalidPathException;
 import java.util.Objects;
 
 import org.apache.datasketches.memory.internal.BaseWritableMemoryImpl;
@@ -79,9 +80,18 @@ public interface Memory extends BaseState {
    * @param file the given file to map. It must be non-null with a non-negative length and readable.
    * @param scope the given ResourceScope. It must be non-null.
    * @return mapped Memory.
-   * @throws Exception various IO exceptions
-   */
-  static Memory map(File file, ResourceScope scope) throws Exception {
+   * @throws IllegalArgumentException -- if file is not readable.
+   * @throws InvalidPathException for invalid path
+   * @throws IllegalStateException - if scope has been already closed, or if access occurs from a thread other
+   * than the thread owning scope.
+   * @throws UnsupportedOperationException - if an unsupported map mode is specified.
+   * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+   * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
+   * required by the implementation.
+   */
+  static Memory map(File file, ResourceScope scope)
+      throws IllegalArgumentException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     return map(file, 0, file.length(), scope, ByteOrder.nativeOrder());
   }
 
@@ -93,12 +103,19 @@ public interface Memory extends BaseState {
    * @param scope the given ResourceScope. It must be non-null.
    * @param byteOrder the byte order to be used.  It must be non-null.
    * @return mapped Memory
-   * @throws Exception various IO exceptions
-   * @throws IllegalArgumentException if file is not readable
+   * @throws IllegalArgumentException -- if file is not readable.
+   * @throws InvalidPathException for invalid path
+   * @throws IllegalStateException - if scope has been already closed, or if access occurs from a thread other
+   * than the thread owning scope.
+   * @throws UnsupportedOperationException - if an unsupported map mode is specified.
+   * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+   * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
+   * required by the implementation.
    */
   @SuppressWarnings("resource")
   static Memory map(File file, long fileOffsetBytes, long capacityBytes, ResourceScope scope, ByteOrder byteOrder)
-      throws Exception {
+      throws IllegalArgumentException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     Objects.requireNonNull(file, "File must be non-null.");
     Objects.requireNonNull(byteOrder, "ByteOrder must be non-null.");
     Objects.requireNonNull(scope, "ResourceScope must be non-null.");
diff --git a/src/main/java/org/apache/datasketches/memory/WritableMemory.java b/src/main/java/org/apache/datasketches/memory/WritableMemory.java
index 7d0442b..a2a60d2 100644
--- a/src/main/java/org/apache/datasketches/memory/WritableMemory.java
+++ b/src/main/java/org/apache/datasketches/memory/WritableMemory.java
@@ -20,8 +20,10 @@
 package org.apache.datasketches.memory;
 
 import java.io.File;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.nio.file.InvalidPathException;
 import java.util.Objects;
 
 import org.apache.datasketches.memory.internal.BaseWritableMemoryImpl;
@@ -80,9 +82,18 @@ public interface WritableMemory extends Memory {
    * @param file the given file to map. It must be non-null with a non-negative length and writable.
    * @param scope the give Resource Scope. It must be non-null.
    * @return mapped WritableMemory
-   * @throws Exception various IO exceptions
-   */
-  static WritableMemory writableMap(File file, ResourceScope scope) throws Exception {
+   * @throws ReadOnlyException -- if file is not writable.
+   * @throws InvalidPathException for invalid path
+   * @throws IllegalStateException - if scope has been already closed, or if access occurs from a thread other
+   * than the thread owning scope.
+   * @throws UnsupportedOperationException - if an unsupported map mode is specified.
+   * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+   * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
+   * required by the implementation.
+   */
+  static WritableMemory writableMap(File file, ResourceScope scope)
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     return writableMap(file, 0, file.length(), scope, ByteOrder.nativeOrder());
   }
 
@@ -94,12 +105,20 @@ public interface WritableMemory extends Memory {
    * @param scope the give Resource Scope. It must be non-null.
    * @param byteOrder the byte order to be used.  It must be non-null.
    * @return mapped WritableMemory.
-   * @throws Exception various IO exceptions
-   * @throws ReadOnlyException if file is not writable
+   * @throws ReadOnlyException -- if file is not writable.
+   * @throws InvalidPathException for invalid path
+   * @throws IllegalStateException - if scope has been already closed, or if access occurs from a thread other
+   * than the thread owning scope.
+   * @throws UnsupportedOperationException - if an unsupported map mode is specified.
+   * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+   * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
+   * required by the implementation.
    */
   @SuppressWarnings("resource")
   static WritableMemory writableMap(File file, long fileOffsetBytes, long capacityBytes, ResourceScope scope,
-      ByteOrder byteOrder) throws Exception {
+      ByteOrder byteOrder)
+          throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+          IOException, SecurityException {
     Objects.requireNonNull(file, "File must be non-null.");
     Objects.requireNonNull(byteOrder, "ByteOrder must be non-null.");
     Objects.requireNonNull(scope, "ResourceScope must be non-null.");
diff --git a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableBufferImpl.java b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableBufferImpl.java
index 7afb6d8..180c09a 100644
--- a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableBufferImpl.java
+++ b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableBufferImpl.java
@@ -74,14 +74,13 @@ public abstract class BaseWritableBufferImpl extends BaseBufferImpl implements W
         | (localReadOnly ? READONLY : 0)
         | (seg.isNative() ? DIRECT : 0)
         | (seg.isMapped() ? MAP : 0);
-    if (byteOrder == ByteOrder.nativeOrder()) {
-      type |= NATIVE;
-      final WritableBuffer wbuf = NativeWritableBufferImpl.notMemoryExtendable(seg, type);
+    if (byteOrder == NON_NATIVE_BYTE_ORDER) {
+      type |= NONNATIVE;
+      final WritableBuffer wbuf = NonNativeWritableBufferImpl.notMemoryExtendable(seg, type);
       wbuf.setStartPositionEnd(0, byteBuffer.position(), byteBuffer.limit());
       return wbuf;
     }
-    type |= NONNATIVE;
-    final WritableBuffer wbuf = NonNativeWritableBufferImpl.notMemoryExtendable(seg, type);
+    final WritableBuffer wbuf = NativeWritableBufferImpl.notMemoryExtendable(seg, type);
     wbuf.setStartPositionEnd(0, byteBuffer.position(), byteBuffer.limit());
     return wbuf;
   }
diff --git a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
index 901a84f..296b059 100644
--- a/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
+++ b/src/main/java/org/apache/datasketches/memory/internal/BaseWritableMemoryImpl.java
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.FileChannel;
+import java.nio.file.InvalidPathException;
 import java.util.Objects;
 
 import org.apache.datasketches.memory.Buffer;
@@ -74,12 +75,11 @@ public abstract class BaseWritableMemoryImpl extends BaseStateImpl implements Wr
       final MemoryRequestServer memReqSvr) {
     int type = MEMORY
         | (seg.isReadOnly() ? READONLY : 0);
-    if (byteOrder == ByteOrder.nativeOrder()) {
-      type |= NATIVE;
-      return NativeWritableMemoryImpl.memoryExtendable(seg, type, memReqSvr);
+    if (byteOrder == NON_NATIVE_BYTE_ORDER) {
+      type |= NONNATIVE;
+      return NonNativeWritableMemoryImpl.memoryExtendable(seg, type, memReqSvr);
     }
-    type |= NONNATIVE;
-    return NonNativeWritableMemoryImpl.memoryExtendable(seg, type, memReqSvr);
+    return NativeWritableMemoryImpl.memoryExtendable(seg, type, memReqSvr);
   }
 
   //BYTE BUFFER RESOURCE
@@ -95,12 +95,11 @@ public abstract class BaseWritableMemoryImpl extends BaseStateImpl implements Wr
         | (localReadOnly ? READONLY : 0)
         | (seg.isNative() ? DIRECT : 0)
         | (seg.isMapped() ? MAP : 0);
-    if (byteOrder == ByteOrder.nativeOrder()) {
-      type |= NATIVE;
-      return NativeWritableMemoryImpl.notMemoryExtendable(seg, type);
+    if (byteOrder == NON_NATIVE_BYTE_ORDER) {
+      type |= NONNATIVE;
+      return NonNativeWritableMemoryImpl.notMemoryExtendable(seg, type);
     }
-    type |= NONNATIVE;
-    return NonNativeWritableMemoryImpl.notMemoryExtendable(seg, type);
+    return NativeWritableMemoryImpl.notMemoryExtendable(seg, type);
   }
 
   //MAP RESOURCE
@@ -115,7 +114,13 @@ public abstract class BaseWritableMemoryImpl extends BaseStateImpl implements Wr
    * @param localReadOnly the requested read-only state
    * @param byteOrder the byte order to be used.  It must be non-null.
    * @return mapped WritableMemory.
-   * @throws Exception for various IO exceptions
+   * @throws InvalidPathException for invalid path
+   * @throws IllegalStateException - if scope has been already closed, or if access occurs from a thread other
+   * than the thread owning scope.
+   * @throws UnsupportedOperationException - if an unsupported map mode is specified.
+   * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
+   * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
+   * required by the implementation.
    */
   @SuppressWarnings("resource")
   public static WritableMemory wrapMap(
@@ -124,7 +129,9 @@ public abstract class BaseWritableMemoryImpl extends BaseStateImpl implements Wr
       final long capacityBytes,
       final ResourceScope scope,
       final boolean localReadOnly,
-      final ByteOrder byteOrder) throws Exception {
+      final ByteOrder byteOrder)
+          throws InvalidPathException, IllegalStateException, UnsupportedOperationException, IOException,
+          SecurityException {
     final FileChannel.MapMode mapMode = (localReadOnly) ? READ_ONLY : READ_WRITE;
     final MemorySegment seg;
     try {
diff --git a/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java b/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
index a04a68d..2d03098 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/AllocateDirectWritableMapMemoryTest.java
@@ -35,6 +35,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteOrder;
+import java.nio.file.InvalidPathException;
 
 import org.apache.datasketches.memory.BaseState;
 import org.apache.datasketches.memory.DefaultMemoryRequestServer;
@@ -52,12 +53,14 @@ public class AllocateDirectWritableMapMemoryTest {
   private static final MemoryRequestServer memReqSvr = new DefaultMemoryRequestServer();
 
   @BeforeClass
-  public void setReadOnly() {
+  public void setReadOnly() throws IOException {
     UtilTest.setGettysburgAddressFileToReadOnly();
   }
 
   @Test
-  public void simpleMap() throws Exception {
+  public void simpleMap()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     File file = getResourceFile("GettysburgAddress.txt");
     Memory mem = null;
     try (ResourceScope scope = ResourceScope.newConfinedScope()) {
@@ -71,17 +74,15 @@ public class AllocateDirectWritableMapMemoryTest {
   }
 
   @Test
-  public void copyOffHeapToMemoryMappedFile() throws Exception {
+  public void copyOffHeapToMemoryMappedFile()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     long numBytes = 1L << 10; //small for unit tests.  Make it larger than 2GB if you like.
     long numLongs = numBytes >>> 3;
 
     File file = new File("TestFile.bin"); //create a dummy file
     if (file.exists()) {
-      try {
-        java.nio.file.Files.delete(file.toPath());
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
+      java.nio.file.Files.delete(file.toPath());
     }
     assertTrue(file.createNewFile());
     assertTrue (file.setWritable(true, false)); //writable=true, ownerOnly=false
@@ -108,14 +109,12 @@ public class AllocateDirectWritableMapMemoryTest {
   }
 
   @Test
-  public void checkNonNativeFile() throws Exception {
+  public void checkNonNativeFile()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     File file = new File("TestFile2.bin");
     if (file.exists()) {
-      try {
-        java.nio.file.Files.delete(file.toPath());
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
+      java.nio.file.Files.delete(file.toPath());
     }
     assertTrue(file.createNewFile());
     assertTrue(file.setWritable(true, false)); //writable=true, ownerOnly=false
@@ -133,7 +132,9 @@ public class AllocateDirectWritableMapMemoryTest {
 
   @SuppressWarnings("resource")
   @Test
-  public void testMapExceptionNoTWR() throws Exception {
+  public void testMapExceptionNoTWR()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     File dummy = createFile("dummy.txt", ""); //zero length
     ResourceScope scope = ResourceScope.newConfinedScope();
     Memory.map(dummy, 0, dummy.length(), scope, ByteOrder.nativeOrder());
@@ -141,20 +142,23 @@ public class AllocateDirectWritableMapMemoryTest {
   }
 
   @Test(expectedExceptions = ReadOnlyException.class)
-  public void simpleMap2() throws Exception {
+  public void simpleMap2()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     File file = getResourceFile("GettysburgAddress.txt");
     assertTrue(file.canRead());
     assertFalse(file.canWrite());
     WritableMemory wmem = null;
     try (ResourceScope scope = ResourceScope.newConfinedScope()) {
-      wmem = WritableMemory.writableMap(file, scope);
-      //throws ReadOnlyException
+      wmem = WritableMemory.writableMap(file, scope); //throws ReadOnlyException
       wmem.getCapacity();
     }
   }
 
   @Test(expectedExceptions = ReadOnlyException.class)
-  public void checkReadException() throws Exception  {
+  public void checkReadException()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     File file = getResourceFile("GettysburgAddress.txt");
     WritableMemory wmem = null;
     try (ResourceScope scope = ResourceScope.newConfinedScope()) {
@@ -165,7 +169,9 @@ public class AllocateDirectWritableMapMemoryTest {
   }
 
   @Test
-  public void testForce() throws Exception {
+  public void testForce()
+      throws ReadOnlyException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
+      IOException, SecurityException {
     String origStr = "Corectng spellng mistks";
     File origFile = createFile("force_original.txt", origStr); //23
     assertTrue(origFile.setWritable(true, false));
diff --git a/src/test/java/org/apache/datasketches/memory/internal/BaseStateTest.java b/src/test/java/org/apache/datasketches/memory/internal/BaseStateTest.java
index b58b238..edc3ad0 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/BaseStateTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/BaseStateTest.java
@@ -21,7 +21,6 @@ package org.apache.datasketches.memory.internal;
 
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
 
 import java.nio.ByteOrder;
 
diff --git a/src/test/java/org/apache/datasketches/memory/internal/BufferBoundaryCheckTest.java b/src/test/java/org/apache/datasketches/memory/internal/BufferBoundaryCheckTest.java
index 9eb6f75..d45f5f8 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/BufferBoundaryCheckTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/BufferBoundaryCheckTest.java
@@ -19,6 +19,8 @@
 
 package org.apache.datasketches.memory.internal;
 
+import static org.testng.Assert.fail;
+
 import org.apache.datasketches.memory.WritableMemory;
 import org.testng.annotations.Test;
 
@@ -31,7 +33,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getByte(7);
     try {
       writableMemory.getByte(8);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -42,7 +44,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putByte(7, (byte) 1);
     try {
       writableMemory.putByte(8, (byte) 1);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -53,7 +55,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getChar(6);
     try {
       writableMemory.getChar(7);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -64,7 +66,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putChar(6, 'a');
     try {
       writableMemory.putChar(7, 'a');
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -75,7 +77,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getShort(6);
     try {
       writableMemory.getShort(7);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -86,7 +88,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putShort(6, (short) 1);
     try {
       writableMemory.putShort(7, (short) 1);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -97,7 +99,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getInt(4);
     try {
       writableMemory.getInt(5);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -108,7 +110,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putInt(4, 1);
     try {
       writableMemory.putInt(5, 1);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -119,7 +121,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getFloat(4);
     try {
       writableMemory.getFloat(5);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -130,7 +132,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putFloat(4, 1f);
     try {
       writableMemory.putFloat(5, 1f);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -141,7 +143,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getLong(0);
     try {
       writableMemory.getLong(1);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -152,7 +154,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putLong(0, 1L);
     try {
       writableMemory.putLong(1, 1L);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -163,7 +165,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.getDouble(0);
     try {
       writableMemory.getDouble(1);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
@@ -174,7 +176,7 @@ public class BufferBoundaryCheckTest {
     writableMemory.putDouble(0, 1d);
     try {
       writableMemory.putDouble(1, 1d);
-      throw new RuntimeException("Expected IndexOutOfBoundsException");
+      fail("Expected IndexOutOfBoundsException");
     } catch (final IndexOutOfBoundsException expected) {
       // ignore
     }
diff --git a/src/test/java/org/apache/datasketches/memory/internal/LeafImplTest.java b/src/test/java/org/apache/datasketches/memory/internal/LeafImplTest.java
index 4b2c71a..6c60379 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/LeafImplTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/LeafImplTest.java
@@ -117,16 +117,12 @@ public class LeafImplTest {
   }
 
   @Test
-  public void checkMapLeafs() throws Exception {
+  public void checkMapLeafs() throws IOException {
     long off = 0;
     long cap = 128;
     File file = new File("TestFile2.bin");
     if (file.exists()) {
-      try {
-        java.nio.file.Files.delete(file.toPath());
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
+      java.nio.file.Files.delete(file.toPath());
     }
     assertTrue(file.createNewFile());
     assertTrue(file.setWritable(true, false)); //writable=true, ownerOnly=false
diff --git a/src/test/java/org/apache/datasketches/memory/internal/MemoryTest.java b/src/test/java/org/apache/datasketches/memory/internal/MemoryTest.java
index 85dead1..533b162 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/MemoryTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/MemoryTest.java
@@ -29,6 +29,7 @@ import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.util.List;
@@ -51,7 +52,7 @@ public class MemoryTest {
 
 
   @BeforeClass
-  public void setReadOnly() {
+  public void setReadOnly() throws IOException {
     UtilTest.setGettysburgAddressFileToReadOnly();
   }
 
diff --git a/src/test/java/org/apache/datasketches/memory/internal/SpecificLeafTest.java b/src/test/java/org/apache/datasketches/memory/internal/SpecificLeafTest.java
index 7f81a64..4401e01 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/SpecificLeafTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/SpecificLeafTest.java
@@ -101,14 +101,10 @@ public class SpecificLeafTest {
   }
 
   @Test
-  public void checkMapLeafs() throws Exception {
+  public void checkMapLeafs() throws IOException {
     File file = new File("TestFile2.bin");
     if (file.exists()) {
-      try {
-        java.nio.file.Files.delete(file.toPath());
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
+      java.nio.file.Files.delete(file.toPath());
     }
     assertTrue(file.createNewFile());
     assertTrue(file.setWritable(true, false)); //writable=true, ownerOnly=false
diff --git a/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java b/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
index 2b6004a..2e1c57f 100644
--- a/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
+++ b/src/test/java/org/apache/datasketches/memory/internal/UtilTest.java
@@ -41,8 +41,7 @@ public class UtilTest {
   private static final String LS = System.getProperty("line.separator");
 
 
-  static final String getFileAttributes(File file) {
-    try {
+  static final String getFileAttributes(File file) throws IOException {
     PosixFileAttributes attrs = Files.getFileAttributeView(
         file.toPath(), PosixFileAttributeView.class, new LinkOption[0]).readAttributes();
     String s = String.format("%s: %s %s %s%n",
@@ -51,18 +50,11 @@ public class UtilTest {
         attrs.group().getName(),
         PosixFilePermissions.toString(attrs.permissions()));
     return s;
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
   }
 
-  static final void setGettysburgAddressFileToReadOnly() {
+  static final void setGettysburgAddressFileToReadOnly() throws IOException {
     File file = getResourceFile("GettysburgAddress.txt");
-    try {
     Files.setPosixFilePermissions(file.toPath(), PosixFilePermissions.fromString("r--r--r--"));
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
   }
 
   //Resources
diff --git a/tools/FindBugsExcludeFilter.xml b/tools/FindBugsExcludeFilter.xml
index ae68389..a89485c 100644
--- a/tools/FindBugsExcludeFilter.xml
+++ b/tools/FindBugsExcludeFilter.xml
@@ -36,6 +36,16 @@ under the License.
     <Class name="~.*\.*Test" />
   </Match>
   
+  <Match>   <!-- Exclude for test classes; too many False Positives. -->
+    <Bug pattern="THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION" />
+    <Class name="~.*\.*Test" />
+  </Match>
+
+  <Match>   <!-- Exclude for test classes; too many False Positives. -->
+    <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
+    <Class name="~.*\.*Test" />
+  </Match>
+
 </FindBugsFilter>
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org