Refactor Json to JsonMapper, update Gradle to 9.5.1, and set Java 26 toolchain.
This commit is contained in:
Generated
+1
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
||||
Generated
+1
-1
@@ -4,7 +4,7 @@
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_26" project-jdk-name="openjdk-26" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_26" default="true" project-jdk-name="openjdk-26" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -16,3 +16,11 @@ dependencies {
|
||||
implementation 'tools.jackson.core:jackson-databind:3.1.3'
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(26)
|
||||
}
|
||||
sourceCompatibility = JavaVersion.VERSION_26
|
||||
targetCompatibility = JavaVersion.VERSION_26
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#Fri May 08 10:10:06 CEST 2026
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
+3
-5
@@ -1,14 +1,12 @@
|
||||
package dev.coph.nextusweb.server.json;
|
||||
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
import tools.jackson.databind.json.JsonMapper;
|
||||
|
||||
|
||||
|
||||
public final class Json {
|
||||
public static final ObjectMapper MAPPER = JsonMapper.builder()
|
||||
public final class JsonMapper {
|
||||
public static final ObjectMapper MAPPER = tools.jackson.databind.json.JsonMapper.builder()
|
||||
// .addModule(new JavaTimeModule())
|
||||
.build();
|
||||
|
||||
private Json() {}
|
||||
private JsonMapper() {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.coph.nextusweb.server.router;
|
||||
|
||||
import dev.coph.nextusweb.server.json.Json;
|
||||
import dev.coph.nextusweb.server.json.JsonMapper;
|
||||
import dev.coph.nextusweb.server.router.exception.BadRequestException;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.util.CharsetUtil;
|
||||
@@ -54,9 +54,9 @@ public final class Request {
|
||||
byte[] bytes = new byte[raw.content().readableBytes()];
|
||||
raw.content().getBytes(raw.content().readerIndex(), bytes);
|
||||
if (bytes.length == 0) {
|
||||
jsonCache = Json.MAPPER.nullNode();
|
||||
jsonCache = JsonMapper.MAPPER.nullNode();
|
||||
} else {
|
||||
jsonCache = Json.MAPPER.readTree(bytes);
|
||||
jsonCache = JsonMapper.MAPPER.readTree(bytes);
|
||||
}
|
||||
} catch (JacksonException e) {
|
||||
throw new BadRequestException("Invalid JSON: " + e.getOriginalMessage());
|
||||
@@ -69,7 +69,7 @@ public final class Request {
|
||||
try {
|
||||
byte[] bytes = new byte[raw.content().readableBytes()];
|
||||
raw.content().getBytes(raw.content().readerIndex(), bytes);
|
||||
return Json.MAPPER.readValue(bytes, type);
|
||||
return JsonMapper.MAPPER.readValue(bytes, type);
|
||||
} catch (JacksonException e) {
|
||||
throw new BadRequestException(
|
||||
"Could not deserialize body as " + type.getSimpleName() + ": " + e.getOriginalMessage());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.coph.nextusweb.server.router;
|
||||
|
||||
import dev.coph.nextusweb.server.json.Json;
|
||||
import dev.coph.nextusweb.server.json.JsonMapper;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import tools.jackson.core.JacksonException;
|
||||
@@ -32,7 +32,7 @@ public final class Response {
|
||||
|
||||
public Response json(Object value) {
|
||||
try {
|
||||
this.body = Json.MAPPER.writeValueAsBytes(value);
|
||||
this.body = JsonMapper.MAPPER.writeValueAsBytes(value);
|
||||
headers.set(HttpHeaderNames.CONTENT_TYPE, "application/json; charset=utf-8");
|
||||
} catch (JacksonException e) {
|
||||
throw new RuntimeException("JSON serialization failed", e);
|
||||
|
||||
Reference in New Issue
Block a user