Skip to content

Commit

Permalink
8299487: Test java/net/httpclient/whitebox/SSLTubeTestDriver.java tim…
Browse files Browse the repository at this point in the history
…ed out

Backport-of: 81083a0e10d9c92f5247ae256e170709014b596b
  • Loading branch information
Andrew Lu committed Jun 24, 2024
1 parent 717e389 commit b0607ee
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -85,16 +85,17 @@ private static class SSLLoopbackSubscriber implements FlowTube {
ExecutorService exec,
CountDownLatch allBytesReceived) throws IOException {
SSLServerSocketFactory fac = ctx.getServerSocketFactory();
InetAddress loopback = InetAddress.getLoopbackAddress();
SSLServerSocket serv = (SSLServerSocket) fac.createServerSocket();
serv.setReuseAddress(false);
serv.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
serv.bind(new InetSocketAddress(loopback, 0));
SSLParameters params = serv.getSSLParameters();
params.setApplicationProtocols(new String[]{"proto2"});
serv.setSSLParameters(params);


int serverPort = serv.getLocalPort();
clientSock = new Socket("localhost", serverPort);
clientSock = new Socket(loopback, serverPort);
serverSock = (SSLSocket) serv.accept();
this.buffer = new LinkedBlockingQueue<>();
this.allBytesReceived = allBytesReceived;
Expand All @@ -107,6 +108,7 @@ private static class SSLLoopbackSubscriber implements FlowTube {
}

public void start() {
System.out.println("Starting: server listening at: " + serverSock.getLocalSocketAddress());
thread1.start();
thread2.start();
thread3.start();
Expand Down Expand Up @@ -144,6 +146,7 @@ private void clientReader() {
publisher.submit(List.of(bb));
}
} catch (Throwable e) {
System.out.println("clientReader got exception: " + e);
e.printStackTrace();
Utils.close(clientSock);
}
Expand Down Expand Up @@ -176,6 +179,7 @@ private void clientWriter() {
clientSubscription.request(1);
}
} catch (Throwable e) {
System.out.println("clientWriter got exception: " + e);
e.printStackTrace();
}
}
Expand Down Expand Up @@ -212,14 +216,18 @@ private void serverLoopback() {
is.close();
os.close();
serverSock.close();
System.out.println("serverLoopback exiting normally");
return;
}
os.write(bb, 0, n);
os.flush();
loopCount.addAndGet(n);
}
} catch (Throwable e) {
System.out.println("serverLoopback got exception: " + e);
e.printStackTrace();
} finally {
System.out.println("serverLoopback exiting at count: " + loopCount.get());
}
}

Expand Down

1 comment on commit b0607ee

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.