Skip to content

MLE-23032 Testing out OkHttp 5 on Java 17 #1797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
@Library('shared-libraries') _

def getJava(){
if(env.JAVA_VERSION=="JAVA17"){
return "/home/builder/java/jdk-17.0.2"
}else if(env.JAVA_VERSION=="JAVA11"){
return "/home/builder/java/jdk-11.0.2"
}else if(env.JAVA_VERSION=="JAVA21"){
if (env.JAVA_VERSION == "JAVA21") {
return "/home/builder/java/jdk-21.0.1"
}else{
return "/home/builder/java/openjdk-1.8.0-262"
} else {
return "/home/builder/java/jdk-17.0.2"
}
}

Expand Down
60 changes: 30 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,49 @@
// used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties
// plugin via subprojects below.
buildscript {
repositories {
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.saliman:gradle-properties-plugin:1.5.2"
}
repositories {
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.saliman:gradle-properties-plugin:1.5.2"
}
}

subprojects {
apply plugin: "net.saliman.properties"
apply plugin: 'java'
apply plugin: "net.saliman.properties"
apply plugin: 'java'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
java {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations {
testImplementation.extendsFrom compileOnly
}
configurations {
testImplementation.extendsFrom compileOnly
}

repositories {
mavenLocal()
mavenCentral()
}
repositories {
mavenLocal()
mavenCentral()
}

test {
systemProperty "file.encoding", "UTF-8"
systemProperty "javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"
}

// Until we do a cleanup of javadoc errors, the build (and specifically the javadoc task) fails on Java 11
// and higher. Preventing that until the cleanup can occur.
javadoc.failOnError = false
// and higher. Preventing that until the cleanup can occur.
javadoc.failOnError = false

// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
// Until then, it's just a lot of noise.
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
// Until then, it's just a lot of noise.
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}
4 changes: 2 additions & 2 deletions marklogic-client-api-functionaltests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
testImplementation 'org.slf4j:slf4j-api:2.0.17'
testImplementation 'commons-io:commons-io:2.17.0'
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
testImplementation 'com.squareup.okhttp3:okhttp:5.1.0'
testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
testImplementation "org.jdom:jdom2:2.0.6.1"
Expand All @@ -32,7 +32,7 @@ dependencies {
exclude module: "commons-lang3"
}

testImplementation 'ch.qos.logback:logback-classic:1.3.15'
testImplementation 'ch.qos.logback:logback-classic:1.5.18'
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testImplementation 'org.xmlunit:xmlunit-legacy:2.10.0'

Expand Down
10 changes: 5 additions & 5 deletions marklogic-client-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ dependencies {
api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1"
implementation "org.glassfish.jaxb:jaxb-runtime:3.0.2"

implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'io.github.rburgst:okhttp-digest:2.7'
implementation 'com.squareup.okhttp3:okhttp:5.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
implementation 'io.github.rburgst:okhttp-digest:3.1.1'

// We tried upgrading to the org.eclipse.angus:angus-mail dependency, but we ran into significant performance issues
// with using the Java Client eval call in our Spark connector. Example - an eval() call for getting 50k URIs would
Expand Down Expand Up @@ -57,10 +57,10 @@ dependencies {
// Starting with mockito 5.x, Java 11 is required, so sticking with 4.x as we have to support Java 8.
testImplementation "org.mockito:mockito-core:4.11.0"
testImplementation "org.mockito:mockito-inline:4.11.0"
testImplementation "com.squareup.okhttp3:mockwebserver:4.12.0"
testImplementation "com.squareup.okhttp3:mockwebserver3:5.1.0"

testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}"
testImplementation 'ch.qos.logback:logback-classic:1.3.15'
testImplementation 'ch.qos.logback:logback-classic:1.5.18'

// Using this to avoid a schema validation issue with the regular xercesImpl
testImplementation 'org.opengis.cite.xerces:xercesImpl-xsd11:2.12-beta-r1667115'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
package com.marklogic.client.impl.okhttp;

import com.marklogic.client.DatabaseClientFactory;
import mockwebserver3.MockWebServer;
import okhttp3.Request;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class OAuthAuthenticationConfigurerTest {
class OAuthAuthenticationConfigurerTest {

@Test
void test() {
DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123");
Request request = new Request.Builder().url(new MockWebServer().url("/url-doesnt-matter")).build();
void test() throws Exception {
MockWebServer mockWebServer = new MockWebServer();
mockWebServer.start();
Request request = new Request.Builder().url(mockWebServer.url("/url-doesnt-matter")).build();

DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123");
Request authenticatedRequest = new OAuthAuthenticationConfigurer().makeAuthenticatedRequest(request, authContext);
assertEquals("Bearer abc123", authenticatedRequest.header("Authorization"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package com.marklogic.client.impl.okhttp;

import com.marklogic.client.ext.helper.LoggingObject;
import mockwebserver3.MockResponse;
import mockwebserver3.MockWebServer;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -23,7 +23,7 @@
* Uses OkHttp's MockWebServer to completely mock a MarkLogic instance so that we can control what response codes are
* returned and processed by TokenAuthenticationInterceptor.
*/
public class TokenAuthenticationInterceptorTest extends LoggingObject {
class TokenAuthenticationInterceptorTest extends LoggingObject {

private MockWebServer mockWebServer;
private FakeTokenGenerator fakeTokenGenerator;
Expand Down Expand Up @@ -110,7 +110,12 @@ void multipleThreads() throws Exception {
*/
private void enqueueResponseCodes(int... codes) {
for (int code : codes) {
mockWebServer.enqueue(new MockResponse().setResponseCode(code));
mockWebServer.enqueue(new MockResponse.Builder().code(code).build());
}
try {
mockWebServer.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ml-development-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ publishing {
}

compileKotlin {
kotlinOptions.jvmTarget = '1.8'
kotlinOptions.jvmTarget = '17'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
kotlinOptions.jvmTarget = '17'
}

tasks.register("generateTests", JavaExec) {
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
// Allows for downloading a JDK based on Gradle toolchain configuration.
// Using a version prior to 1.0, which requires Java 17, and Jenkins is using Java 8.
id "org.gradle.toolchains.foojay-resolver-convention" version "0.10.0"
}

rootProject.name = 'marklogic-client-api-parent'
include ':marklogic-client-api'
include ':marklogic-client-api-functionaltests'
Expand Down