Merge pull request #13812 from ulisseslima/bael-322-quickfix_echo-server

BAEL-322 - quick fix - echo server loop
This commit is contained in:
Loredana Crusoveanu
2023-04-11 14:31:59 +03:00
committed by GitHub

View File

@@ -45,8 +45,9 @@ public class EchoServer {
private static void answerWithEcho(ByteBuffer buffer, SelectionKey key) throws IOException {
SocketChannel client = (SocketChannel) key.channel();
client.read(buffer);
if (new String(buffer.array()).trim().equals(POISON_PILL)) {
int r = client.read(buffer);
if (r == -1 || new String(buffer.array()).trim()
.equals(POISON_PILL)) {
client.close();
System.out.println("Not accepting client messages anymore");
} else {