Skip to content

Commit d84a3fa

Browse files
committed
Add java 25 to test matrix, Hopefully fix void problem
1 parent 7e4e93a commit d84a3fa

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
java: [11, 17, 21]
8+
java: [11, 17, 21, 25]
99
fail-fast: false
1010
steps:
1111
- uses: actions/checkout@v4

src/main/java/gs/mclo/api/internal/JsonBodyHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.JsonElement;
44
import gs.mclo.api.APIException;
55
import gs.mclo.api.MclogsClient;
6+
import org.jetbrains.annotations.Nullable;
67

78
import java.net.http.HttpResponse;
89
import java.util.concurrent.CompletionException;
@@ -17,17 +18,21 @@ public JsonBodyHandler(MclogsClient client, Class<T> clazz) {
1718
}
1819

1920
@Override
20-
public HttpResponse.BodySubscriber<T> apply(HttpResponse.ResponseInfo responseInfo) {
21+
public HttpResponse.BodySubscriber<@Nullable T> apply(HttpResponse.ResponseInfo responseInfo) {
2122
return HttpResponse.BodySubscribers.mapping(new JsonElementBodySubscriber(client.gson()), x -> map(x, responseInfo));
2223
}
2324

24-
T map(JsonElement element, HttpResponse.ResponseInfo responseInfo) {
25+
@Nullable T map(JsonElement element, HttpResponse.ResponseInfo responseInfo) {
2526
if (!element.isJsonObject()) {
2627
throw new CompletionException(new APIException("Invalid API response (Status code: " + responseInfo.statusCode() + ")", responseInfo.statusCode()));
2728
}
2829

2930
checkError(element, responseInfo);
3031

32+
if (clazz == Void.class) {
33+
return null;
34+
}
35+
3136
var body = client.gson().fromJson(element, clazz);
3237

3338
if (body instanceof Initializable) {

0 commit comments

Comments
 (0)