Program: 84570
Project: 84570
Buggy source:
/** 
 * Runs through the advice and extension points and removes from api <code>isShuttingDown</code> should only be true when openmrs is stopping modules because it is shutting down. When normally stopping a module, use stopModule(Module) (or leave value as false). This property controls whether the globalproperty is set for startup/shutdown. Also calls mod.Activator.shutdown()
 * @param mod module to stop
 * @param isShuttingDown
 */
@SuppressWarnings("String_Node_Str") public static void stopModule(Module mod,boolean isShuttingDown){
  if (mod != null) {
    String moduleId=mod.getModuleId();
    String modulePackage=mod.getPackageName();
    List<Module> startedModulesCopy=new ArrayList<Module>();
    startedModulesCopy.addAll(getStartedModules());
    for (    Module dependentModule : startedModulesCopy) {
      if (!dependentModule.equals(mod) && dependentModule.getRequiredModules().contains(modulePackage))       stopModule(dependentModule,isShuttingDown);
    }
    getStartedModulesMap().remove(moduleId);
    if (isShuttingDown == false && !Context.isRefreshingContext()) {
      try {
        Context.addProxyPrivilege("String_Node_Str");
        AdministrationService as=Context.getAdministrationService();
        GlobalProperty gp=new GlobalProperty(moduleId + "String_Node_Str","String_Node_Str",getGlobalPropertyStartedDescription(moduleId));
        as.saveGlobalProperty(gp);
      }
  finally {
        Context.removeProxyPrivilege("String_Node_Str");
      }
    }
    if (getModuleClassLoaderMap().containsKey(mod)) {
      log.debug("String_Node_Str");
      try {
        for (        AdvicePoint advice : mod.getAdvicePoints()) {
          Class cls=null;
          try {
            cls=Class.forName(advice.getPoint());
            Object aopObject=advice.getClassInstance();
            if (Advisor.class.isInstance(aopObject)) {
              log.debug("String_Node_Str" + aopObject.getClass());
              Context.removeAdvisor(cls,(Advisor)aopObject);
            }
 else {
              log.debug("String_Node_Str" + aopObject.getClass());
              Context.removeAdvice(cls,(Advice)aopObject);
            }
          }
 catch (          ClassNotFoundException e) {
            log.warn("String_Node_Str" + advice.getPoint(),e);
          }
        }
      }
 catch (      Throwable t) {
        log.warn("String_Node_Str" + moduleId,t);
      }
      try {
        for (        Extension ext : mod.getExtensions()) {
          String extId=ext.getExtensionId();
          try {
            List<Extension> tmpExtensions=getExtensions(extId);
            if (tmpExtensions == null)             tmpExtensions=new Vector<Extension>();
            tmpExtensions.remove(ext);
            getExtensionMap().put(extId,tmpExtensions);
          }
 catch (          Exception exterror) {
            log.warn("String_Node_Str" + ext,exterror);
          }
        }
      }
 catch (      Throwable t) {
        log.warn("String_Node_Str" + moduleId,t);
      }
    }
    try {
      mod.getActivator().shutdown();
    }
 catch (    ModuleException me) {
      log.debug("String_Node_Str",me);
    }
catch (    Throwable t) {
      log.warn("String_Node_Str",t);
    }
    ModuleClassLoader cl=removeClassLoader(mod);
    if (cl != null) {
      cl.dispose();
      cl=null;
      File folder=OpenmrsClassLoader.getLibCacheFolder();
      File tmpModuleDir=new File(folder,moduleId);
      try {
        System.gc();
        OpenmrsUtil.deleteDirectory(tmpModuleDir);
      }
 catch (      IOException e) {
        log.warn("String_Node_Str" + moduleId);
      }
    }
    System.gc();
  }
}

Fixed version (ground truth):
/** 
 * Runs through the advice and extension points and removes from api <code>isShuttingDown</code> should only be true when openmrs is stopping modules because it is shutting down. When normally stopping a module, use stopModule(Module) (or leave value as false). This property controls whether the globalproperty is set for startup/shutdown. Also calls mod.Activator.shutdown()
 * @param mod module to stop
 * @param isShuttingDown
 */
@SuppressWarnings("String_Node_Str") public static void stopModule(Module mod,boolean isShuttingDown){
  if (mod != null) {
    String moduleId=mod.getModuleId();
    String modulePackage=mod.getPackageName();
    List<Module> startedModulesCopy=new ArrayList<Module>();
    startedModulesCopy.addAll(getStartedModules());
    for (    Module dependentModule : startedModulesCopy) {
      if (!dependentModule.equals(mod) && dependentModule.getRequiredModules().contains(modulePackage))       stopModule(dependentModule,isShuttingDown);
    }
    getStartedModulesMap().remove(moduleId);
    if (isShuttingDown == false && !Context.isRefreshingContext()) {
      try {
        Context.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
        AdministrationService as=Context.getAdministrationService();
        GlobalProperty gp=new GlobalProperty(moduleId + "String_Node_Str","String_Node_Str",getGlobalPropertyStartedDescription(moduleId));
        as.saveGlobalProperty(gp);
      }
  finally {
        Context.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);
      }
    }
    if (getModuleClassLoaderMap().containsKey(mod)) {
      log.debug("String_Node_Str");
      try {
        for (        AdvicePoint advice : mod.getAdvicePoints()) {
          Class cls=null;
          try {
            cls=Class.forName(advice.getPoint());
            Object aopObject=advice.getClassInstance();
            if (Advisor.class.isInstance(aopObject)) {
              log.debug("String_Node_Str" + aopObject.getClass());
              Context.removeAdvisor(cls,(Advisor)aopObject);
            }
 else {
              log.debug("String_Node_Str" + aopObject.getClass());
              Context.removeAdvice(cls,(Advice)aopObject);
            }
          }
 catch (          ClassNotFoundException e) {
            log.warn("String_Node_Str" + advice.getPoint(),e);
          }
        }
      }
 catch (      Throwable t) {
        log.warn("String_Node_Str" + moduleId,t);
      }
      try {
        for (        Extension ext : mod.getExtensions()) {
          String extId=ext.getExtensionId();
          try {
            List<Extension> tmpExtensions=getExtensions(extId);
            if (tmpExtensions == null)             tmpExtensions=new Vector<Extension>();
            tmpExtensions.remove(ext);
            getExtensionMap().put(extId,tmpExtensions);
          }
 catch (          Exception exterror) {
            log.warn("String_Node_Str" + ext,exterror);
          }
        }
      }
 catch (      Throwable t) {
        log.warn("String_Node_Str" + moduleId,t);
      }
    }
    try {
      mod.getActivator().shutdown();
    }
 catch (    ModuleException me) {
      log.debug("String_Node_Str",me);
    }
catch (    Throwable t) {
      log.warn("String_Node_Str",t);
    }
    ModuleClassLoader cl=removeClassLoader(mod);
    if (cl != null) {
      cl.dispose();
      cl=null;
      File folder=OpenmrsClassLoader.getLibCacheFolder();
      File tmpModuleDir=new File(folder,moduleId);
      try {
        System.gc();
        OpenmrsUtil.deleteDirectory(tmpModuleDir);
      }
 catch (      IOException e) {
        log.warn("String_Node_Str" + moduleId);
      }
    }
    System.gc();
  }
}