Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c015a7e8b3c1
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9fe81003b34f
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 24, 2013

  1. Fixing DispatcherServlet memory leak when refreshing spring: Investigate

    possible memory leak in 1.9.0 or one of its bundled modules. -
    TRUNK-3440
    dkayiwa committed Apr 24, 2013
    Copy the full SHA
    eed7b28 View commit details
  2. Merge pull request #286 from dkayiwa/TRUNK-3440

    Fixing DispatcherServlet memory leak when refreshing spring: Investigate possible memory leak in 1.9.0 or one of its bundled modules. - TRUNK-3440
    dkayiwa committed Apr 24, 2013
    Copy the full SHA
    9fe8100 View commit details
Showing with 20 additions and 2 deletions.
  1. +4 −0 web/src/main/java/org/openmrs/module/web/WebModuleUtil.java
  2. +16 −2 web/src/main/java/org/openmrs/web/DispatcherServlet.java
4 changes: 4 additions & 0 deletions web/src/main/java/org/openmrs/module/web/WebModuleUtil.java
Original file line number Diff line number Diff line change
@@ -843,6 +843,10 @@ public static XmlWebApplicationContext refreshWAC(ServletContext servletContext,
if (log.isDebugEnabled())
log.debug("Refreshing web applciation Context of class: " + wac.getClass().getName());

if (dispatcherServlet != null) {
dispatcherServlet.stopAndCloseApplicationContext();
}

XmlWebApplicationContext newAppContext = (XmlWebApplicationContext) ModuleUtil.refreshApplicationContext(wac,
isOpenmrsStartup, startedModule);

18 changes: 16 additions & 2 deletions web/src/main/java/org/openmrs/web/DispatcherServlet.java
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
import org.openmrs.web.filter.initialization.InitializationFilter;
import org.openmrs.web.filter.update.UpdateFilter;
import org.springframework.beans.BeansException;
import org.springframework.web.context.support.XmlWebApplicationContext;

/**
* This class is only used to get access to the DispatcherServlet. <br/>
@@ -68,9 +69,9 @@ protected void initFrameworkServlet() throws ServletException, BeansException {
public void reInitFrameworkServlet() throws ServletException {
log.debug("Framework being REinitialized");
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
((XmlWebApplicationContext)getWebApplicationContext()).setClassLoader(OpenmrsClassLoader.getInstance());

// reset bean info and framework servlet
init();
refresh();

// the spring context gets reset by the framework servlet, so we need to
// reload the advice points that were lost when refreshing Spring
@@ -95,4 +96,17 @@ public void init(ServletConfig config) throws ServletException {
}
}

/**
* Stops and closes the application context created by this dispatcher servlet.
*/
public void stopAndCloseApplicationContext() {
try {
XmlWebApplicationContext ctx = (XmlWebApplicationContext)getWebApplicationContext();
ctx.stop();
ctx.close();
}
catch (Exception e) {
log.error("Exception while stopping and closing dispatcherServlet context: ", e);
}
}
}