-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[maven] Classloader not being closed after PMD run #2163
Comments
Inside PMD - meaning, when running PMD from commandline or via the provided ant task, there is no problem:
It seems, how the maven-pmd-plugin calls PMD, the classloader is not closed, though. I'll keep this issue open, maybe we can improve the API, so that such situation is not even possible. The API caller shouldn't have to deal with that problem. There might be a similar problem for the https://github.com/pmd/pmd-eclipse-plugin. See also: |
This is still open - we still use a classloader via PMDConfiguration, which needs to be closed. This is not a problem, as long as PMD is used as described in https://pmd.github.io/latest/pmd_userdocs_tools_java_api.html. But if PMD is used differently, or a PMDConfiguration is created without calling PmdAnalysis, then one might still run into this issue. |
@adangel so if I understand correctly, this lies 100% on the Maven plugin, that is tightly bound to PMD using it's internal APIs (part of the reason why the Do you want to keep it here? or do you have a corresponding issue on the Maven plugin's JIRA? |
The closing part has been fixed in m-pmd-p 3.14.0 already. The only thing left here is:
That's an API problem: Whoever calls PMDConfiguration#prependAuxClasspath might create an Classloader, that might not be closed. Right now, when calling PMD via PmdAnalysis, the classloader is closed when PmdAnalysis is closed. So, it should not be a problem anymore, if PmdAnalysis is closed. However, I find it still surprising, that PMDConfiguration manages a classloader instead of a classpath... Two things, I'd suggest:
|
Affects PMD Version:
Unknown: Definitely 6.18.0+
Rule:
Description:
Classloader is being constructed in the configuration and then never closed.
https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java#L196
This classloader is then never closed and is being left to be close the open jar file references when finalized. This seems to be keeping open file references to jarfiles. (Also duplicating them across threads).
Code Sample demonstrating the issue:
Example of classloader that isn't closed:
maven-pmd-plugin
Running PMD through: [Maven]
The text was updated successfully, but these errors were encountered: