From ef155546873fb0e40a7c6ba4190ac13d733a456a Mon Sep 17 00:00:00 2001 From: Strongest Number 9 <16169054+StrongestNumber9@users.noreply.github.com> Date: Wed, 15 May 2024 11:03:57 +0300 Subject: [PATCH] Readme fix (#170) * Fixes readme to provide new framedelegates * Fixes back to non-lambda form --- README.adoc | 20 +++---------------- .../rlp_03/readme/ReadmeDeferredTest.java | 20 +++---------------- .../teragrep/rlp_03/readme/ReadmeTest.java | 20 +++---------------- 3 files changed, 9 insertions(+), 51 deletions(-) diff --git a/README.adoc b/README.adoc index 697f4a04..8e05d3df 100644 --- a/README.adoc +++ b/README.adoc @@ -107,19 +107,13 @@ public class ReadmeTest { }; /* - * DefaultFrameDelegate accepts Consumer for processing syslog frames - */ - DefaultFrameDelegate frameDelegate = new DefaultFrameDelegate(syslogConsumer); - - /* - * Same instance of the frameDelegate is shared with every connection + * New instance of the frameDelegate is provided for every connection */ Supplier frameDelegateSupplier = new Supplier() { - @Override public FrameDelegate get() { System.out.println("Providing frameDelegate for a connection"); - return frameDelegate; + return new DefaultFrameDelegate(syslogConsumer); } }; @@ -163,6 +157,7 @@ public class ReadmeTest { * Send Hello, World! via rlp_01 */ new ExampleRelpClient(listenPort).send("Hello, World!"); + new ExampleRelpClient(listenPort).send("Hello, World again!"); /* * Stop eventLoop @@ -180,15 +175,6 @@ public class ReadmeTest { } System.out.println("server stopped at port <" + listenPort + ">"); - /* - * Close the frameDelegate - */ - try { - frameDelegate.close(); - } - catch (Exception e) { - throw new RuntimeException(e); - } executorService.shutdown(); } } diff --git a/src/test/java/com/teragrep/rlp_03/readme/ReadmeDeferredTest.java b/src/test/java/com/teragrep/rlp_03/readme/ReadmeDeferredTest.java index 2f5d42dd..9aa62656 100644 --- a/src/test/java/com/teragrep/rlp_03/readme/ReadmeDeferredTest.java +++ b/src/test/java/com/teragrep/rlp_03/readme/ReadmeDeferredTest.java @@ -112,16 +112,11 @@ public void close() { relpCommandConsumerMap.put(RelpCommand.SYSLOG, syslogRelpEvent); /* - * Register the commands to the DefaultFrameDelegate - */ - FrameDelegate frameDelegate = new DefaultFrameDelegate(relpCommandConsumerMap); - - /* - * Same instance of the frameDelegate is shared with every connection, BlockingQueues are thread-safe + * New instance of the frameDelegate is provided for every connection */ Supplier frameDelegateSupplier = () -> { System.out.println("Providing frameDelegate for a connection"); - return frameDelegate; + return new DefaultFrameDelegate(relpCommandConsumerMap); }; /* @@ -171,6 +166,7 @@ public void close() { * Send Hello, World! via rlp_01 */ new ExampleRelpClient(listenPort).send("Hello, Deferred World!"); + new ExampleRelpClient(listenPort).send("Hello, Deferred World again!"); /* * Stop eventLoop @@ -188,16 +184,6 @@ public void close() { throw new RuntimeException(interruptedException); } - /* - * Close the frameDelegate - */ - try { - frameDelegate.close(); - } - catch (Exception e) { - throw new RuntimeException(e); - } - /* * Stop the deferred processing thread */ diff --git a/src/test/java/com/teragrep/rlp_03/readme/ReadmeTest.java b/src/test/java/com/teragrep/rlp_03/readme/ReadmeTest.java index b7c1719e..421d9ea5 100644 --- a/src/test/java/com/teragrep/rlp_03/readme/ReadmeTest.java +++ b/src/test/java/com/teragrep/rlp_03/readme/ReadmeTest.java @@ -85,19 +85,13 @@ public synchronized void accept(FrameContext frameContext) { }; /* - * DefaultFrameDelegate accepts Consumer for processing syslog frames - */ - DefaultFrameDelegate frameDelegate = new DefaultFrameDelegate(syslogConsumer); - - /* - * Same instance of the frameDelegate is shared with every connection + * New instance of the frameDelegate is provided for every connection */ Supplier frameDelegateSupplier = new Supplier() { - @Override public FrameDelegate get() { System.out.println("Providing frameDelegate for a connection"); - return frameDelegate; + return new DefaultFrameDelegate(syslogConsumer); } }; @@ -141,6 +135,7 @@ public FrameDelegate get() { * Send Hello, World! via rlp_01 */ new ExampleRelpClient(listenPort).send("Hello, World!"); + new ExampleRelpClient(listenPort).send("Hello, World again!"); /* * Stop eventLoop @@ -158,15 +153,6 @@ public FrameDelegate get() { } System.out.println("server stopped at port <" + listenPort + ">"); - /* - * Close the frameDelegate - */ - try { - frameDelegate.close(); - } - catch (Exception e) { - throw new RuntimeException(e); - } executorService.shutdown(); } }