11/*
2- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -85,16 +85,17 @@ private static class SSLLoopbackSubscriber implements FlowTube {
8585 ExecutorService exec ,
8686 CountDownLatch allBytesReceived ) throws IOException {
8787 SSLServerSocketFactory fac = ctx .getServerSocketFactory ();
88+ InetAddress loopback = InetAddress .getLoopbackAddress ();
8889 SSLServerSocket serv = (SSLServerSocket ) fac .createServerSocket ();
8990 serv .setReuseAddress (false );
90- serv .bind (new InetSocketAddress (InetAddress . getLoopbackAddress () , 0 ));
91+ serv .bind (new InetSocketAddress (loopback , 0 ));
9192 SSLParameters params = serv .getSSLParameters ();
9293 params .setApplicationProtocols (new String []{"proto2" });
9394 serv .setSSLParameters (params );
9495
9596
9697 int serverPort = serv .getLocalPort ();
97- clientSock = new Socket ("localhost" , serverPort );
98+ clientSock = new Socket (loopback , serverPort );
9899 serverSock = (SSLSocket ) serv .accept ();
99100 this .buffer = new LinkedBlockingQueue <>();
100101 this .allBytesReceived = allBytesReceived ;
@@ -107,6 +108,7 @@ private static class SSLLoopbackSubscriber implements FlowTube {
107108 }
108109
109110 public void start () {
111+ System .out .println ("Starting: server listening at: " + serverSock .getLocalSocketAddress ());
110112 thread1 .start ();
111113 thread2 .start ();
112114 thread3 .start ();
@@ -144,6 +146,7 @@ private void clientReader() {
144146 publisher .submit (List .of (bb ));
145147 }
146148 } catch (Throwable e ) {
149+ System .out .println ("clientReader got exception: " + e );
147150 e .printStackTrace ();
148151 Utils .close (clientSock );
149152 }
@@ -176,6 +179,7 @@ private void clientWriter() {
176179 clientSubscription .request (1 );
177180 }
178181 } catch (Throwable e ) {
182+ System .out .println ("clientWriter got exception: " + e );
179183 e .printStackTrace ();
180184 }
181185 }
@@ -212,14 +216,18 @@ private void serverLoopback() {
212216 is .close ();
213217 os .close ();
214218 serverSock .close ();
219+ System .out .println ("serverLoopback exiting normally" );
215220 return ;
216221 }
217222 os .write (bb , 0 , n );
218223 os .flush ();
219224 loopCount .addAndGet (n );
220225 }
221226 } catch (Throwable e ) {
227+ System .out .println ("serverLoopback got exception: " + e );
222228 e .printStackTrace ();
229+ } finally {
230+ System .out .println ("serverLoopback exiting at count: " + loopCount .get ());
223231 }
224232 }
225233
0 commit comments