Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #229 from abayer/jenkins-48304
[JENKINS-48304] Invalidate option type caches after extensions augmented
  • Loading branch information
abayer committed Jan 12, 2018
2 parents 63d8452 + d6102ab commit 02ee608
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -99,6 +99,15 @@ class Options implements Serializable {
}
)

/**
* Invalidate our type caches.
*/
static void invalidateCaches() {
wrapperStepsTypeCache.invalidateAll()
propertyTypeCache.invalidateAll()
optionTypeCache.invalidateAll()
}

static Map<String,String> getEligibleWrapperStepClasses() {
return wrapperStepsTypeCache.get(WRAPPER_STEPS_KEY)
}
Expand Down
Expand Up @@ -24,6 +24,9 @@
package org.jenkinsci.plugins.pipeline.modeldefinition;

import hudson.Extension;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import org.jenkinsci.plugins.pipeline.modeldefinition.model.Options;
import org.jenkinsci.plugins.workflow.cps.CpsScript;
import org.jenkinsci.plugins.workflow.cps.CpsThread;
import org.jenkinsci.plugins.workflow.cps.GlobalVariable;
Expand Down Expand Up @@ -59,4 +62,14 @@ public Object getValue(@Nonnull CpsScript script) throws Exception {
.newInstance(script);
}

/**
* Make sure we've invalidated the option type caches due to potential race conditions with their population.
* Because we're using {@link Initializer}, we need this to be triggered in an {@link Extension}, so here is as good
* a place as any.
*/
@Initializer(after = InitMilestone.EXTENSIONS_AUGMENTED)
public static void invalidateOptionTypeCaches() {
Options.invalidateCaches();
}

}

0 comments on commit 02ee608

Please sign in to comment.