From ccecca6b5c33fe93585786ce05ae72805fb18acd Mon Sep 17 00:00:00 2001 From: offthewall123 Date: Fri, 7 Aug 2020 19:51:43 -0700 Subject: [PATCH] ARROW-9536: [Java] Miss parameters in PlasmaOutOfMemoryException.java Miss parameters in PlasmaOutOfMemoryException.java Closes #7815 from offthewall123/miss_parameter_bug_fix Authored-by: offthewall123 Signed-off-by: Micah Kornfield --- .../exceptions/PlasmaOutOfMemoryException.java | 8 ++++++++ .../apache/arrow/plasma/PlasmaClientTest.java | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/java/plasma/src/main/java/org/apache/arrow/plasma/exceptions/PlasmaOutOfMemoryException.java b/java/plasma/src/main/java/org/apache/arrow/plasma/exceptions/PlasmaOutOfMemoryException.java index fd323fa70c99f..ffc4177ebbe30 100644 --- a/java/plasma/src/main/java/org/apache/arrow/plasma/exceptions/PlasmaOutOfMemoryException.java +++ b/java/plasma/src/main/java/org/apache/arrow/plasma/exceptions/PlasmaOutOfMemoryException.java @@ -22,6 +22,14 @@ */ public class PlasmaOutOfMemoryException extends RuntimeException { + public PlasmaOutOfMemoryException(String message) { + super("The plasma store ran out of memory." + message); + } + + public PlasmaOutOfMemoryException(String message, Throwable t) { + super("The plasma store ran out of memory." + message, t); + } + public PlasmaOutOfMemoryException() { super("The plasma store ran out of memory."); } diff --git a/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java b/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java index d3aebea43c47c..e02ee51f9ed0e 100644 --- a/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java +++ b/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java @@ -26,6 +26,7 @@ import org.apache.arrow.plasma.exceptions.DuplicateObjectException; import org.apache.arrow.plasma.exceptions.PlasmaClientException; +import org.apache.arrow.plasma.exceptions.PlasmaOutOfMemoryException; import org.junit.Assert; public class PlasmaClientTest { @@ -277,6 +278,20 @@ public void doByteBufferTest() { client.release(id); } + public void doPlasmaOutOfMemoryExceptionTest() { + System.out.println("Start PlasmaOutOfMemoryException test."); + PlasmaClient client = (PlasmaClient) pLink; + byte[] objectId = new byte[20]; + Arrays.fill(objectId, (byte) 1); + try { + ByteBuffer byteBuffer = client.create(objectId, 200000000, null); + Assert.fail("Fail to create an object, The plasma store ran out of memory."); + } catch (PlasmaOutOfMemoryException e) { + System.out.println(String.format("Expected PlasmaOutOfMemoryException: %s", e)); + System.out.println("PlasmaOutOfMemoryException test success."); + } + } + private byte[] getArrayFilledWithValue(int arrayLength, byte val) { byte[] arr = new byte[arrayLength]; Arrays.fill(arr, val); @@ -290,9 +305,9 @@ public String getStoreAddress() { public static void main(String[] args) throws Exception { PlasmaClientTest plasmaClientTest = new PlasmaClientTest(); + plasmaClientTest.doPlasmaOutOfMemoryExceptionTest(); plasmaClientTest.doByteBufferTest(); plasmaClientTest.doTest(); - } }