[
https://issues.apache.org/jira/browse/IGNITE-28831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anton Vinogradov resolved IGNITE-28831.
---------------------------------------
Resolution: Won't Fix
Resolving as Not A Problem after investigation — the NPE described here does
not reproduce.
The premise is incorrect for the cases this processor actually sees. The claim
is that javac renders a type-use annotation inline, before the simple name of a
qualified type (e.g. "java.util.@NotNull Collection"), making
IDTOSerializerGenerator.className() drop the package qualifier. In practice it
does not.
Instrumenting className() shows the real TypeMirror.toString() for
@NotNull/@Nullable collection fields (e.g. BaselineNode.addrs) is:
@org.jetbrains.annotations.NotNull
java.util.Collection<...ResolvedAddresses>
The annotation is rendered leading (before the whole type), not inline. The
existing substring(indexOf(' ') + 1) heuristic strips it correctly and yields
"java.util.Collection", so the COLL_IMPL lookup succeeds and no NPE occurs.
Verified on modules/core: the original className() and the proposed change both
generate the full set of 457 serializers, including a correct
BaselineNodeSerializer (import java.util.ArrayList; ... obj.addrs = new
ArrayList<>();). Output is byte-for-byte identical with and without the change.
The inline form "pkg.@Anno SimpleName" only occurs for annotations on nested
member types ("Outer.@Anno Inner"); no IDTO field annotates a nested type, so
this failure mode cannot arise with the current DTOs.
No code change is needed. Closing as Not A Problem.
> DTO serializer code generator throws NPE on fields with type-use annotations
> (@Nullable/@NotNull) on qualified types
> --------------------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-28831
> URL: https://issues.apache.org/jira/browse/IGNITE-28831
> Project: Ignite
> Issue Type: Task
> Reporter: Anton Vinogradov
> Assignee: Anton Vinogradov
> Priority: Major
> Fix For: 2.19
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> h2. Problem
> {\{IgniteDataTransferObjectProcessor}} throws a \{{NullPointerException}}
> during annotation
> processing, which breaks compilation of \{{modules/core}} from source.
> Reproduce from a clean master:
> {code}
> mvn -o -q -pl modules/core -am test-compile -DskipTests -Dcheckstyle.skip=true
> {code}
> First (root-cause) errors:
> {noformat}
> BaselineNode.java: Failed to generate a dto serializer: Cannot invoke
> "String.lastIndexOf(int)" because "fqn" is null
> IdleVerifyResult.java: Failed to generate a dto serializer: Cannot invoke
> "String.lastIndexOf(int)" because "fqn" is null
> .../DurableBackgroundCleanupIndexTreeTaskV2Serializer.java:[26,14] '.'
> expected
> .../SnapshotPartitionsVerifyResultSerializer.java:[20,24] '.' expected
> .../VisorTaskResultSerializer.java:[26,17] '.' expected
> {noformat}
> The subsequent cascade of \{{cannot find symbol: class *ViewWalker}} errors
> is a side effect:
> the processor's exception aborts the annotation-processing round, so the
> output of the separate
> {\{SystemViewRowAttributeWalkerProcessor}} never gets compiled.
> h2. Root cause
> {\{IDTOSerializerGenerator.className(TypeMirror)}} strips everything before
> the first space in order
> to drop a *leading* type-use annotation (e.g. \{{@NotNull
> java.util.Collection}}). But the compiler
> renders a type-use annotation \{*}inline, right before the simple name\{*} of
> a qualified type:
> {code}
> [email protected] Collection<...>
> {code}
> The first-space heuristic then discards the \{{java.util.}} qualifier and
> returns only \{{Collection}},
> which causes:
> # \{{COLL_IMPL.get("Collection")}} returns \{{null}} -> NPE in
> \{{simpleName()}} for fields like
> {\{BaselineNode.addrs}} (\{{@NotNull Collection<ResolvedAddresses>}}) and
> {\{IdleVerifyResult.txHashConflicts}} (\{{@Nullable
> List<List<TransactionsHashRecord>>}}).
> # Malformed \{{import String;}} / \{{import Exception;}} / \{{import
> IdleVerifyResult;}} emitted into the
> generated serializers for \{{DurableBackgroundCleanupIndexTreeTaskV2}},
> \{{SnapshotPartitionsVerifyResult}}
> and \{{VisorTaskResult}} (the \{{'.' expected}} compile errors) — for
> \{{@Nullable}}-annotated fields.
> h2. Fix
> Strip type-use annotations wherever they occur (preserving the package
> qualifier) instead of using the
> first-space heuristic. The fix is confined to the codegen module; DTO classes
> are not touched.
> h2. Verification
> {\{mvn -o -q -pl modules/core -am test-compile -DskipTests
> -Dcheckstyle.skip=true}} completes with
> BUILD SUCCESS, and the serializers for \{{BaselineNode}},
> \{{IdleVerifyResult}},
> {\{DurableBackgroundCleanupIndexTreeTaskV2}},
> \{{SnapshotPartitionsVerifyResult}}, \{{VisorTaskResult}}
> are generated and compile.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)