### Question:
SslFilter extends Filter { @Override synchronized void write(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler) { switch (state) { case NOT_STARTED: { writeQueue.write(applicationData, completionHandler); return; } case HANDSHAKING: { completionHandler.failed(new IllegalStateException("Cannot write until SSL handshake has been completed")); break; } case REHANDSHAKING: { storePendingApplicationWrite(applicationData, completionHandler); break; } case DATA: { handleWrite(applicationData, completionHandler); break; } case CLOSED: { completionHandler.failed(new IllegalStateException("SSL session has been closed")); break; } } } SslFilter(Filter downstreamFilter, SslEngineConfigurator sslEngineConfigurator, String serverHost);   SslFilter(Filter downstreamFilter,
              org.glassfish.tyrus.container.jdk.client.SslEngineConfigurator sslEngineConfigurator);   }### Answer:
@Test public void testCloseServer() throws Throwable { CountDownLatch latch = new CountDownLatch(1); SslEchoServer server = new SslEchoServer(); try { server.start(); String message = "Hello world\n"; ByteBuffer readBuffer = ByteBuffer.allocate(message.length()); Filter clientSocket = openClientSocket("localhost", readBuffer, latch, null); clientSocket.write(stringToBuffer(message), new CompletionHandler<ByteBuffer>() { @Override public void failed(Throwable t) { t.printStackTrace(); } }); assertTrue(latch.await(5, TimeUnit.SECONDS)); server.stop(); readBuffer.flip(); String received = bufferToString(readBuffer); assertEquals(message, received); } finally { server.stop(); } }