mandrean opened a new pull request, #3344:
URL: https://github.com/apache/fory/pull/3344

   ## Why?
   
   `SortedSetSerializer` unconditionally requires a `(Comparator)` constructor 
for all non-`TreeSet` subclasses. Java constructors are not inherited, so a 
`class ChildTreeSet extends TreeSet<String>` with only a no-arg constructor 
throws `UnsupportedOperationException` when registered with 
`SortedSetSerializer`.
   
   ## What does this PR do?
   
   Changes `SortedSetSerializer` to try the `(Comparator)` constructor first, 
and fall back to the no-arg constructor if not found. At deserialization time, 
uses whichever constructor is available. The no-arg fallback uses natural 
ordering, which is the common case for TreeSet subclasses.
   
   Only throws `UnsupportedOperationException` if neither constructor is found.
   
   ## Related issues
   
   - Fixes #3343
   
   ## Does this PR introduce any user-facing change?
   
   - [ ] Does this PR introduce any public API change?
   No. Existing behavior is preserved for classes that have a `(Comparator)` 
constructor. Classes that previously threw `UnsupportedOperationException` now 
work.
   
   - [ ] Does this PR introduce any binary protocol compatibility change?
   No. The write path is unchanged (size + comparator ref), and the read path 
still reads the same bytes in the same order. Only the post-read instantiation 
strategy differs (which constructor is used). Wire format is identical in both 
directions.
   
   ## Benchmark
   
   Not applicable; the constructor lookup happens once at serializer 
construction time, not per serialization. The runtime paths (`newCollection`) 
add a single null check (`if (comparatorConstructor != null)`) which is 
negligible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to