From 22d433deae5e8e056f83900cc6c9bcc5a3ba60d5 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 4 Nov 2014 17:25:07 -0500 Subject: [PATCH] =?UTF-8?q?So=20far=20unsuccessful=20attempt=20to=20make?= =?UTF-8?q?=20Jenkins=20startup=20more=20robust=20against=20bugs=20like=20?= =?UTF-8?q?JENKINS-25440.=20Even=20though=20SezpozModule.configure=20catch?= =?UTF-8?q?es=20and=20ignores=20the=20faulty=20component,=20Guice=20still?= =?UTF-8?q?=20dies:=20=E2=80=A6=20hudson.ExtensionFinder$GuiceFinder=20=20SEVERE:=20Failed=20to=20create=20Guice=20container=20from?= =?UTF-8?q?=20all=20the=20plugins=20com.google.inject.internal.guava.colle?= =?UTF-8?q?ct.$ComputationException:=20java.lang.NoClassDefFoundError:=20o?= =?UTF-8?q?rg/eclipse/jgit/storage/file/FileRepository=20=09at=20=E2=80=A6?= =?UTF-8?q?=20=09at=20com.google.inject.Guice.createInjector(Guice.java:73?= =?UTF-8?q?)=20=09at=20hudson.ExtensionFinder$GuiceFinder.(Extension?= =?UTF-8?q?Finder.java:279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/main/java/hudson/ExtensionFinder.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/ExtensionFinder.java b/core/src/main/java/hudson/ExtensionFinder.java index 921a815d1b..d4dc1ef31b 100644 --- a/core/src/main/java/hudson/ExtensionFinder.java +++ b/core/src/main/java/hudson/ExtensionFinder.java @@ -281,6 +281,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { LOGGER.log(Level.SEVERE, "Failed to create Guice container from all the plugins",e); // failing to load all bindings are disastrous, so recover by creating minimum that works // by just including the core + // TODO this recovery is pretty much useless; startup crashes anyway container = Guice.createInjector(new SezpozModule(loadSezpozIndices(Jenkins.class.getClassLoader()))); } @@ -355,7 +356,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { // which results in a LinkageError LOGGER.log(isOptional(item.annotation()) ? Level.FINE : Level.WARNING, "Failed to load "+item.className(), e); - } catch (InstantiationException e) { + } catch (Exception e) { LOGGER.log(isOptional(item.annotation()) ? Level.FINE : Level.WARNING, "Failed to load "+item.className(), e); } @@ -478,8 +479,10 @@ public abstract class ExtensionFinder implements ExtensionPoint { Method m = ClassLoader.class.getDeclaredMethod("resolveClass", Class.class); m.setAccessible(true); m.invoke(ecl, c); + c.getConstructors(); c.getMethods(); - c.getFields(); + c.getFields(); + LOGGER.log(Level.FINER, "{0} looks OK", c); while (c != Object.class) { c.getGenericSuperclass(); c = c.getSuperclass(); @@ -534,7 +537,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { // which results in a LinkageError LOGGER.log(optional ? Level.FINE : Level.WARNING, "Failed to load "+item.className(), e); - } catch (InstantiationException e) { + } catch (Exception e) { LOGGER.log(optional ? Level.FINE : Level.WARNING, "Failed to load "+item.className(), e); } @@ -644,7 +647,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { // sometimes the instantiation fails in an indirect classloading failure, // which results in a LinkageError LOGGER.log(logLevel(item), "Failed to load "+item.className(), e); - } catch (InstantiationException e) { + } catch (Exception e) { LOGGER.log(logLevel(item), "Failed to load "+item.className(), e); } } @@ -675,9 +678,7 @@ public abstract class ExtensionFinder implements ExtensionPoint { // according to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6459208 // this appears to be the only way to force a class initialization Class.forName(extType.getName(),true,extType.getClassLoader()); - } catch (InstantiationException e) { - LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e); - } catch (ClassNotFoundException e) { + } catch (Exception e) { LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e); } catch (LinkageError e) { LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e); -- GitLab