Skip to content

Commit a5b1846

Browse files
authored
techdebt: [FFM-12512]: Fix build for JDK 24 (#207)
* techdebt: [FFM-12512]: Fix build for JDK 24 * formatting fixes
1 parent 7020a49 commit a5b1846

File tree

12 files changed

+81
-74
lines changed

12 files changed

+81
-74
lines changed

build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ plugins {
2020
id 'jacoco-report-aggregation'
2121
id "com.github.spotbugs" version libs.versions.spotbugs
2222
id "org.owasp.dependencycheck" version libs.versions.depcheck
23-
id 'me.champeau.jmh' version '0.6.8' // Added JMH plugin
24-
id "com.vanniktech.maven.publish" version "0.33.0"
23+
id "com.vanniktech.maven.publish" version libs.versions.maven.publish
2524
}
2625

2726

@@ -57,10 +56,6 @@ dependencies {
5756

5857
compileOnly libs.lombok
5958
annotationProcessor libs.lombok
60-
61-
// JMH dependencies
62-
implementation 'org.openjdk.jmh:jmh-core:1.37'
63-
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
6459
}
6560

6661
group = 'io.harness'
@@ -113,6 +108,10 @@ testing {
113108
implementation libs.okhttp3.mockwebserver
114109
compileOnly libs.lombok
115110
annotationProcessor libs.lombok
111+
112+
// JMH dependencies
113+
implementation libs.jmh.core
114+
annotationProcessor libs.jmh.annotations
116115
}
117116

118117
targets {

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-3-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dependencyResolutionManagement {
44
versionCatalogs {
55
libs {
66
// main sdk version
7-
version('sdk', '1.8.3');
7+
version('sdk', '1.9.0-SNAPSHOT');
88

99
// sdk deps
1010
version('okhttp3', '4.12.0')
@@ -17,7 +17,7 @@ dependencyResolutionManagement {
1717
library('swagger-annotations', 'io.swagger:swagger-annotations:1.6.2')
1818
library('javax-annotation-api', 'javax.annotation:javax.annotation-api:1.2')
1919
library('slf4j-api', 'org.slf4j:slf4j-api:1.7.36')
20-
library('lombok', 'org.projectlombok:lombok:1.18.30')
20+
library('lombok', 'org.projectlombok:lombok:1.18.38')
2121
library('google-findbugs', 'com.google.code.findbugs:jsr305:3.0.2')
2222

2323
// test libs
@@ -26,6 +26,9 @@ dependencyResolutionManagement {
2626
library('junit-bom', 'org.junit:junit-bom:5.10.1')
2727
library('mockito-junit5', 'org.mockito:mockito-junit-jupiter:4.8.1')
2828
library('okhttp3-mockwebserver', 'com.squareup.okhttp3', 'mockwebserver').versionRef('okhttp3')
29+
version('jmh', '1.37')
30+
library('jmh-core', 'org.openjdk.jmh', 'jmh-core').versionRef('jmh')
31+
library('jmh-annotations', 'org.openjdk.jmh', 'jmh-generator-annprocess').versionRef('jmh')
2932

3033
// examples
3134
library('bc', 'org.bouncycastle:bcpkix-jdk18on:1.78.1')
@@ -35,10 +38,11 @@ dependencyResolutionManagement {
3538
// do not upgrade openapi, doing so will break compatibility with customers using SpringBoot 2.5.x
3639
// (newer 5.x.x generators use APIs not present in okhttp 3.14.9)
3740
version('openapi.generator', '4.3.1')
38-
version('spotless', '6.23.3')
41+
version('spotless', '7.1.0')
3942
version('depsize', '0.2.0')
40-
version('spotbugs', '6.0.4')
43+
version('spotbugs', '6.1.5')
4144
version('depcheck', '9.0.7')
45+
version('maven.publish', '0.33.0')
4246
}
4347
}
4448
}

src/main/java/io/harness/cf/client/api/PollingProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public CompletableFuture<List<Segment>> retrieveSegments() {
7171
completableFuture.complete(segments);
7272
} catch (Throwable e) {
7373
log.error(
74-
"Exception was raised when fetching segments data with the message {}", e.getMessage(), e);
74+
"Exception was raised when fetching segments data with the message {}",
75+
e.getMessage(),
76+
e);
7577
completableFuture.completeExceptionally(e);
7678
}
7779
return completableFuture;
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
package io.harness.cf.client.connector;
22

3-
import javax.net.SocketFactory;
43
import java.io.IOException;
54
import java.net.InetAddress;
65
import java.net.Socket;
6+
import javax.net.SocketFactory;
77

88
final class DelegatingSocketFactory extends SocketFactory {
9-
private final SocketFactory delegate;
10-
11-
public DelegatingSocketFactory(SocketFactory delegate) {
12-
this.delegate = delegate;
13-
}
14-
15-
@Override
16-
public Socket createSocket() throws IOException {
17-
return configureSocket(delegate.createSocket());
18-
}
19-
20-
@Override
21-
public Socket createSocket(String host, int port) throws IOException {
22-
return configureSocket(delegate.createSocket(host, port));
23-
}
24-
25-
@Override
26-
public Socket createSocket(String host, int port, InetAddress localAddress,
27-
int localPort) throws IOException {
28-
return configureSocket(delegate.createSocket(host, port, localAddress, localPort));
29-
}
30-
31-
@Override
32-
public Socket createSocket(InetAddress host, int port) throws IOException {
33-
return configureSocket(delegate.createSocket(host, port));
34-
}
35-
36-
@Override
37-
public Socket createSocket(InetAddress host, int port, InetAddress localAddress,
38-
int localPort) throws IOException {
39-
return configureSocket(delegate.createSocket(host, port, localAddress, localPort));
40-
}
41-
42-
Socket configureSocket(Socket socket) {
43-
return socket;
44-
}
45-
}
9+
private final SocketFactory delegate;
10+
11+
public DelegatingSocketFactory(SocketFactory delegate) {
12+
this.delegate = delegate;
13+
}
14+
15+
@Override
16+
public Socket createSocket() throws IOException {
17+
return configureSocket(delegate.createSocket());
18+
}
19+
20+
@Override
21+
public Socket createSocket(String host, int port) throws IOException {
22+
return configureSocket(delegate.createSocket(host, port));
23+
}
24+
25+
@Override
26+
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
27+
throws IOException {
28+
return configureSocket(delegate.createSocket(host, port, localAddress, localPort));
29+
}
30+
31+
@Override
32+
public Socket createSocket(InetAddress host, int port) throws IOException {
33+
return configureSocket(delegate.createSocket(host, port));
34+
}
35+
36+
@Override
37+
public Socket createSocket(InetAddress host, int port, InetAddress localAddress, int localPort)
38+
throws IOException {
39+
return configureSocket(delegate.createSocket(host, port, localAddress, localPort));
40+
}
41+
42+
Socket configureSocket(Socket socket) {
43+
return socket;
44+
}
45+
}

src/main/java/io/harness/cf/client/connector/HarnessConnector.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,20 @@ ApiClient makeApiClient(int retryBackOfDelay) {
8888

8989
setupTls(apiClient);
9090

91-
final OkHttpClient.Builder builder = apiClient
92-
.getHttpClient()
93-
.newBuilder();
91+
final OkHttpClient.Builder builder = apiClient.getHttpClient().newBuilder();
9492

9593
ProxyConfig.configureTls(builder);
9694

9795
// if http client response is 403 we need to reauthenticate
98-
apiClient.setHttpClient(builder.proxy(ProxyConfig.getProxyConfig())
99-
.proxyAuthenticator(ProxyConfig.getProxyAuthentication())
100-
.addInterceptor(this::reauthInterceptor)
101-
.addInterceptor(new NewRetryInterceptor(options.getMaxRequestRetry(), retryBackOfDelay, isShuttingDown))
102-
.build());
96+
apiClient.setHttpClient(
97+
builder
98+
.proxy(ProxyConfig.getProxyConfig())
99+
.proxyAuthenticator(ProxyConfig.getProxyAuthentication())
100+
.addInterceptor(this::reauthInterceptor)
101+
.addInterceptor(
102+
new NewRetryInterceptor(
103+
options.getMaxRequestRetry(), retryBackOfDelay, isShuttingDown))
104+
.build());
103105

104106
return apiClient;
105107
}

src/main/java/io/harness/cf/client/connector/NewRetryInterceptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ int getRetryAfterHeaderInSeconds(Response response) {
157157
seconds = (int) Duration.between(Instant.now(), then.toInstant()).getSeconds();
158158
}
159159
} catch (ParseException ignored) {
160-
log.warn("Unable to parse Retry-After header value: `{}` as integer or date", retryAfterValue);
160+
log.warn(
161+
"Unable to parse Retry-After header value: `{}` as integer or date", retryAfterValue);
161162
}
162163
}
163164

src/main/java/io/harness/cf/client/connector/ProxyConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import java.net.InetSocketAddress;
44
import java.net.Proxy;
5+
import javax.net.ssl.SSLSocketFactory;
56
import lombok.extern.slf4j.Slf4j;
67
import okhttp3.Authenticator;
78
import okhttp3.Credentials;
89
import okhttp3.OkHttpClient;
910

10-
import javax.net.ssl.SSLSocketFactory;
11-
1211
@Slf4j
1312
public class ProxyConfig {
1413

src/test/java/io/harness/cf/client/api/EvaluatorIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public List<DynamicTest> getTestCases() throws Exception {
3535

3636
assertTrue(
3737
testCasesDirectory.exists(),
38-
"ff-test-cases folder missing - please check 'git submodule init' has been run");
38+
"ff-test-cases folder missing - please check 'git submodule update --init' has been run");
3939

4040
try (Stream<Path> pathStream = Files.walk(Paths.get(testCasesBasePath))) {
4141
pathStream

src/test/java/io/harness/cf/client/api/StorageRepositoryTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void shouldStoreCurrentConfig() throws Exception {
5050
assertNotNull(current);
5151

5252
// check if the current version is correct
53-
assertEquals(current.getVersion(), new Long(2));
53+
assertEquals(current.getVersion(), 2L);
5454
}
5555

5656
@Test
@@ -84,7 +84,7 @@ void shouldStoreCurrentConfigWithFileStore() throws Exception {
8484
assertNotNull(current);
8585

8686
// check if the current version is correct
87-
assertEquals(current.getVersion(), new Long(2));
87+
assertEquals(current.getVersion(), 2L);
8888
}
8989

9090
@Test
@@ -118,8 +118,8 @@ void shouldStorePreviousAndCurrentConfigWithFileStore() throws Exception {
118118
assertNotNull(current);
119119

120120
// check if the current version is correct
121-
assertEquals(previous.getVersion(), new Long(1));
122-
assertEquals(current.getVersion(), new Long(2));
121+
assertEquals(previous.getVersion(), 1L);
122+
assertEquals(current.getVersion(), 2L);
123123
}
124124

125125
@Test
@@ -146,8 +146,8 @@ void shouldStorePreviousAndCurrentConfig() throws Exception {
146146
assertNotNull(current);
147147

148148
// check if the current version is correct
149-
assertEquals(previous.getVersion(), new Long(1));
150-
assertEquals(current.getVersion(), new Long(2));
149+
assertEquals(previous.getVersion(), 1L);
150+
assertEquals(current.getVersion(), 2L);
151151
}
152152

153153
@Test
@@ -176,8 +176,8 @@ void shouldDeletePreviousAndCurrentConfig() throws Exception {
176176
assertNotNull(current);
177177

178178
// check if the current version is correct
179-
assertEquals(previous.getVersion(), new Long(1));
180-
assertEquals(current.getVersion(), new Long(2));
179+
assertEquals(previous.getVersion(), 1L);
180+
assertEquals(current.getVersion(), 2L);
181181

182182
// delete config
183183
repository.deleteFlag(featureIdentifier);
@@ -233,7 +233,7 @@ private List<FeatureConfig> makeFeatureList(FeatureConfig fc) {
233233

234234
private FeatureConfig GetUpdatedFeatureConfigFromFile() throws Exception {
235235
FeatureConfig fc = GetFeatureConfigFromFile();
236-
fc.setVersion(new Long(2));
236+
fc.setVersion(2L);
237237
return fc;
238238
}
239239

@@ -262,7 +262,7 @@ private List<FeatureConfig> createBenchmarkData(int flagNumber, int version) thr
262262
for (int i = 1; i <= flagNumber; i++) {
263263
FeatureConfig f = fg;
264264
f.setFeature("simpleBool" + i);
265-
f.setVersion(new Long(version));
265+
f.setVersion((long) version);
266266
list.add(f);
267267
}
268268
// System.out.println(list);

0 commit comments

Comments
 (0)