Properly log any Throwable on plugin class creation (#8897)

This commit is contained in:
Jake Potrebic 2023-02-23 01:36:45 -08:00
parent 4ad4252079
commit a59536946b

View File

@ -2292,7 +2292,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin)); + javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin));
+ } + }
+ +
+ } catch (Exception ex) { + } catch (Throwable ex) {
+ LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper + LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper
+ } + }
+ } + }
@ -2324,7 +2324,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin)); + javapluginsLoaded.add(new ProviderPair<>(file, loadedPlugin));
+ } + }
+ break; + break;
+ } catch (Exception ex) { + } catch (Throwable ex) {
+ LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper + LOGGER.log(Level.SEVERE, "Could not load '" + file.getSource() + "' in folder '" + file.getParentSource() + "'", ex); // Paper
+ } + }
+ } + }
@ -2382,7 +2382,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+@SuppressWarnings("UnstableApiUsage") +@SuppressWarnings("UnstableApiUsage")
+public class ModernPluginLoadingStrategy<T> implements ProviderLoadingStrategy<T> { +public class ModernPluginLoadingStrategy<T> implements ProviderLoadingStrategy<T> {
+ +
+ private static final Logger LOGGER = LogUtils.getLogger(); + private static final Logger LOGGER = LogUtils.getClassLogger();
+ private final ProviderConfiguration<T> configuration; + private final ProviderConfiguration<T> configuration;
+ +
+ public ModernPluginLoadingStrategy(ProviderConfiguration<T> onLoad) { + public ModernPluginLoadingStrategy(ProviderConfiguration<T> onLoad) {
@ -2489,7 +2489,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (this.configuration.load(retrievedProvider, instance)) { + if (this.configuration.load(retrievedProvider, instance)) {
+ loadedPlugins.add(new ProviderPair<>(retrievedProvider, instance)); + loadedPlugins.add(new ProviderPair<>(retrievedProvider, instance));
+ } + }
+ } catch (Exception ex) { + } catch (Throwable ex) {
+ LOGGER.error("Could not load plugin '%s' in folder '%s'".formatted(retrievedProvider.getFileName(), retrievedProvider.getParentSource()), ex); // Paper + LOGGER.error("Could not load plugin '%s' in folder '%s'".formatted(retrievedProvider.getFileName(), retrievedProvider.getParentSource()), ex); // Paper
+ } + }
+ } + }