commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <>
Subject [jira] [Created] (JEXL-244) Webapp classloader memory leaks
Date Tue, 31 Oct 2017 09:03:01 GMT
Dmitri Blinov created JEXL-244:

             Summary: Webapp classloader memory leaks
                 Key: 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

I have spotted that the following constructions, like for example in
    public static final Object TRY_FAILED = new Object() {
        public String toString() {
            return "tryExecute failed";
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 like
    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>() {...


The issue is easily resolved if for example the following pattern is followed

    public static class FailObject extends Object {
        public String toString() {
            return "tryExecute failed";

    public static final Object TRY_FAILED = new FailObject();

This message was sent by Atlassian JIRA

View raw message