Skip to content

[#8385] Make JsonCodec.java is thread safe#8399

Merged
justinmclean merged 2 commits intoapache:mainfrom
Surya00011:fix/make-JsonCodec-threadSafe
Sep 3, 2025
Merged

[#8385] Make JsonCodec.java is thread safe#8399
justinmclean merged 2 commits intoapache:mainfrom
Surya00011:fix/make-JsonCodec-threadSafe

Conversation

@Surya00011
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • Made JsonCodec thread-safe by marking mapper and jsonType as volatile.
  • Applied double-checked locking in getMapper and getJsonType to ensure proper lazy initialization in concurrent scenarios.
  • No functional changes to the JSON serialization/deserialization behavior.

Why are the changes needed?

  • JsonCodec was not thread-safe: concurrent access to mapper and jsonType could cause race conditions or inconsistent initialization.

Fix: #8385

Does this PR introduce any user-facing change?

  • No user-facing API changes.
  • No properties or configuration keys were added or removed.
  • Existing functionality behaves identically, but now safely under concurrent access.

@justinmclean justinmclean changed the title Made JsonCodec.java is thread safe Make JsonCodec.java is thread safe Sep 2, 2025
@justinmclean justinmclean changed the title Make JsonCodec.java is thread safe [#8385] Make JsonCodec.java is thread safe Sep 3, 2025
Copy link
Copy Markdown
Member

@justinmclean justinmclean left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this

@justinmclean justinmclean merged commit 23a13e4 into apache:main Sep 3, 2025
25 checks passed
diqiu50 pushed a commit to diqiu50/gravitino that referenced this pull request Sep 15, 2025
### What changes were proposed in this pull request?

- Made `JsonCodec` thread-safe by marking `mapper` and `jsonType` as
`volatile`.
- Applied double-checked locking in `getMapper` and `getJsonType` to
ensure proper lazy initialization in concurrent scenarios.
- No functional changes to the JSON serialization/deserialization
behavior.

### Why are the changes needed?

- `JsonCodec` was not thread-safe: concurrent access to `mapper` and
`jsonType` could cause race conditions or inconsistent initialization.

Fix: apache#8385

### Does this PR introduce  any user-facing change?

- No user-facing API changes.
- No properties or configuration keys were added or removed.
- Existing functionality behaves identically, but now safely under
concurrent access.
bharos pushed a commit to bharos/gravitino that referenced this pull request Oct 3, 2025
### What changes were proposed in this pull request?

- Made `JsonCodec` thread-safe by marking `mapper` and `jsonType` as
`volatile`.
- Applied double-checked locking in `getMapper` and `getJsonType` to
ensure proper lazy initialization in concurrent scenarios.
- No functional changes to the JSON serialization/deserialization
behavior.

### Why are the changes needed?

- `JsonCodec` was not thread-safe: concurrent access to `mapper` and
`jsonType` could cause race conditions or inconsistent initialization.

Fix: apache#8385

### Does this PR introduce  any user-facing change?

- No user-facing API changes.
- No properties or configuration keys were added or removed.
- Existing functionality behaves identically, but now safely under
concurrent access.
bharos pushed a commit to bharos/gravitino that referenced this pull request Oct 7, 2025
### What changes were proposed in this pull request?

- Made `JsonCodec` thread-safe by marking `mapper` and `jsonType` as
`volatile`.
- Applied double-checked locking in `getMapper` and `getJsonType` to
ensure proper lazy initialization in concurrent scenarios.
- No functional changes to the JSON serialization/deserialization
behavior.

### Why are the changes needed?

- `JsonCodec` was not thread-safe: concurrent access to `mapper` and
`jsonType` could cause race conditions or inconsistent initialization.

Fix: apache#8385

### Does this PR introduce  any user-facing change?

- No user-facing API changes.
- No properties or configuration keys were added or removed.
- Existing functionality behaves identically, but now safely under
concurrent access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] TestJsonCodec.java is not thread safe

2 participants