From bc537299e5ddd3954bbad91ec09d66be21c509aa Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:35:35 +0900 Subject: [PATCH] fix pdns api clients (retry 16x) reflect-config.json add --- build.gradle.kts | 3 +-- reflect-config.json | 6 ++++++ src/main/kotlin/space/mori/dnsapi/PowerDNSAPIClient.kt | 7 ++++++- src/main/kotlin/space/mori/dnsapi/ReflectiveAccess.kt | 5 +++++ src/main/resources/reflect-config.json | 8 -------- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 reflect-config.json create mode 100644 src/main/kotlin/space/mori/dnsapi/ReflectiveAccess.kt delete mode 100644 src/main/resources/reflect-config.json diff --git a/build.gradle.kts b/build.gradle.kts index b9bfb95..92b27d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -81,7 +81,7 @@ tasks.withType { environment = mapOf( "BP_NATIVE_IMAGE" to "true", - "BP_NATIVE_IMAGE_BUILD_ARGUMENTS" to "-H:+UnlockExperimentalVMOptions -H:ReflectionConfigurationFiles=src/main/resources/reflect-config.json", + "BP_NATIVE_IMAGE_BUILD_ARGUMENTS" to "-H:+UnlockExperimentalVMOptions", "BP_JVM_TYPE" to "JDK", "BP_JVM_VERSION" to "21", ) @@ -100,6 +100,5 @@ tasks.named("bootRun") { graalvmNative { binaries.all { buildArgs.add("--initialize-at-build-time=org.slf4j.helpers") - buildArgs.add("-H:ReflectionConfigurationFiles=src/main/resources/reflect-config.json") } } \ No newline at end of file diff --git a/reflect-config.json b/reflect-config.json new file mode 100644 index 0000000..ea1bc36 --- /dev/null +++ b/reflect-config.json @@ -0,0 +1,6 @@ +[ + { + "name": "java.lang.reflect.RecordComponent", + "allPublicMethods": true + } +] \ No newline at end of file diff --git a/src/main/kotlin/space/mori/dnsapi/PowerDNSAPIClient.kt b/src/main/kotlin/space/mori/dnsapi/PowerDNSAPIClient.kt index 27b4c12..3ebaba0 100644 --- a/src/main/kotlin/space/mori/dnsapi/PowerDNSAPIClient.kt +++ b/src/main/kotlin/space/mori/dnsapi/PowerDNSAPIClient.kt @@ -1,6 +1,7 @@ package space.mori.dnsapi import com.google.gson.Gson +import com.google.gson.annotations.SerializedName import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request @@ -126,7 +127,11 @@ class PowerDNSAPIClient() { } } -class PowerDNSAPIError(val error: String, val errors: List) +@ReflectiveAccess +data class PowerDNSAPIError( + @SerializedName("error") val error: String, + @SerializedName("errors") val errors: List +) class PowerDNSAPIException(private val error: PowerDNSAPIError): RuntimeException(error.error) { val errors: List get() = error.errors diff --git a/src/main/kotlin/space/mori/dnsapi/ReflectiveAccess.kt b/src/main/kotlin/space/mori/dnsapi/ReflectiveAccess.kt new file mode 100644 index 0000000..f53a05d --- /dev/null +++ b/src/main/kotlin/space/mori/dnsapi/ReflectiveAccess.kt @@ -0,0 +1,5 @@ +package space.mori.dnsapi + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FIELD, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.RUNTIME) +annotation class ReflectiveAccess \ No newline at end of file diff --git a/src/main/resources/reflect-config.json b/src/main/resources/reflect-config.json deleted file mode 100644 index 19e8134..0000000 --- a/src/main/resources/reflect-config.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "name": "space.mori.dnsapi.PowerDNSAPIError", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - } -] \ No newline at end of file