Skip to content

Commit 08b9c7c

Browse files
authored
Upgrade test compilation and execution to Java 25 (#3210)
* Upgrade test compilation and execution to Java 25 Signed-off-by: Marvin Froeder <velo.br@gmail.com> * Apply OpenRewrite UpgradeToJava25 on test sources and fix Lombok val compatibility Signed-off-by: Marvin Froeder <velo.br@gmail.com> * Update TrustingSSLSocketFactory to use TLS and ECDHE cipher suite for Java 25 compatibility Signed-off-by: Marvin Froeder <velo.br@gmail.com> --------- Signed-off-by: Marvin Froeder <velo.br@gmail.com>
1 parent 5e1345e commit 08b9c7c

62 files changed

Lines changed: 258 additions & 275 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ commands:
2929
- run:
3030
name: 'Check if cache was restored'
3131
command: |
32-
if [ -d "$HOME/.sdkman/candidates/java/21.0.2-tem" ] && [ -d ~/.m2/repository/io/github/openfeign ]; then
32+
if [ -d "$HOME/.sdkman/candidates/java/25.0.2-tem" ] && [ -d ~/.m2/repository/io/github/openfeign ]; then
3333
echo "Complete cache hit detected - SDKMAN and Maven dependencies available."
3434
circleci step halt
3535
elif [ -d "$HOME/.sdkman/candidates/java/21.0.2-tem" ]; then
@@ -47,16 +47,16 @@ commands:
4747
fi
4848
source "$HOME/.sdkman/bin/sdkman-init.sh"
4949
- run:
50-
name: 'Install JDKs (8, 11, 17, 21)'
50+
name: 'Install JDKs (8, 11, 17, 21, 25)'
5151
command: |
5252
source "$HOME/.sdkman/bin/sdkman-init.sh"
53-
jdk_versions=("8.0.382-tem" "11.0.22-tem" "17.0.10-tem" "21.0.2-tem")
53+
jdk_versions=("8.0.382-tem" "11.0.22-tem" "17.0.10-tem" "21.0.2-tem" "25.0.2-tem")
5454
for jdk_version in "${jdk_versions[@]}"; do
5555
if [ ! -d "$HOME/.sdkman/candidates/java/$jdk_version" ]; then
5656
echo "n" | sdk install java "$jdk_version" || true
5757
fi
5858
done
59-
sdk default java 21.0.2-tem
59+
sdk default java 25.0.2-tem
6060
- run:
6161
name: 'Configure Maven Toolchain'
6262
command: |

.circleci/toolchains.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,13 @@
5050
<jdkHome>/home/circleci/.sdkman/candidates/java/21.0.2-tem</jdkHome>
5151
</configuration>
5252
</toolchain>
53+
<toolchain>
54+
<type>jdk</type>
55+
<provides>
56+
<version>25</version>
57+
</provides>
58+
<configuration>
59+
<jdkHome>/home/circleci/.sdkman/candidates/java/25.0.2-tem</jdkHome>
60+
</configuration>
61+
</toolchain>
5362
</toolchains>

annotation-error-decoder/src/test/java/feign/error/AnnotationErrorDecoderNoAnnotationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Class<TestClientInterfaceWithNoAnnotations> interfaceAtTest() {
3232
@Test
3333
void delegatesToDefaultErrorDecoder() throws Exception {
3434

35-
ErrorDecoder defaultErrorDecoder = (methodKey, response) -> new DefaultErrorDecoderException();
35+
ErrorDecoder defaultErrorDecoder = (_, _) -> new DefaultErrorDecoderException();
3636

3737
AnnotationErrorDecoder decoder =
3838
AnnotationErrorDecoder.builderFor(TestClientInterfaceWithNoAnnotations.class)

core/src/test/java/feign/AlwaysEncodeBodyContractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AlwaysEncodeBodyContractTest {
3838
private static class SampleContract extends AlwaysEncodeBodyContract {
3939
SampleContract() {
4040
AnnotationProcessor<SampleMethodAnnotation> annotationProcessor =
41-
(annotation, metadata) -> metadata.template().method(Request.HttpMethod.POST);
41+
(_, metadata) -> metadata.template().method(Request.HttpMethod.POST);
4242
super.registerMethodAnnotation(SampleMethodAnnotation.class, annotationProcessor);
4343
}
4444
}

core/src/test/java/feign/AsyncFeignTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void overrideTypeSpecificDecoder() throws Throwable {
508508

509509
TestInterfaceAsync api =
510510
new TestInterfaceAsyncBuilder()
511-
.decoder((response, type) -> "fail")
511+
.decoder((_, _) -> "fail")
512512
.target("http://localhost:" + server.getPort());
513513

514514
assertThat(unwrap(api.post())).isEqualTo("fail");
@@ -551,7 +551,7 @@ void doesntRetryAfterResponseIsSent() throws Throwable {
551551
TestInterfaceAsync api =
552552
new TestInterfaceAsyncBuilder()
553553
.decoder(
554-
(response, type) -> {
554+
(_, _) -> {
555555
throw new IOException("timeout");
556556
})
557557
.target("http://localhost:" + server.getPort());
@@ -569,7 +569,7 @@ void throwsFeignExceptionIncludingBody() throws Throwable {
569569
TestInterfaceAsync api =
570570
AsyncFeign.builder()
571571
.decoder(
572-
(response, type) -> {
572+
(_, _) -> {
573573
throw new IOException("timeout");
574574
})
575575
.target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());
@@ -594,7 +594,7 @@ void throwsFeignExceptionWithoutBody() {
594594
TestInterfaceAsync api =
595595
AsyncFeign.builder()
596596
.decoder(
597-
(response, type) -> {
597+
(_, _) -> {
598598
throw new IOException("timeout");
599599
})
600600
.target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());
@@ -621,7 +621,7 @@ void ensureRetryerClonesItself() throws Throwable {
621621
AsyncFeign.builder()
622622
.retryer(retryer)
623623
.errorDecoder(
624-
(methodKey, response) ->
624+
(_, response) ->
625625
new RetryableException(
626626
response.status(),
627627
"play it again sam!",
@@ -647,7 +647,7 @@ void throwsOriginalExceptionAfterFailedRetries() throws Throwable {
647647
.exceptionPropagationPolicy(UNWRAP)
648648
.retryer(new Retryer.Default(1, 1, 2))
649649
.errorDecoder(
650-
(methodKey, response) ->
650+
(_, response) ->
651651
new RetryableException(
652652
response.status(),
653653
"play it again sam!",
@@ -673,7 +673,7 @@ void throwsRetryableExceptionIfNoUnderlyingCause() throws Throwable {
673673
.exceptionPropagationPolicy(UNWRAP)
674674
.retryer(new Retryer.Default(1, 1, 2))
675675
.errorDecoder(
676-
(methodKey, response) ->
676+
(_, response) ->
677677
new RetryableException(
678678
response.status(),
679679
message,
@@ -705,7 +705,7 @@ void whenReturnTypeIsResponseNoErrorHandling() throws Throwable {
705705
// fake client as Client.Default follows redirects.
706706
TestInterfaceAsync api =
707707
AsyncFeign.<Void>builder()
708-
.client(new AsyncClient.Default<>((request, options) -> response, execs))
708+
.client(new AsyncClient.Default<>((_, _) -> response, execs))
709709
.target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());
710710

711711
assertThat(unwrap(api.response()).headers())
@@ -730,7 +730,7 @@ public void cancelRetry(final int expectedTryCount) throws Throwable {
730730
final int RUNNING_TIME_MILLIS = 100;
731731
final ExecutorService execs = Executors.newSingleThreadExecutor();
732732
final AsyncClient<Void> clientMock =
733-
(request, options, requestContext) ->
733+
(_, _, _) ->
734734
CompletableFuture.supplyAsync(
735735
() -> {
736736
final int tryCount = actualTryCount.addAndGet(1);
@@ -796,7 +796,7 @@ void okIfDecodeRootCauseHasNoMessage() throws Throwable {
796796
TestInterfaceAsync api =
797797
new TestInterfaceAsyncBuilder()
798798
.decoder(
799-
(response, type) -> {
799+
(_, _) -> {
800800
throw new RuntimeException();
801801
})
802802
.target("http://localhost:" + server.getPort());
@@ -812,7 +812,7 @@ void decodingExceptionGetWrappedInDismiss404Mode() throws Throwable {
812812
new TestInterfaceAsyncBuilder()
813813
.dismiss404()
814814
.decoder(
815-
(response, type) -> {
815+
(response, _) -> {
816816
assertEquals(404, response.status());
817817
throw new NoSuchElementException();
818818
})
@@ -848,7 +848,7 @@ void okIfEncodeRootCauseHasNoMessage() throws Throwable {
848848
TestInterfaceAsync api =
849849
new TestInterfaceAsyncBuilder()
850850
.encoder(
851-
(object, bodyType, template) -> {
851+
(_, _, _) -> {
852852
throw new RuntimeException();
853853
})
854854
.target("http://localhost:" + server.getPort());
@@ -951,7 +951,7 @@ void responseMapperIsAppliedBeforeDelegate() throws IOException {
951951
}
952952

953953
private ResponseMapper upperCaseResponseMapper() {
954-
return (response, type) -> {
954+
return (response, _) -> {
955955
try {
956956
return response.toBuilder()
957957
.body(Util.toString(response.body().asReader()).toUpperCase().getBytes())
@@ -1222,7 +1222,7 @@ static final class TestInterfaceAsyncBuilder {
12221222
AsyncFeign.<Void>builder()
12231223
.decoder(new Decoder.Default())
12241224
.encoder(
1225-
(object, bodyType, template) -> {
1225+
(object, _, template) -> {
12261226
if (object instanceof Map) {
12271227
template.body(new Gson().toJson(object));
12281228
} else {

core/src/test/java/feign/BaseApiTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void resolvesParameterizedResult() throws InterruptedException {
6565

6666
Feign.builder()
6767
.decoder(
68-
(response, type) -> {
68+
(_, type) -> {
6969
assertThat(type).isEqualTo(new TypeToken<Entity<String, Long>>() {}.getType());
7070
return null;
7171
})
@@ -83,10 +83,10 @@ void resolvesBodyParameter() throws InterruptedException {
8383

8484
Feign.builder()
8585
.encoder(
86-
(object, bodyType, template) ->
86+
(_, bodyType, _) ->
8787
assertThat(bodyType).isEqualTo(new TypeToken<Keys<String>>() {}.getType()))
8888
.decoder(
89-
(response, type) -> {
89+
(_, type) -> {
9090
assertThat(type).isEqualTo(new TypeToken<Entities<String, Long>>() {}.getType());
9191
return null;
9292
})

core/src/test/java/feign/BaseBuilderTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ class BaseBuilderTest {
3030
void checkEnrichTouchesAllAsyncBuilderFields()
3131
throws IllegalArgumentException, IllegalAccessException {
3232
test(
33-
AsyncFeign.builder()
34-
.requestInterceptor(template -> {})
35-
.responseInterceptor((ic, c) -> c.next(ic)),
33+
AsyncFeign.builder().requestInterceptor(_ -> {}).responseInterceptor((ic, c) -> c.next(ic)),
3634
14);
3735
}
3836

@@ -62,9 +60,6 @@ private void test(BaseBuilder<?, ?> builder, int expectedFieldsCount)
6260
void checkEnrichTouchesAllBuilderFields()
6361
throws IllegalArgumentException, IllegalAccessException {
6462
test(
65-
Feign.builder()
66-
.requestInterceptor(template -> {})
67-
.responseInterceptor((ic, c) -> c.next(ic)),
68-
12);
63+
Feign.builder().requestInterceptor(_ -> {}).responseInterceptor((ic, c) -> c.next(ic)), 12);
6964
}
7065
}

core/src/test/java/feign/FeignBuilderTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void overrideEncoder() throws Exception {
210210
server.enqueue(new MockResponse().setBody("response data"));
211211

212212
String url = "http://localhost:" + server.getPort();
213-
Encoder encoder = (object, bodyType, template) -> template.body(object.toString());
213+
Encoder encoder = (object, _, template) -> template.body(object.toString());
214214

215215
TestInterface api = Feign.builder().encoder(encoder).target(TestInterface.class, url);
216216
api.encodedPost(Arrays.asList("This", "is", "my", "request"));
@@ -223,7 +223,7 @@ void overrideDecoder() {
223223
server.enqueue(new MockResponse().setBody("success!"));
224224

225225
String url = "http://localhost:" + server.getPort();
226-
Decoder decoder = (response, type) -> "fail";
226+
Decoder decoder = (_, _) -> "fail";
227227

228228
TestInterface api = Feign.builder().decoder(decoder).target(TestInterface.class, url);
229229
assertThat(api.decodedPost()).isEqualTo("fail");
@@ -237,7 +237,7 @@ void overrideQueryMapEncoder() throws Exception {
237237

238238
String url = "http://localhost:" + server.getPort();
239239
QueryMapEncoder customMapEncoder =
240-
ignored -> {
240+
_ -> {
241241
Map<String, Object> queryMap = new HashMap<>();
242242
queryMap.put("key1", "value1");
243243
queryMap.put("key2", "value2");
@@ -347,7 +347,7 @@ void doNotCloseAfterDecode() {
347347

348348
String url = "http://localhost:" + server.getPort();
349349
Decoder decoder =
350-
(response, type) ->
350+
(response, _) ->
351351
new Iterator<>() {
352352
private boolean called = false;
353353

@@ -391,7 +391,7 @@ void doNotCloseAfterDecodeDecoderFailure() {
391391

392392
String url = "http://localhost:" + server.getPort();
393393
Decoder angryDecoder =
394-
(response, type) -> {
394+
(_, _) -> {
395395
throw new IOException("Failed to decode the response");
396396
};
397397

@@ -454,7 +454,7 @@ public void close() throws IOException {
454454
try {
455455
api.decodedLazyPost();
456456
fail("Expected an exception");
457-
} catch (FeignException expected) {
457+
} catch (FeignException _) {
458458
}
459459
assertThat(closed.get()).as("Responses must be closed when the decoder fails").isTrue();
460460
}

0 commit comments

Comments
 (0)