Update testsuite / pom.xml to be able to build with Java15 (#10210)
Motivation: We need to make some slightly changes to be able to build on Java15 as some previous deprecated methods now throw UnsupportedOperationException Modifications: - Add code to handle UnsupportedOperationException - Revert previous applied workaround for bug that was fixed in Java15 - Add maven profile Result: Be able to build with latest Java15 EA release
This commit is contained in:
parent
0c2c7c8f82
commit
411ad9d5b6
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
@ -59,7 +61,10 @@ final class Conscrypt {
|
||||
* Indicates whether or not conscrypt is available on the current system.
|
||||
*/
|
||||
static boolean isAvailable() {
|
||||
return CAN_INSTANCE_PROVIDER && IS_CONSCRYPT_SSLENGINE != null;
|
||||
return CAN_INSTANCE_PROVIDER && IS_CONSCRYPT_SSLENGINE != null &&
|
||||
// Only works on Java14 and earlier for now
|
||||
// See https://github.com/google/conscrypt/issues/838
|
||||
(PlatformDependent.javaVersion() < 15 || PlatformDependent.isAndroid());
|
||||
}
|
||||
|
||||
static boolean isEngineSupported(SSLEngine engine) {
|
||||
|
@ -1015,8 +1015,13 @@ public abstract class SSLEngineTest {
|
||||
assertEquals(1, session.getPeerCertificates().length);
|
||||
assertArrayEquals(certBytes, session.getPeerCertificates()[0].getEncoded());
|
||||
|
||||
try {
|
||||
assertEquals(1, session.getPeerCertificateChain().length);
|
||||
assertArrayEquals(certBytes, session.getPeerCertificateChain()[0].getEncoded());
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||
}
|
||||
|
||||
assertEquals(1, session.getLocalCertificates().length);
|
||||
assertArrayEquals(certBytes, session.getLocalCertificates()[0].getEncoded());
|
||||
@ -1752,12 +1757,15 @@ public abstract class SSLEngineTest {
|
||||
Throwable cause = ((SslHandshakeCompletionEvent) evt).cause();
|
||||
if (cause == null) {
|
||||
SSLSession session = ((SslHandler) ctx.pipeline().first()).engine().getSession();
|
||||
X509Certificate[] peerCertificateChain = session.getPeerCertificateChain();
|
||||
Certificate[] peerCertificates = session.getPeerCertificates();
|
||||
if (peerCertificates == null) {
|
||||
promise.setFailure(new NullPointerException("peerCertificates"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
X509Certificate[] peerCertificateChain = session.getPeerCertificateChain();
|
||||
if (peerCertificateChain == null) {
|
||||
promise.setFailure(new NullPointerException("peerCertificateChain"));
|
||||
} else if (peerCertificates == null) {
|
||||
promise.setFailure(new NullPointerException("peerCertificates"));
|
||||
} else if (peerCertificateChain.length + peerCertificates.length != 4) {
|
||||
String excTxtFmt = "peerCertificateChain.length:%s, peerCertificates.length:%s";
|
||||
promise.setFailure(new IllegalStateException(String.format(excTxtFmt,
|
||||
@ -1773,6 +1781,19 @@ public abstract class SSLEngineTest {
|
||||
}
|
||||
promise.setSuccess(null);
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||
assertEquals(2, peerCertificates.length);
|
||||
for (int i = 0; i < peerCertificates.length; i++) {
|
||||
if (peerCertificates[i] == null) {
|
||||
promise.setFailure(
|
||||
new IllegalStateException("Certificate in chain is null"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
promise.setSuccess(null);
|
||||
}
|
||||
} else {
|
||||
promise.setFailure(cause);
|
||||
}
|
||||
@ -2993,7 +3014,7 @@ public abstract class SSLEngineTest {
|
||||
|
||||
// Workaround for JDK 14 regression.
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8242008
|
||||
if (PlatformDependent.javaVersion() < 14) {
|
||||
if (PlatformDependent.javaVersion() != 14) {
|
||||
assertNotNull(serverSession.getSessionContext());
|
||||
}
|
||||
|
||||
@ -3028,9 +3049,15 @@ public abstract class SSLEngineTest {
|
||||
assertEquals(1, serverPeerCertificates.length);
|
||||
assertArrayEquals(clientLocalCertificates[0].getEncoded(), serverPeerCertificates[0].getEncoded());
|
||||
|
||||
try {
|
||||
X509Certificate[] serverPeerX509Certificates = serverSession.getPeerCertificateChain();
|
||||
assertEquals(1, serverPeerX509Certificates.length);
|
||||
assertArrayEquals(clientLocalCertificates[0].getEncoded(), serverPeerX509Certificates[0].getEncoded());
|
||||
assertArrayEquals(clientLocalCertificates[0].getEncoded(),
|
||||
serverPeerX509Certificates[0].getEncoded());
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||
}
|
||||
|
||||
Principal clientLocalPrincipial = clientSession.getLocalPrincipal();
|
||||
assertNotNull(clientLocalPrincipial);
|
||||
@ -3053,6 +3080,9 @@ public abstract class SSLEngineTest {
|
||||
fail();
|
||||
} catch (SSLPeerUnverifiedException expected) {
|
||||
// As we did not use mutual auth this is expected
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -3067,10 +3097,14 @@ public abstract class SSLEngineTest {
|
||||
assertEquals(1, clientPeerCertificates.length);
|
||||
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerCertificates[0].getEncoded());
|
||||
|
||||
try {
|
||||
X509Certificate[] clientPeerX509Certificates = clientSession.getPeerCertificateChain();
|
||||
assertEquals(1, clientPeerX509Certificates.length);
|
||||
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerX509Certificates[0].getEncoded());
|
||||
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||
}
|
||||
Principal clientPeerPrincipal = clientSession.getPeerPrincipal();
|
||||
assertEquals(serverLocalPrincipal, clientPeerPrincipal);
|
||||
} finally {
|
||||
|
20
pom.xml
20
pom.xml
@ -98,6 +98,26 @@
|
||||
</properties>
|
||||
</profile>
|
||||
<!-- JDK14 -->
|
||||
<profile>
|
||||
<id>java15</id>
|
||||
<activation>
|
||||
<jdk>15</jdk>
|
||||
</activation>
|
||||
<properties>
|
||||
<!-- Not use alpn agent as Java11+ supports alpn out of the box -->
|
||||
<argLine.alpnAgent />
|
||||
<forbiddenapis.skip>true</forbiddenapis.skip>
|
||||
<!-- Needed because of https://issues.apache.org/jira/browse/MENFORCER-275 -->
|
||||
<enforcer.plugin.version>3.0.0-M3</enforcer.plugin.version>
|
||||
<!-- 1.4.x does not work in Java10+ -->
|
||||
<jboss.marshalling.version>2.0.5.Final</jboss.marshalling.version>
|
||||
<!-- This is the minimum supported by Java12+ -->
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<!-- pax-exam does not work on latest Java12 EA 22 build -->
|
||||
<skipOsgiTestsuite>true</skipOsgiTestsuite>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java14</id>
|
||||
<activation>
|
||||
|
Loading…
Reference in New Issue
Block a user