fix: convert anonymous classes to named inner classes for Jackson serialization - #20070
fix: convert anonymous classes to named inner classes for Jackson serialization#20070zhang-arvin wants to merge 1 commit into
Conversation
…ialization Anonymous subclasses in Long/Double/Float First/Last aggregator factories were being serialized as LongLastAggregatorFactory$1 instead of the registered @JsonTypeName. This caused 'Could not resolve type id' errors during Jackson deserialization. Converted all NIL_AGGREGATOR and NIL_BUFFER_AGGREGATOR anonymous classes to private static named inner classes in all 6 factory classes. Closes apache#7599
FrankChen021
left a comment
There was a problem hiding this comment.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 1 |
| P2 | 2 |
| P3 | 0 |
| Total | 3 |
Reviewed 6 of 6 changed files.
The review found one unresolved Jackson-type risk, two remaining anonymous NIL paths, and missing serialization regression coverage.
This is an automated review by Codex GPT-5.6-Luna(max)
| ) | ||
| private static final Aggregator NIL_AGGREGATOR = new NilLongLastAggregator(); | ||
|
|
||
| private static class NilLongLastAggregator extends LongLastAggregator |
There was a problem hiding this comment.
[P1] Named NIL class does not fix the Jackson type ID
NilLongLastAggregator extends LongLastAggregator, not AggregatorFactory. The Jackson subtype registration applies to the factory, while the static NIL field is not serialized. If the NIL object is serialized directly, it still has no registered longLast type, so the change does not demonstrably fix the reported serialization failure.
| NilColumnValueSelector.instance(), | ||
| false | ||
| ) | ||
| private static final Aggregator NIL_AGGREGATOR = new NilDoubleFirstAggregator(); |
There was a problem hiding this comment.
[P2] Anonymous NIL implementations remain elsewhere
The conversion is incomplete: anonymous NIL implementations remain in StringFirstAggregatorFactory, StringLastAggregatorFactory, and the numeric Any factories. The same class-name serialization risk therefore remains for those absent-column paths if runtime aggregators are serialized.
| NilColumnValueSelector.instance(), | ||
| false | ||
| ) | ||
| private static final Aggregator NIL_AGGREGATOR = new NilLongLastAggregator(); |
There was a problem hiding this comment.
[P2] No serialization regression test covers the fix
Existing serde tests only deserialize hard-coded factory JSON; they do not serialize a factory or exercise NIL factorization. Add round-trip coverage for the affected types and the missing-column branch.
Purpose
Fix Jackson serialization failure for Long/Double/Float First/Last aggregator factories.
Anonymous inner classes used as
NIL_AGGREGATORandNIL_BUFFER_AGGREGATORwere being serializedas
LongLastAggregatorFactory$1instead of the registered@JsonTypeName. This caused the error:Changes
Converted all anonymous subclasses of
AggregatorandBufferAggregatorin the following 6 factoryclasses to private static named inner classes:
LongLastAggregatorFactoryDoubleLastAggregatorFactoryFloatLastAggregatorFactoryLongFirstAggregatorFactoryDoubleFirstAggregatorFactoryFloatFirstAggregatorFactoryEach factory previously had two anonymous classes (
NIL_AGGREGATORandNIL_BUFFER_AGGREGATOR)that overrode
aggregate()to be no-ops. These are now named inner classes (e.g.,NilLongLastAggregator,NilLongLastBufferAggregator) that correctly extend their parent classeswith explicit constructors.
Closes #7599