提交 1f31f421 编写于 作者: S Steve Arch 提交者: Oleg Nenashev

[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.
上级 3caef8ec
......@@ -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<Action> 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<Action> getActions() {
List<Action> result = new ArrayList<Action>();
result.addAll(getOwner().getViewActions());
synchronized (this) {
if (transientActions == null) {
updateTransientActions();
}
result.addAll(transientActions);
}
return result;
}
public synchronized void updateTransientActions() {
transientActions = TransientViewActionFactory.createAllFor(this);
List<Action> 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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册