From 9cd00e40dd5ea7f4bfb7ca11b5383d13d0afd8eb Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 25 Mar 2015 10:30:45 +0000 Subject: [PATCH] added `@since` tag as requested by @jglick --- core/src/main/java/hudson/Functions.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 1b696a431e..441f865a24 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -203,9 +203,22 @@ public class Functions { return Util.RFC822_DATETIME_FORMATTER.format(cal.getTime()); } + /** + * During Jenkins start-up, before {@link InitMilestone#PLUGINS_STARTED} the extensions lists will be empty + * and they are not guaranteed to be fully populated until after {@link InitMilestone#EXTENSIONS_AUGMENTED}. + * If you attempt to access the extensions list from a UI thread while the extensions are being loaded you will + * hit a big honking great monitor lock that will block until the effective extension list has been determined + * (as if a plugin fails to start, all of the failed plugin's extensions and any dependent plugins' extensions + * will have to be evicted from the list of extensions. In practical terms this only affects the + * "Jenkins is loading" screen, but as that screen uses the generic layouts we provide this utility method + * so that the generic layouts can avoid iterating extension lists while Jenkins is starting up. + * + * @return {@code true} if the extensions lists have been populated. + * @since 1.FIXME + */ public static boolean isExtensionsAvailable() { final Jenkins jenkins = Jenkins.getInstance(); - return jenkins == null ? false : jenkins.getInitLevel().compareTo(InitMilestone.EXTENSIONS_AUGMENTED) >= 0; + return jenkins != null && jenkins.getInitLevel().compareTo(InitMilestone.EXTENSIONS_AUGMENTED) >= 0; } public static void initPageVariables(JellyContext context) {