feat: raise minimum Java version to 11 and apply OpenRewrite best pra… · OpenFeign/feign@72c9729 · GitHub
Skip to content

Commit 72c9729

Browse files
authored
feat: raise minimum Java version to 11 and apply OpenRewrite best practices (#3397)
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
1 parent 2fe3f1c commit 72c9729

178 files changed

Lines changed: 2279 additions & 1869 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.

‎.gitignore‎

Lines changed: 5 additions & 0 deletions

‎annotation-error-decoder/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
<dependency>
4646
<groupId>com.squareup.okhttp3</groupId>
47-
<artifactId>mockwebserver</artifactId>
47+
<artifactId>mockwebserver3</artifactId>
4848
<scope>test</scope>
4949
</dependency>
5050
<dependency>

‎api/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<dependency>
4747
<groupId>com.squareup.okhttp3</groupId>
48-
<artifactId>mockwebserver</artifactId>
48+
<artifactId>mockwebserver3</artifactId>
4949
<scope>test</scope>
5050
</dependency>
5151

‎api/src/main/java/feign/stream/StreamDecoder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class StreamDecoder implements Decoder {
6767
@Override
6868
public Object decode(Response response, Type type) throws IOException, FeignException {
6969
if (!isStream(type)) {
70-
if (!delegateDecoder.isPresent()) {
70+
if (delegateDecoder.isEmpty()) {
7171
throw new IllegalArgumentException(
7272
"StreamDecoder supports types other than stream. "
7373
+ "When type is not stream, the delegate decoder needs to be setting.");

‎api/src/test/java/feign/EmptyTargetTest.java‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package feign;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19-
import static org.junit.jupiter.api.Assertions.assertThrows;
19+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2020

2121
import feign.Request.HttpMethod;
2222
import feign.Target.EmptyTarget;
@@ -33,24 +33,25 @@ void whenNameNotSupplied() {
3333

3434
@Test
3535
void toString_withoutName() {
36-
assertThat(EmptyTarget.create(UriInterface.class).toString())
37-
.isEqualTo("EmptyTarget(type=UriInterface)");
36+
assertThat(EmptyTarget.create(UriInterface.class))
37+
.hasToString("EmptyTarget(type=UriInterface)");
3838
}
3939

4040
@Test
4141
void toString_withName() {
42-
assertThat(EmptyTarget.create(UriInterface.class, "manager-access").toString())
43-
.isEqualTo("EmptyTarget(type=UriInterface, name=manager-access)");
42+
assertThat(EmptyTarget.create(UriInterface.class, "manager-access"))
43+
.hasToString("EmptyTarget(type=UriInterface, name=manager-access)");
4444
}
4545

4646
@Test
4747
void mustApplyToAbsoluteUrl() {
4848
UnsupportedOperationException exception =
49-
assertThrows(
50-
UnsupportedOperationException.class,
51-
() ->
52-
EmptyTarget.create(UriInterface.class)
53-
.apply(new RequestTemplate().method(HttpMethod.GET).uri("/relative")));
49+
assertThatExceptionOfType(UnsupportedOperationException.class)
50+
.isThrownBy(
51+
() ->
52+
EmptyTarget.create(UriInterface.class)
53+
.apply(new RequestTemplate().method(HttpMethod.GET).uri("/relative")))
54+
.actual();
5455
assertThat(exception.getMessage())
5556
.isEqualTo("Request with non-absolute URL not supported with empty target");
5657
}

‎api/src/test/java/feign/EnumForNameTest.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020

2121
import feign.Request.ProtocolVersion;
2222
import java.util.Arrays;
23+
import org.junit.jupiter.api.Nested;
2324
import org.junit.jupiter.params.ParameterizedTest;
2425
import org.junit.jupiter.params.provider.MethodSource;
2526

2627
public class EnumForNameTest {
2728

28-
public static class KnownEnumValuesTest {
29+
@Nested
30+
public class KnownEnumValuesTest {
2931
public Object name;
3032
public ProtocolVersion expectedProtocolVersion;
3133

@@ -56,7 +58,8 @@ public void initKnownEnumValues(Object name, ProtocolVersion expectedProtocolVer
5658
}
5759
}
5860

59-
public static class UnknownEnumValuesTest {
61+
@Nested
62+
public class UnknownEnumValuesTest {
6063

6164
public Object name;
6265

‎api/src/test/java/feign/FeignExceptionTest.java‎

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package feign;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19-
import static org.junit.jupiter.api.Assertions.assertThrows;
19+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2020

2121
import java.io.IOException;
2222
import java.nio.charset.StandardCharsets;
@@ -255,40 +255,41 @@ void lengthOfBodyExceptionTest() {
255255

256256
@Test
257257
void nullRequestShouldThrowNPEwThrowable() {
258-
assertThrows(
259-
NullPointerException.class, () -> new Derived(404, "message", null, new Throwable()));
258+
assertThatThrownBy(() -> new Derived(404, "message", null, new Throwable()))
259+
.isInstanceOf(NullPointerException.class);
260260
}
261261

262262
@Test
263263
void nullRequestShouldThrowNPEwThrowableAndBytes() {
264-
assertThrows(
265-
NullPointerException.class,
266-
() ->
267-
new Derived(
268-
404,
269-
"message",
270-
null,
271-
new Throwable(),
272-
"content".getBytes(StandardCharsets.UTF_8),
273-
Collections.emptyMap()));
264+
assertThatThrownBy(
265+
() ->
266+
new Derived(
267+
404,
268+
"message",
269+
null,
270+
new Throwable(),
271+
"content".getBytes(StandardCharsets.UTF_8),
272+
Collections.emptyMap()))
273+
.isInstanceOf(NullPointerException.class);
274274
}
275275

276276
@Test
277277
void nullRequestShouldThrowNPE() {
278-
assertThrows(NullPointerException.class, () -> new Derived(404, "message", null));
278+
assertThatThrownBy(() -> new Derived(404, "message", null))
279+
.isInstanceOf(NullPointerException.class);
279280
}
280281

281282
@Test
282283
void nullRequestShouldThrowNPEwBytes() {
283-
assertThrows(
284-
NullPointerException.class,
285-
() ->
286-
new Derived(
287-
404,
288-
"message",
289-
null,
290-
"content".getBytes(StandardCharsets.UTF_8),
291-
Collections.emptyMap()));
284+
assertThatThrownBy(
285+
() ->
286+
new Derived(
287+
404,
288+
"message",
289+
null,
290+
"content".getBytes(StandardCharsets.UTF_8),
291+
Collections.emptyMap()))
292+
.isInstanceOf(NullPointerException.class);
292293
}
293294

294295
static class Derived extends FeignException {

‎api/src/test/java/feign/JavaLoggerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.junit.jupiter.api.BeforeEach;
2424
import org.junit.jupiter.api.Test;
2525

26-
public class JavaLoggerTest {
26+
class JavaLoggerTest {
2727

2828
private static final String CONFIG_KEY = "TestApi#testMethod()";
2929
private java.util.logging.Logger julLogger;

‎api/src/test/java/feign/LoggerMethodsTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
import static org.mockito.Mockito.verify;
2222

2323
import feign.Logger.Level;
24-
import java.io.IOException;
2524
import java.util.Collections;
2625
import org.junit.jupiter.api.Test;
2726

28-
public class LoggerMethodsTest {
27+
class LoggerMethodsTest {
2928

3029
Logger logger =
3130
new Logger() {
@@ -34,7 +33,7 @@ protected void log(String configKey, String format, Object... args) {}
3433
};
3534

3635
@Test
37-
void responseIsClosedAfterRebuffer() throws IOException {
36+
void responseIsClosedAfterRebuffer() throws Exception {
3837
Request request =
3938
Request.create(Request.HttpMethod.GET, "/api", Collections.emptyMap(), null, null);
4039
Response response =

‎api/src/test/java/feign/LoggerRebufferTest.java‎

Lines changed: 14 additions & 14 deletions

0 commit comments

Comments
 (0)