PluginManager: try/catch Throwable all the plugin startup stuff

If you loaded an external plugin that throws LinkageErrors it could
cause the client not to start
This commit is contained in:
Max Weber
2020-02-13 09:55:19 -07:00
parent 9d908110b8
commit e7679a8700
2 changed files with 46 additions and 13 deletions

View File

@@ -305,7 +305,11 @@ public class ExternalPluginManager
});
}
}
catch (Exception e)
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable e)
{
log.warn("Unable to start or load external plugin \"{}\"", manifest.getInternalName(), e);
if (newPlugins != null)

View File

@@ -159,6 +159,8 @@ public class PluginManager
}
public Config getPluginConfigProxy(Plugin plugin)
{
try
{
final Injector injector = plugin.getInjector();
@@ -170,7 +172,15 @@ public class PluginManager
return (Config) injector.getInstance(key);
}
}
}
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable e)
{
log.warn("Unable to get plugin config", e);
}
return null;
}
@@ -202,12 +212,23 @@ public class PluginManager
}
public void loadDefaultPluginConfiguration(Collection<Plugin> plugins)
{
try
{
for (Object config : getPluginConfigProxies(plugins))
{
configManager.setDefaultConfiguration(config, false);
}
}
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{
log.warn("Unable to reset plugin configuration", ex);
}
}
public void startPlugins()
{
@@ -367,7 +388,11 @@ public class PluginManager
schedule(plugin);
eventBus.post(new PluginChanged(plugin, true));
}
catch (Exception ex)
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{
throw new PluginInstantiationException(ex);
}
@@ -440,9 +465,13 @@ public class PluginManager
Plugin plugin;
try
{
plugin = clazz.newInstance();
plugin = clazz.getDeclaredConstructor().newInstance();
}
catch (InstantiationException | IllegalAccessException ex)
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{
throw new PluginInstantiationException(ex);
}