From da236bad5e6efeff430ebcf4af844953e4a545ea Mon Sep 17 00:00:00 2001 From: mindless Date: Wed, 12 May 2010 19:44:08 +0000 Subject: [PATCH] Support "optional=true" parameter for @Extension to logging exceptions at FINE level (instead of WARNING) for any class loading problems reading the extension. Also move up to sezpoz 1.7 and remove catch block for LinkageError in ExtensionFinder.. sezpoz should now throw only InstantiationException. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30963 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 2 +- core/src/main/java/hudson/Extension.java | 8 +++++++- core/src/main/java/hudson/ExtensionFinder.java | 8 +++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index fa496d794e..8d68eb0b13 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -736,7 +736,7 @@ THE SOFTWARE. net.java.sezpoz sezpoz - 1.5 + 1.7 org.jvnet.hudson diff --git a/core/src/main/java/hudson/Extension.java b/core/src/main/java/hudson/Extension.java index 9ef86d8562..66342a2b61 100644 --- a/core/src/main/java/hudson/Extension.java +++ b/core/src/main/java/hudson/Extension.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc. + * Copyright (c) 2004-2010, Sun Microsystems, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -78,4 +78,10 @@ public @interface Extension { * @since 1.306 */ double ordinal() default 0; + + /** + * If an extension is optional, don't log any class loading errors when reading it. + * @since 1.358 + */ + boolean optional() default false; } diff --git a/core/src/main/java/hudson/ExtensionFinder.java b/core/src/main/java/hudson/ExtensionFinder.java index 0f91edd5ad..cc924da4af 100644 --- a/core/src/main/java/hudson/ExtensionFinder.java +++ b/core/src/main/java/hudson/ExtensionFinder.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc. + * Copyright (c) 2004-2010, Sun Microsystems, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -125,10 +125,8 @@ public abstract class ExtensionFinder implements ExtensionPoint { result.add(new ExtensionComponent(type.cast(instance),item.annotation())); } } catch (InstantiationException e) { - LOGGER.log(Level.WARNING, "Failed to load "+item.className(),e); - } catch (LinkageError e) { - // work around for SEZPOZ-11: https://sezpoz.dev.java.net/issues/show_bug.cgi?id=11 - LOGGER.log(Level.WARNING, "Failed to load "+item.className(),e); + LOGGER.log(item.annotation().optional() ? Level.FINE : Level.WARNING, + "Failed to load "+item.className(), e); } }