diff options
author | jonmv <venstad@gmail.com> | 2022-04-29 18:34:47 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-05-02 12:02:02 +0200 |
commit | 9c65dcd179a7b2c0b98b5e6fa3cc4a9a40221478 (patch) | |
tree | 899924feefae26820a6d87a66fb45e7c64fd8fbc /yolean | |
parent | ae4f0388247496f11b6e878ef597e049b6ada246 (diff) |
Update ABI spec
Diffstat (limited to 'yolean')
-rw-r--r-- | yolean/abi-spec.json | 30 | ||||
-rw-r--r-- | yolean/src/test/java/com/yahoo/yolean/concurrent/MemoizedTest.java | 12 |
2 files changed, 42 insertions, 0 deletions
diff --git a/yolean/abi-spec.json b/yolean/abi-spec.json index 6285cc54118..553a8aa61e1 100644 --- a/yolean/abi-spec.json +++ b/yolean/abi-spec.json @@ -234,6 +234,36 @@ ], "fields": [] }, + "com.yahoo.yolean.concurrent.Memoized$Closer": { + "superClass": "java.lang.Object", + "interfaces": [], + "attributes": [ + "public", + "interface", + "abstract" + ], + "methods": [ + "public abstract void close(java.lang.Object)" + ], + "fields": [] + }, + "com.yahoo.yolean.concurrent.Memoized": { + "superClass": "java.lang.Object", + "interfaces": [ + "java.util.function.Supplier", + "java.lang.AutoCloseable" + ], + "attributes": [ + "public" + ], + "methods": [ + "public void <init>(java.util.function.Supplier, com.yahoo.yolean.concurrent.Memoized$Closer)", + "public static com.yahoo.yolean.concurrent.Memoized of(java.util.function.Supplier)", + "public java.lang.Object get()", + "public void close()" + ], + "fields": [] + }, "com.yahoo.yolean.concurrent.ResourceFactory": { "superClass": "java.lang.Object", "interfaces": [], diff --git a/yolean/src/test/java/com/yahoo/yolean/concurrent/MemoizedTest.java b/yolean/src/test/java/com/yahoo/yolean/concurrent/MemoizedTest.java index 5f6268ce7da..7f2f49c75f2 100644 --- a/yolean/src/test/java/com/yahoo/yolean/concurrent/MemoizedTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/concurrent/MemoizedTest.java @@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; import static org.junit.Assert.fail; @@ -66,6 +67,17 @@ public class MemoizedTest { executor.shutdown(); } + @Test + public void closeBeforeFirstGet() throws Exception { + OnceSupplier supplier = new OnceSupplier(); + Memoized<OnceCloseable, ?> lazy = Memoized.of(supplier); + lazy.close(); + assertEquals("already closed", + assertThrows(IllegalStateException.class, lazy::get).getMessage()); + lazy.close(); + assertFalse(supplier.initialized.get()); + } + class OnceSupplier implements Supplier<OnceCloseable> { final AtomicBoolean initialized = new AtomicBoolean(); @Override public OnceCloseable get() { |