java-client-api
java-client-api copied to clipboard
UnsupportedOperationException thrown from SSLTest when run on openJDK 11 JVM
Version of MarkLogic Java Client API
develop
Version of MarkLogic Server
9.0 nightly build
Java version
openJDK 11
OS and version
Linux
Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end
Run SSLTest using gradle / gradlew command. (Requires gradle 4.10 version on open JDK 11)
Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.marklogic.client.test.SSLTest" tests="2" skipped="0" failures="1" errors="0" timestamp="2018-11-15T17:59:16" hostname="engrlab-129-025.engrlab.marklogic.com" time="0.201">
<properties/>
<testcase name="testHostnameVerifier" classname="com.marklogic.client.test.SSLTest" time="0.198"/>
<testcase name="testSSLAuth" classname="com.marklogic.client.test.SSLTest" time="0.002">
<failure message="java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+" type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+
at okhttp3.internal.platform.Jdk9Platform.trustManager(Jdk9Platform.java:81)
at okhttp3.internal.platform.Platform.buildCertificateChainCleaner(Platform.java:176)
at okhttp3.OkHttpClient$Builder.sslSocketFactory(OkHttpClient.java:673)
at com.marklogic.client.impl.OkHttpServices.connect(OkHttpServices.java:332)
at com.marklogic.client.impl.OkHttpServices.connect(OkHttpServices.java:270)
at com.marklogic.client.DatabaseClientFactory.newClient(DatabaseClientFactory.java:1082)
at com.marklogic.client.DatabaseClientFactory.newClient(DatabaseClientFactory.java:963)
at com.marklogic.client.test.SSLTest.testSSLAuth(SSLTest.java:56)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at jdk.internal.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117)
at jdk.internal.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.base/java.lang.Thread.run(Thread.java:834)
</failure>
</testcase>
<system-out><![CDATA[09:59:16.780 [Test worker] DEBUG c.m.client.impl.OkHttpServices - Connecting to localhost at 8012 as rest-writer
]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
Expected output: What specifically did you expect to happen?
Test runs fine.
Alternatives: What else have you tried, actual/expected?
N/A
The root issue is that OkHttpClient.Builder.sslSocketFactory() is deprecated in Java 8 and throws a runtime exception in Java 9 because a X509TrustManager is required.
At the next backward incompatibility boundary for the Java API, we should also require a X509TrustManager
In the interim, OKHttpClient attempts to default the trust manager. The situations under which that will work is not clear. The workaround where it fails is the same as the long term solution: the application should provide a X509TrustManager
Can you please port into develop branch?
@georgeajit , commit c13902c862d5285bfcac8524621fcb61d166a03c appears to be in the commit log for the develop branch.
I also notice that GitHub associates it with the 4.2.0 tag.
Finally, it looks like OKHttpServices still has the important part of the fix:
https://github.com/marklogic/java-client-api/commit/c13902c862d5285bfcac8524621fcb61d166a03c#diff-7687ae7e0b984785b9b12f30a4a582abR339
Are you seeing that the fix is not working?