Skip to content

refactor(framework): replace fastjson with jackson#120

Open
halibobo1205 wants to merge 1 commit intodevelopfrom
feat/jackjson2
Open

refactor(framework): replace fastjson with jackson#120
halibobo1205 wants to merge 1 commit intodevelopfrom
feat/jackjson2

Conversation

@halibobo1205
Copy link
Copy Markdown
Owner

@halibobo1205 halibobo1205 commented Apr 4, 2026

Remove the fastjson and replace it with
Jackson-backed drop-in wrappers (JSON, JSONObject, JSONArray,JSONException).

Motivation:

  • Fastjson has a history of critical CVEs and is no longer actively maintained for 1.x
  • Jackson-databind 2.18.6 addresses CVE GHSA-72hv-8253-57qq

Core changes (common module):

  • Add org.tron.json.{JSON, JSONObject, JSONArray, JSONException}
    wrappers backed by a shared Jackson ObjectMapper configured to
    match Fastjson 1.x parsing/serialization.
  • Upgrade jackson-databind 2.18.3 → 2.18.6

HTTP servlet changes (framework module):

  • Swap import from com.alibaba.fastjson → org.tron.json across all
    HTTP API servlets, JSON-RPC layer, and event/log parsers

Test changes:

  • Add BaseHttpTest base class managing Args lifecycle, Wallet mock,
    MINIMAL_TX constant, and request/response factory methods
    (postRequest, getRequest, newResponse)

Build:

  • Remove fastjson from common/build.gradle dependencies
  • Update gradle/verification-metadata.xml for jackson 2.18.6

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Apr 4, 2026
Comment thread framework/src/test/java/org/tron/core/services/http/SetAccountIdServletTest.java Outdated
Comment thread common/src/main/java/org/tron/common/utils/JsonUtil.java
Comment thread common/src/main/java/org/tron/json/JSONArray.java
Comment thread common/src/main/java/org/tron/json/JSON.java Outdated
Comment thread framework/src/test/java/org/tron/json/JsonCompatibilityFuzzTest.java Outdated
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI finished reviewing your PR.

halibobo1205 added a commit that referenced this pull request Apr 4, 2026
…erministic fuzz

- Use exact token_id/sell_token_id/buy_token_id byte assertions instead
  of non-empty checks in Exchange and Market servlet tests
- Add account_id byte assertion in SetAccountIdServletTest
- Switch fuzz test from non-deterministic SecureRandom to seeded Random
  for reproducible CI failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@halibobo1205
Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI is running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:XXL This PR changes 1000+ lines, ignoring generated files labels Apr 4, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

Sequence Diagram

This PR replaces Fastjson with Jackson-backed JSON, JSONObject, and JSONArray wrappers and wires all HTTP servlets to use them, so request bodies are parsed and responses serialized via a shared, safely-configured ObjectMapper while preserving existing API contracts.

sequenceDiagram
    participant Client
    participant HttpServlet
    participant JSONWrapper
    participant Wallet
    participant Util

    Client->>HttpServlet: POST transaction request (JSON body)
    HttpServlet->>JSONWrapper: parseObject(requestBody) to JSONObject
    HttpServlet->>Wallet: createTransactionCapsule(built from JSONObject fields)
    Wallet-->>HttpServlet: Transaction object
    HttpServlet->>Util: Serialize Transaction to JSON via JSON/JSONObject/JSONArray
    Util-->>Client: 200 OK with transaction JSON response
Loading

Generated by CodeAnt AI

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@halibobo1205
Copy link
Copy Markdown
Owner Author

@codex: review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 9, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:XXL This PR changes 1000+ lines, ignoring generated files labels Apr 9, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 9, 2026

CodeAnt AI Incremental review completed.

@halibobo1205
Copy link
Copy Markdown
Owner Author

@codex: review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ef086465c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/src/main/java/org/tron/json/JSON.java
Comment thread common/src/main/java/org/tron/json/JSONObject.java
Comment thread common/src/main/java/org/tron/json/JSONArray.java
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 14, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot removed the size:XXL This PR changes 1000+ lines, ignoring generated files label Apr 14, 2026
@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Apr 14, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 14, 2026

CodeAnt AI Incremental review completed.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5227cca3d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/src/main/java/org/tron/json/JSONObject.java
halibobo1205 added a commit that referenced this pull request Apr 15, 2026
… intent

Two compatibility fixes from PR #120 review:

1. JSON.parse("null") now returns Java null instead of Jackson NullNode,
   matching Fastjson's observable behavior. This restores Util.isValidJson("null")
   to false (its prior behavior) and prevents subtle NPE/branch issues for
   downstream callers that compare the result against null.

2. JSONObject.put(key, null) intentionally removes the key. Verified that
   switching to node.putNull(key) would have the unintended side effect of
   emitting "key":null in serialized output (Jackson Include.NON_NULL does NOT
   filter NullNode children of ObjectNode), which would break the Fastjson
   WriteMapNullValue=OFF default that production HTTP responses rely on.
   Documented this in the JSONObject class javadoc to make the design choice
   explicit for future readers.

Fuzz tests updated to assert Java-null result for JSON.parse("null").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 15, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:XXL This PR changes 1000+ lines, ignoring generated files labels Apr 15, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 15, 2026

CodeAnt AI Incremental review completed.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94a3955ec9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/src/main/java/org/tron/core/services/http/Util.java Outdated
@halibobo1205
Copy link
Copy Markdown
Owner Author

@codex: review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2f01952ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/src/main/java/org/tron/json/JSONObject.java Outdated
Comment thread framework/src/main/java/org/tron/core/services/http/Util.java Outdated
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 18, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:XXL This PR changes 1000+ lines, ignoring generated files labels Apr 18, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 18, 2026

CodeAnt AI Incremental review completed.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ed5059a86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/src/main/java/org/tron/json/JSON.java
Comment thread common/src/main/java/org/tron/json/JSONObject.java
Remove the fastjson and replace it with
Jackson-backed drop-in wrappers (JSON, JSONObject, JSONArray,JSONException).

Motivation:
- Fastjson has a history of critical CVEs and is no longer actively maintained for 1.x
- Jackson-databind 2.18.6 addresses CVE GHSA-72hv-8253-57qq

Core changes (common module):
- Add org.tron.json.{JSON, JSONObject, JSONArray, JSONException}
  wrappers backed by a shared Jackson ObjectMapper configured to
  match Fastjson 1.x parsing/serialization.
- Upgrade jackson-databind 2.18.3 → 2.18.6

HTTP servlet changes (framework module):
- Swap import from com.alibaba.fastjson → org.tron.json across all
  HTTP API servlets, JSON-RPC layer, and event/log parsers

Test changes:
- Add BaseHttpTest base class managing Args lifecycle, Wallet mock,
  MINIMAL_TX constant, and request/response factory methods
  (postRequest, getRequest, newResponse)

Build:
- Remove fastjson from common/build.gradle dependencies
- Update gradle/verification-metadata.xml for jackson 2.18.6
@halibobo1205
Copy link
Copy Markdown
Owner Author

@codex: review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1417f1da8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/src/main/java/org/tron/json/JSON.java
@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

Committed on branch work as:

  • 60dafec10fix(json): align parser compatibility and mapper reuse.

Testing

  • ⚠️ ./gradlew :framework:test --tests org.tron.json.JsonTest --tests org.tron.common.utils.JsonUtilTest (fails in this environment because the project requires Java 8, but the runner has Java 17).

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant