From 728031a972e9b52f3d1eedf030468a7bc4a37ceb Mon Sep 17 00:00:00 2001 From: bibabolynn <1018527906@qq.com> Date: Sat, 9 Feb 2019 18:03:17 +0800 Subject: [PATCH] [java] when put an object in plasma store, ignore "object alreay exists" exception (#3687) * distinct plasma client exception * Update ObjectStoreProxy.java * Update and rename PlasmaArrowTest.java to PlasmaStoreTest.java * store put * Use testng to replace junit to fix test failure --- .../org/ray/api/test/PlasmaStoreTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java diff --git a/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java b/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java new file mode 100644 index 000000000..726bad3da --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java @@ -0,0 +1,27 @@ +package org.ray.api.test; + +import org.apache.arrow.plasma.PlasmaClient; +import org.apache.arrow.plasma.exceptions.DuplicateObjectException; + +import org.ray.api.Ray; +import org.ray.api.id.UniqueId; +import org.ray.runtime.AbstractRayRuntime; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class PlasmaStoreTest extends BaseTest { + + @Test + public void testPutWithDuplicateId() { + UniqueId objectId = UniqueId.randomId(); + AbstractRayRuntime runtime = (AbstractRayRuntime) Ray.internal(); + PlasmaClient store = new PlasmaClient(runtime.getRayConfig().objectStoreSocketName, "", 0); + store.put(objectId.getBytes(), new byte[]{}, new byte[]{}); + try { + store.put(objectId.getBytes(), new byte[]{}, new byte[]{}); + Assert.fail("This line shouldn't be reached."); + } catch (DuplicateObjectException e) { + // Putting 2 objects with duplicate ID should throw DuplicateObjectException. + } + } +}