Commit 1afea41
authored
fix(artifacts): a non-identifier view-dispatch target is not a dataflow variable, not a NullPointerException (#271)
ViewDispatches.resolve() ran the intra-procedural dataflow tier on
s.varName() unguarded, but Site.varName() returns null for any dispatch
target that is not a bare identifier -- a call expression like
`return String.valueOf(count);` inside a @RestController, as seen in
Robot Shop's shipping service (Controller.count()). Spring entrypoint
detection does not yet distinguish @RestController from @controller
(SpringEntrypointFinder.isEntrypointClass matches on
annotation.getNameAsString().contains("Controller")), so a REST
endpoint's String return is still gated into the view-name tier. That
null then reached DataflowTiers.intra and crashed in
IntraTier.reachingLiteral's `var.equals(edge.getVar())` at analysis
level >= 3. The very next tier down (interprocAll, L4) already guards
the identical null with `s.varName() == null ? null : ...` -- the L3
call was just missing the equivalent check.
Guarded `var == null` at the shared DataflowTiers.intra choke point
rather than only at the call site, so any future caller is protected
too. Added ViewNameDispatchTest.aNonIdentifierReturnExpressionStaysNonLiteralInsteadOfCrashing,
reproducing the exact Robot Shop shape, and
ViewDispatchDataflowTierTest.aCallExpressionTargetStaysNonLiteralInsteadOfCrashing
for the analogous dispatcher-call-site shape; both reproduce the NPE
on the old code and pass with the guard. Full suite: 606 tests, only
the Docker-only integration test unrun (no local Docker daemon).
Separately, @RestController return values are HTTP response bodies,
not Spring view names -- conflating them with @controller in
SpringEntrypointFinder is a real semantic gap, left untouched here
since it changes detection scope rather than just fixing the crash.1 parent 2c8deb1 commit 1afea41
3 files changed
Lines changed: 43 additions & 1 deletion
File tree
- src
- main/java/com/ibm/cldk/artifacts
- test/java/com/ibm/cldk/artifacts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
139 | 165 | | |
0 commit comments