feat(framework,actuator,common): replace fastjson with jackson#6701
Conversation
|
Direction is right — fastjson 1.2.83 has been a long-standing security overhang, and consolidating on Jackson + a thin wrapper is the obvious move. Waiting on the MUST items @lxcmyf and @waynercheung raised before LGTM. One additional question worth pinning down in the PR description: after this change, are there any remaining Also worth a sentence in the PR description on hot-path performance posture: fastjson 1.2.x has a historically-fast parse path, and Jackson has different characteristics under |
|
@yanghang8612 Performance: |
0210c18 to
0116365
Compare
8f82a26 to
669321a
Compare
1984e97 to
afb38e7
Compare
16b15bd to
7d6cccc
Compare
0ac395c to
3dbc2a9
Compare
Replace `com.alibaba:fastjson` with Jackson-backed drop-in
wrappers (`org.tron.json.{JSON, JSONObject, JSONArray, JSONException}`).
No external API changes — all HTTP and JSON-RPC responses remain identical.
Motivation:
- Fastjson 1.2.83 is EOL with 20+ CVEs including critical RCE
- Upgrade jackson-databind 2.18.3 → 2.18.6 (GHSA-72hv-8253-57qq)
- Unify JSON handling (previously split between Jackson and Fastjson)
Core changes (common):
- Add org.tron.json wrappers backed by a shared ObjectMapper
- Remove fastjson from common/build.gradle
HTTP & servlet changes (framework):
- Swap imports from com.alibaba.fastjson → org.tron.json across
all HTTP servlets, JSON-RPC layer, and event/log parsers
Test changes:
- Add BaseHttpTest base class for servlet test lifecycle
Build:
- Update jackson to 2.18.6
- Remove fastjson
close tronprotocol#6607
…ndexV2ServletTest
8c2c805 to
a246ea4
Compare
Pre-3.0.0(The previous event-plugin public release is 2.2.0) event-plugin builds still link against com.alibaba.fastjson, which was removed from java-tron in tronprotocol#6701. When such a plugin is loaded, the NoClassDefFoundError surfaces inside the plugin's own worker thread and is swallowed by its catch(Throwable) handler. The node keeps running while silently dropping every trigger, leaving operators with no signal that the event subscription is broken. Enforce a minimum Plugin-Version at startup in EventPluginLoader.startPlugin using pf4j's VersionManager (semver). When the descriptor version is below 3.0.0, log a clear upgrade hint and return false; the existing call chain in Manager.startEventSubscribing wraps that into TronError(EVENT_SUBSCRIBE_INIT) and aborts node startup instead of silently degrading.
Pre-3.0.0(The previous event-plugin public release is 2.2.0) event-plugin builds still link against com.alibaba.fastjson, which was removed from java-tron in tronprotocol#6701. When such a plugin is loaded, the NoClassDefFoundError surfaces inside the plugin's own worker thread and is swallowed by its catch(Throwable) handler. The node keeps running while silently dropping every trigger, leaving operators with no signal that the event subscription is broken. Enforce a minimum Plugin-Version at startup in EventPluginLoader.startPlugin using pf4j's VersionManager (semver). When the descriptor version is below 3.0.0, log a clear upgrade hint and return false; the existing call chain in Manager.startEventSubscribing wraps that into TronError(EVENT_SUBSCRIBE_INIT) and aborts node startup instead of silently degrading.
) Pre-3.0.0(The previous event-plugin public release is 2.2.0) event-plugin builds still link against com.alibaba.fastjson, which was removed from java-tron in #6701. When such a plugin is loaded, the NoClassDefFoundError surfaces inside the plugin's own worker thread and is swallowed by its catch(Throwable) handler. The node keeps running while silently dropping every trigger, leaving operators with no signal that the event subscription is broken. Enforce a minimum Plugin-Version at startup in EventPluginLoader.startPlugin using pf4j's VersionManager (semver). When the descriptor version is below 3.0.0, log a clear upgrade hint and return false; the existing call chain in Manager.startEventSubscribing wraps that into TronError(EVENT_SUBSCRIBE_INIT) and aborts node startup instead of silently degrading.
Summary
Replace
com.alibaba:fastjsonwith Jackson-backed drop-in wrappers (org.tron.json.{JSON, JSONObject, JSONArray, JSONException}). No external API changes — all HTTP and JSON-RPC responses remain identical.Motivation
Core changes
(common):
org.tron.jsonwrappers backed by a sharedObjectMappercommon/build.gradlemaxNestingDepth/maxTokenCountonCommonParameterandNodeConfig.HttpConfig, with defaults100/100_000inreference.conf(framework): HTTP & servlet changes
com.alibaba.fastjson→org.tron.jsonacross all HTTP servlets, JSON-RPC layer, and event/log parsersCompatibility
{a:1}ALLOW_UNQUOTED_FIELD_NAMES{'a':'1'}ALLOW_SINGLE_QUOTES{"a":1,}and[1,2,]ALLOW_TRAILING_COMMA{"a":1,,,,}and[1,,2]NaNnullInfinity/-Infinity+123,+0.5ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS+.5ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS.5ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS+.5without also accepting.5.5.ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS007as7ALLOW_LEADING_ZEROS_FOR_NUMBERSALLOW_UNESCAPED_CONTROL_CHARS"\q"// ...and/* ... */ALLOW_JAVA_COMMENTSNULLtokenNULLasnullTRUE/FALSEBigDecimalby defaultUSE_BIG_DECIMAL_FOR_FLOATSFAIL_ON_UNKNOWN_PROPERTIES = false{}FAIL_ON_EMPTY_BEANS = falseWriteMapNullValueis enabledJsonInclude.Include.NON_NULLCaution
The table above covers only the currently known differences in Fastjson/Jackson behavior verified during this migration. There may still be other unknown edge-case differences. New code and clients are strongly encouraged to use strict standard JSON instead of relying on Fastjson-specific lenient parsing behavior.
Configuration
Two new
node.httpkeys (defaults shown):Beyond either ceiling, parsing fails with
StreamConstraintsExceptionbefore any business logic runs. Defaults are sized to accommodate every legitimate java-tron HTTP payload comfortably.Build:
close #6607