Apache Avro ThreadLocal objects are lingering on Tomcat deployment

We are using Apache Avro as the JSON interface between our Python application and some third party Java libraries that we run on the Tomcat service. We decided to simply extend the org.apache.avro.ipc.ResponderServlet class to implement our own servlet. The servlet is really simple as it creates the superclass of the ResponderServlet class in the constructor and overrides the init () and destroy () methods to do some storage work for the third party libraries that we run in the servlet.

If Tomcat does not deploy our webapp, we can see that some SEVERE errors are warning about memory leaks related to ThreadLocal.

SEVERE: The web application [/hotwire] created a ThreadLocal with key of type [org.apache.avro.Schema$3] (value [org.apache.avro.Schema$3@4464784f]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jan 24, 2013 2:19:36 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/hotwire] created a ThreadLocal with key of type [org.apache.avro.generic.GenericDatumReader$1] (value [org.apache.avro.generic.GenericDatumReader$1@2016ad9d]) and a value of type [org.apache.avro.util.WeakIdentityHashMap] (value [org.apache.avro.util.WeakIdentityHashMap@30e02ee0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

      

We're probably doing something naive because we haven't been able to find any help anywhere on the internet for this scenario. However, we hope that someone can tell us where we are going wrong.

Check out our servlet here.

public class HotWire extends ResponderServlet{
    public HotWire() throws IOException
    {
              super(new SpecificResponder(Engine.class, new EngineImpl()));
    }

    @Override
        public void init() {
        try {
         super.init();
                 try {
                      init_engine();                
                      } catch (EngineInitException e) {
                      e.printStackTrace();
                      }
            } catch (ServletException e) {
                 e.printStackTrace();
            }
        }

        @Override
        public void destroy() {
            super.destroy();
            shutdown_engine();
        }

        public static class EngineImpl implements EngineInterface  {
            public Boolean create(Parameters message) {
                Boolean status = null;
                try {
                    status = engine.create_object(message);
                } catch (SemanticException | IOException e) {
                    e.printStackTrace();
                }
                return status;
            }

}

      

+3


source to share





All Articles