From: Simon Brandhof Date: Mon, 23 Jul 2012 16:17:14 +0000 (+0200) Subject: SONAR-3688 Improve log when loading a plugin that is not compiled for Java 5 X-Git-Tag: 3.2~14^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a0a52ddc782e95c38dfb1221064cbf72a41710f0;p=sonarqube.git SONAR-3688 Improve log when loading a plugin that is not compiled for Java 5 --- 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); } }