diff --git a/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java b/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java index 2b25120dd4..eaaf3dea06 100644 --- a/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java +++ b/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java @@ -40,8 +40,8 @@ public class AsyncEchoClient { } } - public String sendMessage(String message) throws ExecutionException, InterruptedException { - byte[] byteMsg = new String(message).getBytes(); + public String sendMessage(String message) throws Exception { + byte[] byteMsg = message.getBytes(); ByteBuffer buffer = ByteBuffer.wrap(byteMsg); Future writeResult = client.write(buffer); @@ -65,7 +65,7 @@ public class AsyncEchoClient { } } - public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { + public static void main(String[] args) throws Exception { AsyncEchoClient client = AsyncEchoClient.getInstance(); client.start(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); diff --git a/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoTest.java b/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoTest.java index 475c91095e..93cb3e1eb6 100644 --- a/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoTest.java +++ b/core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoTest.java @@ -1,14 +1,13 @@ package com.baeldung.java.nio2.async; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + public class AsyncEchoTest { Process server; @@ -21,7 +20,7 @@ public class AsyncEchoTest { } @Test - public void givenServerClient_whenServerEchosMessage_thenCorrect() throws ExecutionException, InterruptedException { + public void givenServerClient_whenServerEchosMessage_thenCorrect() throws Exception { String resp1 = client.sendMessage("hello"); String resp2 = client.sendMessage("world"); assertEquals("hello", resp1);