Skip to content

Commit 110d075

Browse files
committed
MLE-23032 Testing out OkHttp 5 on Java 17
1 parent fde7049 commit 110d075

File tree

8 files changed

+65
-56
lines changed

8 files changed

+65
-56
lines changed

Jenkinsfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
@Library('shared-libraries') _
22

33
def getJava(){
4-
if(env.JAVA_VERSION=="JAVA17"){
5-
return "/home/builder/java/jdk-17.0.2"
6-
}else if(env.JAVA_VERSION=="JAVA11"){
7-
return "/home/builder/java/jdk-11.0.2"
8-
}else if(env.JAVA_VERSION=="JAVA21"){
4+
if (env.JAVA_VERSION == "JAVA21") {
95
return "/home/builder/java/jdk-21.0.1"
10-
}else{
11-
return "/home/builder/java/openjdk-1.8.0-262"
6+
} else {
7+
return "/home/builder/java/jdk-17.0.2"
128
}
139
}
1410

@@ -153,7 +149,7 @@ pipeline{
153149
}
154150

155151
environment {
156-
JAVA_HOME_DIR= getJava()
152+
JAVA_HOME_DIR= "/home/builder/java/jdk-17.0.2"
157153
GRADLE_DIR =".gradle"
158154
DMC_USER = credentials('MLBUILD_USER')
159155
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')

build.gradle

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@
44
// used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties
55
// plugin via subprojects below.
66
buildscript {
7-
repositories {
8-
maven {
9-
url = "https://plugins.gradle.org/m2/"
10-
}
11-
}
12-
dependencies {
13-
classpath "net.saliman:gradle-properties-plugin:1.5.2"
14-
}
7+
repositories {
8+
maven {
9+
url = "https://plugins.gradle.org/m2/"
10+
}
11+
}
12+
dependencies {
13+
classpath "net.saliman:gradle-properties-plugin:1.5.2"
14+
}
1515
}
1616

1717
subprojects {
18-
apply plugin: "net.saliman.properties"
19-
apply plugin: 'java'
18+
apply plugin: "net.saliman.properties"
19+
apply plugin: 'java'
2020

21-
tasks.withType(JavaCompile) {
22-
options.encoding = 'UTF-8'
23-
}
21+
tasks.withType(JavaCompile) {
22+
options.encoding = 'UTF-8'
23+
}
2424

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

31-
configurations {
32-
testImplementation.extendsFrom compileOnly
33-
}
31+
configurations {
32+
testImplementation.extendsFrom compileOnly
33+
}
3434

35-
repositories {
36-
mavenLocal()
37-
mavenCentral()
38-
}
35+
repositories {
36+
mavenLocal()
37+
mavenCentral()
38+
}
3939

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

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

49-
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
50-
// Until then, it's just a lot of noise.
51-
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
49+
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
50+
// Until then, it's just a lot of noise.
51+
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
5252
}

marklogic-client-api-functionaltests/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
2020
testImplementation 'org.slf4j:slf4j-api:2.0.17'
2121
testImplementation 'commons-io:commons-io:2.17.0'
22-
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
22+
testImplementation 'com.squareup.okhttp3:okhttp:5.1.0'
2323
testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
2424
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
2525
testImplementation "org.jdom:jdom2:2.0.6.1"
@@ -32,7 +32,7 @@ dependencies {
3232
exclude module: "commons-lang3"
3333
}
3434

35-
testImplementation 'ch.qos.logback:logback-classic:1.3.15'
35+
testImplementation 'ch.qos.logback:logback-classic:1.5.18'
3636
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
3737
testImplementation 'org.xmlunit:xmlunit-legacy:2.10.0'
3838

marklogic-client-api/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ dependencies {
1818
api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1"
1919
implementation "org.glassfish.jaxb:jaxb-runtime:3.0.2"
2020

21-
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
22-
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
23-
implementation 'io.github.rburgst:okhttp-digest:2.7'
21+
implementation 'com.squareup.okhttp3:okhttp:5.1.0'
22+
implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
23+
implementation 'io.github.rburgst:okhttp-digest:3.1.1'
2424

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

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

6565
// Using this to avoid a schema validation issue with the regular xercesImpl
6666
testImplementation 'org.opengis.cite.xerces:xercesImpl-xsd11:2.12-beta-r1667115'

marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
package com.marklogic.client.impl.okhttp;
55

66
import com.marklogic.client.DatabaseClientFactory;
7+
import mockwebserver3.MockWebServer;
78
import okhttp3.Request;
8-
import okhttp3.mockwebserver.MockWebServer;
99
import org.junit.jupiter.api.Test;
1010

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

13-
public class OAuthAuthenticationConfigurerTest {
13+
class OAuthAuthenticationConfigurerTest {
1414

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

21+
DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123");
2022
Request authenticatedRequest = new OAuthAuthenticationConfigurer().makeAuthenticatedRequest(request, authContext);
2123
assertEquals("Bearer abc123", authenticatedRequest.header("Authorization"));
2224
}

marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
package com.marklogic.client.impl.okhttp;
55

66
import com.marklogic.client.ext.helper.LoggingObject;
7+
import mockwebserver3.MockResponse;
8+
import mockwebserver3.MockWebServer;
79
import okhttp3.OkHttpClient;
810
import okhttp3.Request;
9-
import okhttp3.mockwebserver.MockResponse;
10-
import okhttp3.mockwebserver.MockWebServer;
1111
import org.junit.jupiter.api.BeforeEach;
1212
import org.junit.jupiter.api.Test;
1313

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

2828
private MockWebServer mockWebServer;
2929
private FakeTokenGenerator fakeTokenGenerator;
@@ -110,7 +110,12 @@ void multipleThreads() throws Exception {
110110
*/
111111
private void enqueueResponseCodes(int... codes) {
112112
for (int code : codes) {
113-
mockWebServer.enqueue(new MockResponse().setResponseCode(code));
113+
mockWebServer.enqueue(new MockResponse.Builder().code(code).build());
114+
}
115+
try {
116+
mockWebServer.start();
117+
} catch (IOException e) {
118+
throw new RuntimeException(e);
114119
}
115120
}
116121

ml-development-tools/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ publishing {
7171
}
7272

7373
compileKotlin {
74-
kotlinOptions.jvmTarget = '1.8'
74+
kotlinOptions.jvmTarget = '17'
7575
}
7676
compileTestKotlin {
77-
kotlinOptions.jvmTarget = '1.8'
77+
kotlinOptions.jvmTarget = '17'
7878
}
7979

8080
tasks.register("generateTests", JavaExec) {

settings.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
// Allows for downloading a JDK based on Gradle toolchain configuration.
3+
// Using a version prior to 1.0, which requires Java 17, and Jenkins is using Java 8.
4+
id "org.gradle.toolchains.foojay-resolver-convention" version "0.10.0"
5+
}
6+
17
rootProject.name = 'marklogic-client-api-parent'
28
include ':marklogic-client-api'
39
include ':marklogic-client-api-functionaltests'

0 commit comments

Comments
 (0)