From 1f31f421770847787f7928f52bc83cf825bba373 Mon Sep 17 00:00:00 2001 From: Steve Arch Date: Thu, 27 Sep 2018 19:15:48 +0100 Subject: [PATCH] [JENKINS-53353] - Do not cache results of View.getActions() (#3608) * JENKINS-53353 Do not cache results of View.getActions() Plugins that may affect the view, eg via TransientViewActionFactory that get installed _after_ a `view` has been initally viewed will not be able to add anything to the view if the results of getActions() are cached. * JENKINS-53353 Removed unnecessary synchronization * JENKINS-53353 Whitespace * JENKINS-53353 Restored (and deprecated) updateTransientActions to maintain backwards compatibility. --- core/src/main/java/hudson/model/View.java | 31 ++++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index de1dc343e8..fcab16b90b 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -116,7 +116,6 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; -import static jenkins.scm.RunWithSCM.*; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -172,8 +171,6 @@ public abstract class View extends AbstractModelObject implements AccessControll */ protected boolean filterQueue; - protected transient List transientActions; - /** * List of {@link ViewProperty}s configured for this view. * @since 1.406 @@ -550,21 +547,20 @@ public abstract class View extends AbstractModelObject implements AccessControll * @see Jenkins#getActions() */ public List getActions() { - List result = new ArrayList(); - result.addAll(getOwner().getViewActions()); - synchronized (this) { - if (transientActions == null) { - updateTransientActions(); - } - result.addAll(transientActions); - } - return result; - } - - public synchronized void updateTransientActions() { - transientActions = TransientViewActionFactory.createAllFor(this); + List result = new ArrayList<>(); + result.addAll(getOwner().getViewActions()); + result.addAll(TransientViewActionFactory.createAllFor(this)); + return result; } - + + /** + * No-op. Included to maintain backwards compatibility. + * @deprecated This method does nothing and should not be used + */ + @Restricted(DoNotUse.class) + @Deprecated + public void updateTransientActions() {} + public Object getDynamic(String token) { for (Action a : getActions()) { String url = a.getUrlName(); @@ -994,7 +990,6 @@ public abstract class View extends AbstractModelObject implements AccessControll rename(req.getParameter("name")); getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); - updateTransientActions(); save(); -- GitLab