Refactor from Jackson Core to avaje-json-core#3789
Open
rob-bygrave wants to merge 6 commits into
Open
Conversation
Reworks the DJsonService (the SpiJsonService SPI behind io.ebean.text.json.EJson) to use avaje JsonMapper instead of the bespoke EJsonReader/EJsonWriter, consolidating all read/write logic into a single JsonAdapter. Changes - New EbeanJsonAdapter — a JsonAdapter<Object> that materializes JSON into plain or modify-aware Map/List/Set, with two shared singletons (PLAIN, MODIFY_AWARE). Preserves existing EJson semantics: - Integral numbers → Long, decimals → BigDecimal - Write coverage for String/Integer/Long/Double/Float/BigDecimal/Boolean/Map/Collection with a toString() fallback for other types (UUID, enum, etc.) - Modify-aware loads share a single ModifyAwareFlag owner per root, reset to non-dirty once after the load completes - DJsonService now builds one JsonMapper + two JsonMapper.Type<Object> and routes parse/write through them. Null serialization is retained via a serializeNulls(true) writer; null/blank-input guards, token-honoring entry points, and parseSet (modify-aware asSet()) are preserved. - EJsonReader/EJsonWriter are now unused and should be deleted (couldn't remove them in this environment). Why Simplifies Ebean's JSON handling by reusing avaje-json-core's JsonMapper rather than maintaining a parallel reader/writer, while keeping behavior identical.
Collapse the per-storage and per-platform ScalarType subclass explosion for the built-in JSON value types into two orthogonal strategies. - Add JsonStorage strategy (VARCHAR / CLOB / BLOB / Postgres) encapsulating how the raw JSON string is read from / bound to JDBC. Postgres vs non-Postgres is now a single reusable strategy rather than a subclass per value type. - Add ScalarTypeJsonValue<T> base holding the shared read / bind / L2-cache / json plumbing once, plus ScalarTypeJsonCollectionValue<T> adding the ScalarTypeArray (DB array column definition) aspect for List/Set. - Rewrite ScalarTypeJsonMap, ScalarTypeJsonList and ScalarTypeJsonSet as thin types: a typeFor factory selecting a JsonStorage + value marshalling that delegates to the avaje-JsonMapper-backed EJson facade. - Remove ScalarTypeJsonMapPostgres and ~16 nested storage/platform classes.
Addresses #3735. Enum-keyed JSON maps previously failed (enum key cast to String). Add ScalarTypeJsonMapEnum which converts enum keys via their ScalarType (honouring @DbEnumValue) and reuses ScalarTypeJsonMap for all storage/platform handling, so it works for VARCHAR/CLOB/BLOB and Postgres JSON/JSONB with no per-storage variants. - JsonStorage now reports jdbcType(), enabling a shared storageFor(...) reused by the plain and enum-key Map types - DefaultTypeManager routes Map<Enum,Object> to the new type and calls setAccessible on the @DbEnumValue method (supports nested/non-public enums) - add TypeReflectHelper.getMapKeyTypeRaw and TestEnumKeyMap
Replace isMapValueTypeObject + isMapStringString with isBuiltinJsonMap: the built-in JSON map handles a String or enum key with a String, Object or wildcard value. This also routes Map<Enum,String> to the built-in type and fixes non-String/enum keys with Object value (e.g. Map<Integer,Object>) being mis-routed to the built-in type (ClassCastException) instead of the object mapper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.