incubator-directmemory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff MAURY (JIRA)" <>
Subject [jira] [Commented] (DIRECTMEMORY-84) Cache should not be a private DirectMemoryServlet field and initialized in init methods
Date Fri, 25 May 2012 22:57:23 GMT


Jeff MAURY commented on DIRECTMEMORY-84:

In fact, it is a little bit more subtle. The servlet spec guaranties that for a servlet definition,
there will be a single instance in a JVM (assumed it is not a SingleThreaded servlet, btw
SingleThreaded pattern is probably the sole PHP piece of code in the Java ecosystem). So I
think we don't need a ContextListener. But I have discovered that Tomcat is calling twice
the servlet init method !!! so we should probably protect against this double call (this seems
to be a very old Tomcat behavior). You can see in the Maven log that the servlet traces are
generated twice in a sequence and on the same thread.
> Cache should not be a private DirectMemoryServlet field and initialized in init methods
> ---------------------------------------------------------------------------------------
>                 Key: DIRECTMEMORY-84
>                 URL:
>             Project: Apache DirectMemory
>          Issue Type: Bug
>          Components: REST Server
>    Affects Versions: 0.6.0
>            Reporter: Jeff MAURY
>              Labels: REST, memory_leak
>             Fix For: 0.6.0
> The cache should not be a private DirectMemoryServlet field as there is nothing per the
Servlet spec that prevents the Servlet container to hold several instances of the same servlet
class. This may lead to memory consumption (as the cache may be created several times) and
unexpected behaviour (as one instance may put the object in ITS cache and another one try
to retrieve it and either no finding it or returning another object !!!!).
> It should be a Servlet context attribute and managed through the ServletContextListener
> As soon as I have completed the work i'm doing on the Closeable stuff, I'm will submit
the fix

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message