-
Sub-task
-
Resolution: Won't Do
-
Major
-
None
-
None
-
None
-
None
In this example:
FunctionalMap.ReadOnlyMap<String, String> readOnlyMap = CreateFunctionalMaps.ro(); FunctionalMap.WriteOnlyMap<String, String> writeOnlyMap = CreateFunctionalMaps.wo(); FunctionalMap.ReadWriteMap<String, String> readWriteMap = CreateFunctionalMaps.rw(); // `written` is a ReadEntryView of the written entry try(AutoCloseable handler = writeOnlyMap.listeners().onWrite(written -> System.out.printf("Written (via onWrite): %s%n", written.get()))) { Map<String, String> entries = new HashMap<>(); entries.put("key1", "value1"); entries.put("key2", "value2"); writeOnlyMap.evalMany(entries, (v, writeView) -> writeView.set(v)) .get(); // Wait for completable future } AutoCloseable writeCloseHandler = writeOnlyMap.listeners().add(new WriteListener<String, String>() { @Override public void onWrite(ReadEntryView<String, String> written) { System.out.printf("Written (via add): %s%n", written.get()); } }); CompletableFuture<Void> f0 = writeOnlyMap.eval("key1", view -> view.set("new-value1")); CompletableFuture<Void> f1 = f0.thenAccept(ignore -> writeOnlyMap.eval("key2", view -> view.set("new-value2"))); CompletableFuture<Void> f2 = f1.thenAccept(ignore -> { try { writeCloseHandler.close(); } catch (Exception e) { e.printStackTrace(); // TODO: Customise this generated block } }); f2.get(); // Wait for completable future
The output is:
Written (via onWrite): value1
Written (via onWrite): value2
Written (via add): new-value1
Even though the listener is closed after the 2nd new value has been modified, it seems like the close might get ahead somehow.
- is related to
-
ISPN-5848 WriteOnlyMap.evalAll and eval remove do not produce listener events
- Resolved