You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (JIRA)" <ji...@apache.org> on 2017/11/06 14:32:00 UTC

[jira] [Resolved] (JEXL-244) Webapp classloader memory leaks

     [ https://issues.apache.org/jira/browse/JEXL-244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro resolved JEXL-244.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 3.2

I'm respectfully skeptical that the leak you are reporting originates from a static inner class definition. I've been unable to find another occurence of such a problem (stack overflow, Google...).
Nevertheless, long standing working relationship grants benefits. :-)
Please report if this fixes things on your end.


Committed revision 1814413.
trunk/RELEASE-NOTES.txt
trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java
trunk/src/site/xdoc/changes.xml

> Webapp classloader memory leaks
> -------------------------------
>
>                 Key: JEXL-244
>                 URL: https://issues.apache.org/jira/browse/JEXL-244
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>         Environment: Inside J2EE container when Jexl library is included in the deployed .war file
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>             Fix For: 3.2
>
>
> I have spotted that the following constructions, like for example in JexlEngine.java
> {code}
>     public static final Object TRY_FAILED = new Object() {
>         @Override
>         public String toString() {
>             return "tryExecute failed";
>         }
>     };
> {code}
> are not garbage collected when web-app is reloaded and its classloader is released. This is because circular references are created when static class members are initialized with non-static inner/anonymous classes, which are holding implicit references to its enclosing class and thus to its static class type. There are other such examples in JexlEngine.java like
> {code}
>     protected static final java.lang.ThreadLocal<JexlContext.ThreadLocal> CONTEXT =             new java.lang.ThreadLocal<JexlContext.ThreadLocal>() {..
>     protected static final java.lang.ThreadLocal<JexlEngine> ENGINE =
>             new java.lang.ThreadLocal<JexlEngine>() {...
> {code}
> The issue is easily resolved if for example the following pattern is followed
> {code}
>     public static class FailObject extends Object {
>         @Override
>         public String toString() {
>             return "tryExecute failed";
>         }
>     }
>     public static final Object TRY_FAILED = new FailObject();
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)