contribution icon indicating copy to clipboard operation
contribution copied to clipboard

OutOfMemoryError in postProcessCheckstyleReport() for large checkstyle-result.xml files

Open vivek-0509 opened this issue 8 months ago • 2 comments

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)

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).

Error:(link) java.lang.OutOfMemoryError: UTF16 String size is 1074003966, should be less than 1073741823

Fix: Replace the whole-file read with line-by-line streaming

vivek-0509 avatar Mar 05 '26 11:03 vivek-0509

@vivek-0509 , please help us to fix this issue.

romani avatar Mar 09 '26 01:03 romani

Sure will open PR for this

vivek-0509 avatar Mar 11 '26 09:03 vivek-0509