From e672bf04bc7c436642c09c28609dd5407a75a5ee Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Fri, 7 Oct 2011 11:01:40 +0100 Subject: [PATCH] There are a number of ways the previous version could seriously bork plugin initialization all because you don't have a Messages.properties in the correct package, or because you are missing a key in your bundle... when we know the correct answer without a key is ClassName.MetodName --- .../main/java/hudson/init/InitializerFinder.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/init/InitializerFinder.java b/core/src/main/java/hudson/init/InitializerFinder.java index e8b170a408..61f9d39ff8 100644 --- a/core/src/main/java/hudson/init/InitializerFinder.java +++ b/core/src/main/java/hudson/init/InitializerFinder.java @@ -41,6 +41,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.MissingResourceException; import java.util.Set; import java.util.logging.Logger; @@ -85,16 +86,19 @@ public class InitializerFinder extends TaskBuilder { * Obtains the display name of the given initialization task */ protected String getDisplayNameOf(Method e, Initializer i) { + Class c = e.getDeclaringClass(); + String key = i.displayName(); + if (key.length()==0) return c.getSimpleName()+"."+e.getName(); try { - Class c = e.getDeclaringClass(); - ResourceBundleHolder rb = ResourceBundleHolder.get(c.getClassLoader().loadClass(c.getPackage().getName() + ".Messages")); - - String key = i.displayName(); - if (key.length()==0) return c.getSimpleName()+"."+e.getName(); + ResourceBundleHolder rb = ResourceBundleHolder.get( + c.getClassLoader().loadClass(c.getPackage().getName() + ".Messages")); return rb.format(key); } catch (ClassNotFoundException x) { LOGGER.log(WARNING, "Failed to load "+x.getMessage()+" for "+e.toString(),x); - return ""; + return key; + } catch (MissingResourceException x) { + LOGGER.log(WARNING, "Could not find key '" + key + "' in " + c.getPackage().getName() + ".Messages", x); + return key; } }