Adjust testsuite to pass on JDK15+ (#10511)

Motivation:

JDK15 is about to be released as GA, we should ensure netty works and builds on it. SSLSession#getPeerCertificateChain() throws UnsupportedOperationException in JDK15 and later as it was deprecated before and people should use SSLSession#getPeerCertificates(). We need to account for that in our tests

Modifications:

- Catch UnsupportedOperationException in our testsuite and ignore it when on JDK15+ while rethrowing it otherwise.

Result:

Testsuite passes on JDK15+
This commit is contained in:
Norman Maurer 2020-08-31 09:05:02 +02:00 committed by GitHub
parent 82fa2d780a
commit bc344617b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ import io.netty.handler.ssl.SslHandler;
import io.netty.handler.ssl.SslHandshakeCompletionEvent;
import io.netty.handler.ssl.SslProvider;
import io.netty.handler.ssl.util.SelfSignedCertificate;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import org.junit.Test;
@ -253,6 +254,12 @@ public class SocketSslGreetingTest extends AbstractSocketTest {
fail();
} catch (SSLPeerUnverifiedException e) {
// expected
} catch (UnsupportedOperationException e) {
// Starting from Java15 this method throws UnsupportedOperationException as it was
// deprecated before and getPeerCertificates() should be used
if (PlatformDependent.javaVersion() < 15) {
throw e;
}
}
try {
session.getPeerPrincipal();