提交 1c8ed8e6 编写于 作者: A Alvaro Lobato 提交者: Oleg Nenashev

[JENKINS-45244] Avoid locking every time getActions is called (#2933)

* [JENKINS-45244] Avoid locking every time getActions is called

* [JENKINS-45244] - Remove initializer

* Add comment clarifying that the actions must be volatile
上级 6e652aea
......@@ -74,12 +74,15 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
@Deprecated
@Nonnull
public List<Action> getActions() {
synchronized (this) {
if(actions == null) {
actions = new CopyOnWriteArrayList<Action>();
//this double checked synchronization is only safe if the field 'actions' is volatile
if (actions == null) {
synchronized (this) {
if (actions == null) {
actions = new CopyOnWriteArrayList<Action>();
}
}
return actions;
}
return actions;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册