Changeset 6636


Ignore:
Timestamp:
Dec 3, 2014, 9:55:44 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1894: BASE is unloading JAR files too often

Deprecating JarClassLoader.unload since forcing an unload will trigger the problem if not all references are updated at the same time. This can only be ensured by the extensions installation wizard so it should all be handled from there via the autoUnload parameter.

As a consequence, the possibility to manually unload plug-ins from the web gui has been removed.

Location:
branches/3.3-stable
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/core/net/sf/basedb/core/PluginDefinition.java

    r6435 r6636  
    12651265      else
    12661266      {
    1267         if (unloadBefore) JarClassLoader.unload(jarPath);
    1268         ClassLoader cl = JarClassLoader.getInstance(jarPath, Application.autoUnloadPlugins());
     1267        ClassLoader cl = JarClassLoader.getInstance(jarPath, unloadBefore || Application.autoUnloadPlugins());
    12691268        c = ClassUtil.checkAndLoadClass(cl, className, true, Plugin.class);
    12701269      }
  • branches/3.3-stable/src/core/net/sf/basedb/core/PluginType.java

    r6127 r6636  
    325325      else
    326326      {
    327         JarClassLoader.unload(jarPath);
    328         ClassLoader cl = JarClassLoader.getInstance(jarPath, Application.autoUnloadPlugins());
     327        ClassLoader cl = JarClassLoader.getInstance(jarPath, true);
    329328        c = cl.loadClass(interfaceName);
    330329      }
  • branches/3.3-stable/src/core/net/sf/basedb/util/JarClassLoader.java

    r6444 r6636  
    157157   
    158158    @param jarPath The path to the JAR file
    159   */
     159    @deprecated In 3.3.4, use {@ #newInstance(String)} or {@link #getInstance(String, boolean)} with autoUnload=true instead
     160  */
     161  @Deprecated
    160162  public static final void unload(String jarPath)
    161163  {
  • branches/3.3-stable/src/test/TestJarClassLoader.java

    r5610 r6636  
    4949    test_load("JarPlugin.jar", "affymetrix.calvin.exception.CalvinException", false, true);
    5050    test_resource("JarPlugin.jar", "org/hibernate/hibernate-configuration-3.0.dtd", false, false);
    51     test_unload("JarPlugin.jar");
    5251    test_load("JarPlugin.jar", "affymetrix.calvin.exception.CalvinException", true, false);
    5352    test_resource("JarPlugin.jar", "org/hibernate/hibernate-configuration-3.0.dtd", true, false);
     
    119118
    120119 
    121   static void test_unload(String jarPath)
    122   {
    123     try
    124     {
    125       JarClassLoader.unload(jarPath);
    126       if (JarClassLoader.exists(jarPath))
    127       {
    128         throw new Exception("Class loader for '"+jarPath+"' was not unloaded.");
    129       }
    130       write("--Unload class loader OK");
    131     }
    132     catch (Throwable ex)
    133     {
    134       write("--Unload class loader FAILED");
    135       ex.printStackTrace();
    136       ok = false;
    137     }
    138   }
    139  
    140120  static void write(String message)
    141121  {
  • branches/3.3-stable/www/admin/pluginconfigurations/index.jsp

    r6400 r6636  
    348348    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
    349349  }
    350   else if ("UnloadItems".equals(cmd))
    351   {
    352     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    353     dc = sc.newDbControl();
    354     for (int id : cc.getSelected())
    355     {
    356       PluginDefinition pd = PluginDefinition.getById(dc, id);
    357       if (pd.getJarPath() != null)
    358       {
    359         JarClassLoader.unload(pd.getJarPath());
    360       }
    361     }
    362     dc.close();
    363     redirect = listPage;
    364   }
    365   else if ("UnloadItem".equals(cmd))
    366   {
    367     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    368     dc = sc.newDbControl();
    369     PluginDefinition pd = PluginDefinition.getById(dc, cc.getId());
    370     if (pd.getJarPath() != null)
    371     {
    372       JarClassLoader.unload(pd.getJarPath());
    373     }
    374     dc.close();
    375     redirect = viewPage;
    376   }
    377350  else
    378351  {
  • branches/3.3-stable/www/admin/plugindefinitions/index.jsp

    r6305 r6636  
    456456    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
    457457  }
    458   else if ("UnloadItems".equals(cmd))
    459   {
    460     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    461     dc = sc.newDbControl();
    462     for (int id : cc.getSelected())
    463     {
    464       PluginDefinition pd = PluginDefinition.getById(dc, id);
    465       if (pd.getJarPath() != null)
    466       {
    467         JarClassLoader.unload(pd.getJarPath());
    468       }
    469     }
    470     dc.close();
    471     redirect = listPage;
    472   }
    473   else if ("UnloadItem".equals(cmd))
    474   {
    475     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    476     dc = sc.newDbControl();
    477     PluginDefinition pd = PluginDefinition.getById(dc, cc.getId());
    478     if (pd.getJarPath() != null)
    479     {
    480       JarClassLoader.unload(pd.getJarPath());
    481     }
    482     dc.close();
    483     redirect = viewPage;
    484   }
    485458  else
    486459  {
  • branches/3.3-stable/www/admin/plugindefinitions/list_plugins.jsp

    r6289 r6636  
    468468            tooltip="Run a plugin"
    469469            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
    470           />
    471           <tbl:button
    472             id="btnUnload"
    473             title="Unload"
    474             tooltip="Unload plugins"
    475470          />
    476471          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>"
  • branches/3.3-stable/www/admin/plugindefinitions/plugins.js

    r6592 r6636  
    116116      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    117117      Buttons.addClickHandler('btnNewConfiguration', plugins.newConfiguration, attributes);
    118       Buttons.addClickHandler('btnUnload', plugins.unloadPlugin, attributes);
    119118      Buttons.addClickHandler('btnToggleDisabled', plugins.toggleDisabled);
    120119
     
    138137      Buttons.addClickHandler('btnImport', Buttons.runListPlugin, tableAttributes);
    139138      Buttons.addClickHandler('btnRunPlugin', Buttons.runListPlugin, tableAttributes);
    140       Buttons.addClickHandler('btnUnload', plugins.unloadSelected);
    141139     
    142140      Buttons.addClickHandler('close', App.closeWindow);
     
    163161  }
    164162
    165   plugins.unloadSelected = function()
    166   {
    167     Table.submitSelected('plugins', 'UnloadItems');
    168   }
    169  
    170   plugins.unloadPlugin = function()
    171   {
    172     var pluginId = Data.get('page-data', 'item-id');
    173     var iframe = Data.get('page-data', 'iframe');
    174    
    175     var url = 'index.jsp?ID='+App.getSessionId();
    176     url += '&cmd=UnloadItem';
    177     url += '&item_id='+pluginId + '&iframe='+iframe;
    178     location.replace(url);
    179   }
    180  
    181163  plugins.newConfiguration = function(event)
    182164  {
  • branches/3.3-stable/www/admin/plugindefinitions/view_plugin.jsp

    r6592 r6636  
    272272              tooltip="Run a plugin"
    273273              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
    274             />
    275             <tbl:button
    276               id="btnUnload"
    277               title="Unload"
    278               tooltip="<%=loaded && !internal ? "Unload the code for this plugin" : "The code for this plugin has not yet been loaded" %>"
    279               visible="<%=loaded && !internal%>"
    280274            />
    281275            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>"
Note: See TracChangeset for help on using the changeset viewer.