From 9962c3e3fa5b2640612e67b29d0c3634e4bf4e05 Mon Sep 17 00:00:00 2001 From: chaokunyang Date: Wed, 6 Nov 2024 15:22:14 +0800 Subject: [PATCH 1/2] add fury builder options --- .../quarkiverse/fury/FuryBuildTimeConfig.java | 36 +++++++++++++++++++ .../io/quarkiverse/fury/FuryRecorder.java | 8 ++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java b/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java index bf01151..d40861d 100644 --- a/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java +++ b/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java @@ -3,6 +3,8 @@ import java.util.Map; import java.util.Optional; +import org.apache.fury.config.CompatibleMode; + import io.quarkus.runtime.annotations.ConfigDocMapKey; import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigPhase; @@ -17,6 +19,40 @@ public interface FuryBuildTimeConfig { @WithDefault("true") boolean requiredClassRegistration(); + /** Whether track shared or circular references. */ + @WithDefault("false") + boolean trackRef(); + + /** + * Set class schema compatible mode. + *
+ * SCHEMA_CONSISTENT: Class schema must be consistent between serialization peer and deserialization peer. + *
+ * COMPATIBLE: Class schema can be different between serialization peer and deserialization peer. They can + * add/delete fields independently. + */ + @WithDefault("SCHEMA_CONSISTENT") + CompatibleMode compatibleMode(); + + /** Use variable length encoding for int/long. */ + @WithDefault("true") + boolean compressNumber(); + + /** Whether compress string for small size. */ + @WithDefault("true") + boolean compressString(); + + /** + * Whether deserialize/skip data of un-existed class. If not enabled, an exception will be thrown + * if class not exist. + */ + @WithDefault("true") + boolean deserializeNonexistentClass(); + + /** If an enum value doesn't exist, return a null instead of throws exception. */ + @WithDefault("true") + boolean deserializeNonexistentEnumValueAsNull(); + /** Whether to use thread safe fury. The default is true. */ @WithDefault("true") boolean threadSafe(); diff --git a/runtime/src/main/java/io/quarkiverse/fury/FuryRecorder.java b/runtime/src/main/java/io/quarkiverse/fury/FuryRecorder.java index 5198cc9..627a95e 100644 --- a/runtime/src/main/java/io/quarkiverse/fury/FuryRecorder.java +++ b/runtime/src/main/java/io/quarkiverse/fury/FuryRecorder.java @@ -23,7 +23,13 @@ public RuntimeValue createFury( final FuryBuildTimeConfig config, final BeanContainer beanContainer) { // create the Fury instance from the config FuryBuilder builder = Fury.builder(); - builder.requireClassRegistration(config.requiredClassRegistration()); + builder.requireClassRegistration(config.requiredClassRegistration()) + .withRefTracking(config.trackRef()) + .withCompatibleMode(config.compatibleMode()) + .withDeserializeNonexistentClass(config.deserializeNonexistentClass()) + .deserializeNonexistentEnumValueAsNull(config.deserializeNonexistentEnumValueAsNull()) + .withNumberCompressed(config.compressNumber()) + .withStringCompressed(config.compressString()); BaseFury fury = config.threadSafe() ? builder.buildThreadSafeFury() : builder.build(); // register to the container From 4e50a986dd07ded766761d34cb710095726cbd56 Mon Sep 17 00:00:00 2001 From: chaokunyang Date: Wed, 6 Nov 2024 20:29:24 +0800 Subject: [PATCH 2/2] set deserializeNonexistentClass default value to false --- .../main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java b/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java index d40861d..3f49b6d 100644 --- a/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java +++ b/runtime/src/main/java/io/quarkiverse/fury/FuryBuildTimeConfig.java @@ -46,11 +46,11 @@ public interface FuryBuildTimeConfig { * Whether deserialize/skip data of un-existed class. If not enabled, an exception will be thrown * if class not exist. */ - @WithDefault("true") + @WithDefault("false") boolean deserializeNonexistentClass(); /** If an enum value doesn't exist, return a null instead of throws exception. */ - @WithDefault("true") + @WithDefault("false") boolean deserializeNonexistentEnumValueAsNull(); /** Whether to use thread safe fury. The default is true. */