You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[maven] Classloader not being closed after PMD run #2163
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).
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.
@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 pmd-compat6 module was needed); with nothing to do on this end.
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.
As #4949 / #4899 showed, the classloader is definitely closed in maven-pmd-plugin still today. So, there is no problem in this regard anymore.
The only thing left here is:
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.
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:
document in the API for PMDConfiguration#prependAuxClasspath and the related methods (setClassloader, getClassloader) the implications of not properly closing the classloader.
deprecate setClassloader/getClassloader, refactor PMDConfiguration to deal with a list of strings (a "classpath") and create the classloader only later, fully internally and not exposing this classloader in any way.
Activity
adangel commentedon Feb 4, 2020
Inside PMD - meaning, when running PMD from commandline or via the provided ant task, there is no problem:
pmd/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java
Line 287 in d115ca5
pmd/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java
Line 265 in d115ca5
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:
[-][java] Classloader not being closed after PMD run.[/-][+][java] Classloader not being closed after PMD run[/+]adangel commentedon Jan 13, 2023
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.
[-][java] Classloader not being closed after PMD run[/-][+][core] Classloader not being closed after PMD run[/+][-][core] Classloader not being closed after PMD run[/-][+][maven] Classloader not being closed after PMD run[/+]jsotuyod commentedon Apr 3, 2024
@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
pmd-compat6module was needed); with nothing to do on this end.Do you want to keep it here? or do you have a corresponding issue on the Maven plugin's JIRA?
adangel commentedon Apr 11, 2024
The closing part has been fixed in m-pmd-p 3.14.0 already.
As #4949 / #4899 showed, the classloader is definitely closed in maven-pmd-plugin still today. So, there is no problem in this regard anymore.
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:
adangel commentedon Apr 11, 2024
Closing this one now in favor of #4952 and #4953.