From a0a52ddc782e95c38dfb1221064cbf72a41710f0 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 23 Jul 2012 18:17:14 +0200 Subject: [PATCH] SONAR-3688 Improve log when loading a plugin that is not compiled for Java 5 --- .../org/sonar/core/plugins/PluginClassloaders.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java index 11a762d7333..2b2c27600be 100644 --- a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java +++ b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java @@ -122,8 +122,8 @@ public class PluginClassloaders { realm.addURL(url); } return realm; - } catch (Exception e) { - throw new SonarException(e); + } catch (Throwable e) { + throw new SonarException("Fail to build the classloader of " + plugin.getKey(), e); } } @@ -143,8 +143,8 @@ public class PluginClassloaders { base.addURL(file.toURI().toURL()); } return true; - } catch (Exception e) { - throw new SonarException(e); + } catch (Throwable e) { + throw new SonarException("Fail to extend the plugin " + plugin.getBasePlugin() + " for " + plugin.getKey(), e); } } @@ -207,7 +207,9 @@ public class PluginClassloaders { Class claz = get(metadata.getKey()).loadClass(metadata.getMainClass()); return (Plugin) claz.newInstance(); - } catch (Exception e) { + } catch (Throwable e) { + // Do not catch only Exception in order to detect the plugins compiled for Java > 5 + // (it raises a java.lang.UnsupportedClassVersionError) throw new SonarException("Fail to load plugin " + metadata.getKey(), e); } } -- 2.39.5