Navigation Menu

Skip to content

Commit

Permalink
8262409: sun/security/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExcep…
Browse files Browse the repository at this point in the history
…tions. SSL test failures caused by java failed with "Server reported the wrong exception"

Reviewed-by: stuefe
Backport-of: 3aa7062
  • Loading branch information
RealCLanger committed Jul 1, 2021
1 parent 65fe466 commit aa79d2b
Showing 1 changed file with 11 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 @@ -35,8 +35,8 @@
* @author Brad Wetmore
*/

import java.io.*;
import java.net.*;
import java.net.SocketException;
import java.util.concurrent.CountDownLatch;
import javax.net.ssl.*;

public class SSLSocketImplThrowsWrongExceptions {
Expand Down Expand Up @@ -64,7 +64,7 @@ public class SSLSocketImplThrowsWrongExceptions {
/*
* Is the server ready to serve?
*/
volatile static boolean serverReady = false;
private CountDownLatch serverReadyLatch = new CountDownLatch(1);

/*
* Turn on SSL debugging?
Expand All @@ -87,20 +87,20 @@ void doServerSide() throws Exception {
/*
* Signal Client, we're ready for his connect.
*/
serverReady = true;
serverReadyLatch.countDown();

try {
System.out.println("Server socket accepting...");
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
System.out.println("Server starting handshake");
sslSocket.startHandshake();
throw new Exception("Handshake was successful");
} catch (SSLException e) {
} catch (SSLException | SocketException se){
/*
* Caught the right Exeption. Swallow it.
* Caught the right Exception. Swallow it.
*/
System.out.println("Server reported the right exception");
System.out.println(e.toString());
System.out.println(se);
} catch (Exception e) {
/*
* Caught the wrong exception. Rethrow it.
Expand All @@ -121,9 +121,7 @@ void doClientSide() throws Exception {
/*
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
serverReadyLatch.await();

SSLSocketFactory sslsf =
(SSLSocketFactory) SSLSocketFactory.getDefault();
Expand Down Expand Up @@ -271,7 +269,7 @@ public void run() {
* Release the client, if not active already...
*/
System.err.println("Server died...");
serverReady = true;
serverReadyLatch.countDown();
serverException = e;
}
}
Expand All @@ -283,7 +281,7 @@ public void run() {
} catch (Exception e) {
serverException = e;
} finally {
serverReady = true;
serverReadyLatch.countDown();
}
}
}
Expand Down

1 comment on commit aa79d2b

@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.