Commit 75e9711
authored
Catch Throwable instead of Exception in KotlinParser and PythonParser (#6633)
* Catch StackOverflowError during Kotlin parsing
When parsing Kotlin files with deeply nested binary expressions (e.g., very
long string concatenations like "a" + "b" + "c" + ...), the Kotlin compiler's
FIR builder uses recursive descent which can exceed the JVM stack limit.
Changed the catch block from catching Exception to Throwable so that
StackOverflowError is caught and converted to a ParseError instead of
crashing the entire parsing process. This allows mass ingest to continue
processing other files when one file has this issue.
Added a test case that verifies deeply nested concatenations (2000+ operations)
result in a ParseError with StackOverflowError rather than crashing.
Fixes moderneinc/customer-requests#1694
* Also catch Throwable in PythonParser
Apply the same fix to PythonParser for consistency with all other parsers.1 parent ac001a4 commit 75e9711
3 files changed
Lines changed: 36 additions & 4 deletions
File tree
- rewrite-kotlin/src
- main/java/org/openrewrite/kotlin
- test/java/org/openrewrite/kotlin/tree
- rewrite-python/src/main/java/org/openrewrite/python
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
| 26 | + | |
23 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| |||
363 | 370 | | |
364 | 371 | | |
365 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
366 | 398 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
0 commit comments