Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ImportControlLoader does not close InputStream and leaks filehandles when xml is malformed #3962
I have been looking into this checkstyle plugin related gradle issue gradle/gradle#1416. One of the issues the original author has is a problem with the import-control.xml file remaining open after gradle has finished execution.
I have managed to replicate the issue on my Linux box using the provided project and checkstyle configuration.
I have tracked the problem to be in ImportControlLoader which opens an InputStream but not closes it in case there is a parse exception.
Setup project as described in gradle/gradle#1416
When checkstyle library fails to read import-control.xml for whatever reason it should not leave unclosed streams in the containing jvm.
I have tries applying a fix using a try-with-resources construct but I got stuck because it drops coverage in cobertura. I have researched this quite a bit cobertura/cobertura#289 but was unable to find a solution.