Commit 3b2df40
authored
fix: prevent CPU runaway in HttpNodesStatsAction JSON parsing (#18)
* fix: prevent CPU runaway in HttpNodesStatsAction JSON parsing (#18)
Three parse methods introduced in #14 were missing `parser.nextToken()`
before calling `consumeObject()` or sub-parse methods when the current
token was START_OBJECT. This caused `consumeObject()` to consume tokens
beyond its scope (including sibling fields), corrupting the parser state
and eventually leading to an infinite loop at EOF — spinning all eshttp
threads at 100% CPU each.
Fixes:
- Add `parser.nextToken()` in parseSearchBackpressureStats,
parseTaskCancellationStats, and parseSearchPipelineStats
- Add null-token (EOF) guards in fromXContent, parseNodes,
parseNodeStats, and consumeObject to throw IOException instead of
spinning
- Add START_ARRAY handling in consumeObject
- Remove orphan `new ArrayList<>()` in parseNodeStats
Tests: add 61 unit tests covering token boundary verification, field
ordering, multiple nodes, partial sub-fields, deeply nested structures,
truncated JSON, and concurrent parsing.
* fix: handle initial parser state and reduce test log output
- Fix fromXContent to call nextToken() when parser is uninitialized
(currentToken is null before first read), preventing false EOF
detection that broke integration tests
- Change test log level from ALL to INFO in 5 integration test classes
to reduce output from ~30k lines to ~1k lines for GitHub Actions1 parent 005ad1c commit 3b2df40
7 files changed
Lines changed: 1064 additions & 11 deletions
File tree
- src
- main/java/org/codelibs/fesen/client/action
- test/java/org/codelibs/fesen/client
- action
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
160 | 163 | | |
161 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
| |||
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
184 | 193 | | |
185 | 194 | | |
186 | 195 | | |
| |||
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
196 | | - | |
197 | 205 | | |
198 | 206 | | |
199 | 207 | | |
| |||
230 | 238 | | |
231 | 239 | | |
232 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
233 | 244 | | |
234 | 245 | | |
235 | 246 | | |
| |||
399 | 410 | | |
400 | 411 | | |
401 | 412 | | |
| 413 | + | |
402 | 414 | | |
403 | 415 | | |
404 | 416 | | |
| |||
544 | 556 | | |
545 | 557 | | |
546 | 558 | | |
| 559 | + | |
547 | 560 | | |
548 | 561 | | |
549 | 562 | | |
| |||
606 | 619 | | |
607 | 620 | | |
608 | 621 | | |
| 622 | + | |
609 | 623 | | |
610 | 624 | | |
611 | 625 | | |
| |||
2322 | 2336 | | |
2323 | 2337 | | |
2324 | 2338 | | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
2325 | 2342 | | |
2326 | 2343 | | |
2327 | 2344 | | |
| 2345 | + | |
| 2346 | + | |
2328 | 2347 | | |
2329 | 2348 | | |
2330 | 2349 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
0 commit comments