checkstyle / checkstyle/contribution
OutOfMemoryError in postProcessCheckstyleReport() for large checkstyle-result.xml files
- Dominant language
- Java
- Stars
- 57
- Forks
- 168
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
detected at: https://github.com/checkstyle/checkstyle/pull/19043#issuecomment-3986332943
`postProcessCheckstyleReport()` in diff.groovy reads the entire checkstyle-result.xml into a single Java String ([diff.groovy](https://github.com/checkstyle/contribution/blob/1392c4a4bbb95f53acb72518ba3a4173732e3e30/checkstyle-tester/diff.groovy#L708-L717))
```
def content = checkstyleResultFile.text
content = content.replace(oldPath, newPath)
checkstyleResultFile.text = content
```
For large projects (e.g., openjdk25 with full google_checks.xml), the XML file exceeds the hard JVM String size limit of 1,073,741,823 characters introduced in JDK 9 ([JDK-8190429](https://bugs.openjdk.org/browse/JDK-8190429)).
Error:[(link)](https://github.com/checkstyle/checkstyle/actions/runs/22553094943/job/65326166130#step:10:4346)
`java.lang.OutOfMemoryError: UTF16 String size is 1074003966, should be less than 1073741823`
Fix:
Replace the whole-file read with line-by-line streaming
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.