Skip to content

Commit 76109d2

Browse files
jderegclaude
andcommitted
Fix: Update LenientNanInfinityTest to use unsafe mode for package-private classes
- Added .useUnsafe(true) to ReadOptions for deserializing package-private outer class - Required due to ThreadLocal unsafe mode changes in java-util 4.0.1 - Updated changelog with unsafe mode feature documentation 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0343e14 commit 76109d2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Revision History
22
#### 4.61.0 (Unreleased)
3+
* **FEATURE**: Added `useUnsafe` option to `ReadOptions` to control unsafe object instantiation. When enabled, json-io can deserialize package-private classes, inner classes, and classes without accessible constructors. This feature is opt-in for security reasons and uses thread-local settings to prevent interference between concurrent deserializations.
34
* **TEST**: Fixed `DistanceBetweenClassesTest.testPrimitives` to accommodate changes in java-util 4.0.1's `ClassUtilities.computeInheritanceDistance()` method. The method now correctly recognizes primitive widening conversions (e.g., byte to int returns distance 2, short to int returns distance 1).
45
* **FIX**: PR #426 - Windows compatibility fixes for json-io:
56
* Fixed `JsonObject.CacheState` to implement `Serializable` for proper Java serialization support

src/test/java/com/cedarsoftware/io/LenientNanInfinityTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ private void testFloatDouble(float float1, double double1)
7979
TestUtil.printLine("a = " + a);
8080
TestUtil.printLine("json = " + json);
8181

82-
ReadOptions readOptions = new ReadOptionsBuilder().allowNanAndInfinity(true).build();
82+
ReadOptions readOptions = new ReadOptionsBuilder()
83+
.allowNanAndInfinity(true)
84+
.useUnsafe(true) // Enable unsafe mode for package-private outer class
85+
.build();
8386
A newA = (A) TestUtil.toObjects(json, readOptions, null);
8487
TestUtil.printLine("newA = " + newA);
8588

0 commit comments

Comments
 (0)