From 68b9dc435a2cdf5a06d97ea4ab73d7f10941bf60 Mon Sep 17 00:00:00 2001 From: Ulrik Guenther Date: Tue, 9 Apr 2024 09:17:45 +0200 Subject: [PATCH] RenderConfigReader/OpenVRHMD/ScreenConfig: Replace deprecated jackson KotlinModule() call with current KotlinBuilder() --- .../graphics/scenery/backends/RenderConfigReader.kt | 8 ++++---- .../kotlin/graphics/scenery/controls/OpenVRHMD.kt | 11 ++++++++++- .../kotlin/graphics/scenery/controls/ScreenConfig.kt | 11 ++++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/graphics/scenery/backends/RenderConfigReader.kt b/src/main/kotlin/graphics/scenery/backends/RenderConfigReader.kt index 781600e97..06de2c9c4 100644 --- a/src/main/kotlin/graphics/scenery/backends/RenderConfigReader.kt +++ b/src/main/kotlin/graphics/scenery/backends/RenderConfigReader.kt @@ -183,11 +183,11 @@ class RenderConfigReader { mapper.registerModule( KotlinModule.Builder() .withReflectionCacheSize(512) - .configure(KotlinFeature.NullToEmptyCollection, false) - .configure(KotlinFeature.NullToEmptyMap, false) + .configure(KotlinFeature.NullToEmptyCollection, true) + .configure(KotlinFeature.NullToEmptyMap, true) .configure(KotlinFeature.NullIsSameAsDefault, false) - .configure(KotlinFeature.SingletonSupport, false) - .configure(KotlinFeature.StrictNullChecks, false) + .configure(KotlinFeature.SingletonSupport, true) + .configure(KotlinFeature.StrictNullChecks, true) .build() ) diff --git a/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt b/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt index 1f661221f..6de3f2828 100644 --- a/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt +++ b/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.dataformat.yaml.YAMLFactory +import com.fasterxml.jackson.module.kotlin.KotlinFeature import com.fasterxml.jackson.module.kotlin.KotlinModule import graphics.scenery.* import graphics.scenery.backends.Display @@ -1271,7 +1272,15 @@ open class OpenVRHMD(val seated: Boolean = false, val useCompositor: Boolean = t compositeFile.exists() && compositeFile.length() > 1024 -> { logger.info("Loading model from composite JSON, ${compositeFile.absolutePath}") val mapper = ObjectMapper(YAMLFactory()) - mapper.registerModule(KotlinModule()) + mapper.registerModule( + KotlinModule.Builder() + .configure(KotlinFeature.NullToEmptyCollection, true) + .configure(KotlinFeature.NullToEmptyMap, true) + .configure(KotlinFeature.NullIsSameAsDefault, false) + .configure(KotlinFeature.SingletonSupport, true) + .configure(KotlinFeature.StrictNullChecks, true) + .build() + ) mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false) diff --git a/src/main/kotlin/graphics/scenery/controls/ScreenConfig.kt b/src/main/kotlin/graphics/scenery/controls/ScreenConfig.kt index feeef21fc..8f5b9d2d9 100644 --- a/src/main/kotlin/graphics/scenery/controls/ScreenConfig.kt +++ b/src/main/kotlin/graphics/scenery/controls/ScreenConfig.kt @@ -5,6 +5,7 @@ import org.joml.Vector3f import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.dataformat.yaml.YAMLFactory +import com.fasterxml.jackson.module.kotlin.KotlinFeature import com.fasterxml.jackson.module.kotlin.KotlinModule import graphics.scenery.utils.JsonDeserialisers import graphics.scenery.utils.lazyLogger @@ -142,7 +143,15 @@ class ScreenConfig { */ @JvmStatic fun loadFromFile(path: String): ScreenConfig.Config { val mapper = ObjectMapper(YAMLFactory()) - mapper.registerModule(KotlinModule()) + mapper.registerModule( + KotlinModule.Builder() + .configure(KotlinFeature.NullToEmptyCollection, true) + .configure(KotlinFeature.NullToEmptyMap, true) + .configure(KotlinFeature.NullIsSameAsDefault, false) + .configure(KotlinFeature.SingletonSupport, true) + .configure(KotlinFeature.StrictNullChecks, true) + .build() + ) var stream = ScreenConfig::class.java.getResourceAsStream(path)