Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
92234d4d
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
92234d4d
编写于
11月 01, 2016
作者:
S
Stephen Connolly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-39404] Make it easier for subclasses and address some code review comments
上级
65de34f7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
29 deletion
+37
-29
core/src/main/java/hudson/model/Actionable.java
core/src/main/java/hudson/model/Actionable.java
+36
-21
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+0
-7
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+1
-1
未找到文件。
core/src/main/java/hudson/model/Actionable.java
浏览文件 @
92234d4d
...
...
@@ -75,16 +75,26 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
* May still be called for compatibility reasons from subclasses predating {@link TransientActionFactory}.
*/
@Deprecated
public
List
<
Action
>
getActions
()
{
if
(
actions
==
null
)
{
synchronized
(
this
)
{
if
(
actions
==
null
)
{
actions
=
new
CopyOnWriteArrayList
<
Action
>();
}
}
}
return
actions
;
}
public
List
<
Action
>
getActions
()
{
return
getOrCreateActions
();
}
/**
* We need to handle the initialization of the actions list in Actionable so that child classes that override
* getActions() for historical reasons do not have to override the manipulation methods: {@link #addAction(Action)},
* {@link #replaceAction(Action)}, {@link #removeAction(Action)}, etc.
* @return the CopyOnWriteArrayList of persisted actions.
*/
private
CopyOnWriteArrayList
<
Action
>
getOrCreateActions
()
{
if
(
actions
==
null
)
{
synchronized
(
this
)
{
if
(
actions
==
null
)
{
actions
=
new
CopyOnWriteArrayList
<
Action
>();
}
}
}
return
actions
;
}
/**
* Gets all actions, transient or persistent.
...
...
@@ -123,9 +133,10 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
/**
* Adds a new action.
* Adds a new action. Note calls to {@link #getAllActions()} that happen before calls to this method may not see the
* update.
*
* The default implementation
calls
{@code getActions().add(a)}.
* The default implementation
is mostly equivalent to the call chain
{@code getActions().add(a)}.
*/
@SuppressWarnings
({
"ConstantConditions"
,
"deprecation"
})
@SuppressFBWarnings
(
"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"
)
...
...
@@ -133,11 +144,12 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
if
(
a
==
null
)
{
throw
new
IllegalArgumentException
(
"Action must be non-null"
);
}
getActions
().
add
(
a
);
get
OrCreate
Actions
().
add
(
a
);
}
/**
* Add an action, replacing any existing action of the (exact) same class.
* Add an action, replacing any existing action of the (exact) same class. Note calls to {@link #getAllActions()}
* that happen before calls to this method may not see the update.
* @param a an action to add/replace
* @since 1.548
*/
...
...
@@ -149,7 +161,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
// CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way:
List
<
Action
>
old
=
new
ArrayList
<
Action
>(
1
);
List
<
Action
>
current
=
getActions
();
List
<
Action
>
current
=
get
OrCreate
Actions
();
boolean
found
=
false
;
for
(
Action
a2
:
current
)
{
if
(!
found
&&
a
.
equals
(
a2
))
{
...
...
@@ -165,7 +177,8 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
/**
* Remove an action.
* Remove an action. Note calls to {@link #getAllActions()} that happen before calls to this method may not see the
* update.
*
* @param a an action to remove (if {@code null} then this will be a no-op)
* @return {@code true} if this actions changed as a result of the call
...
...
@@ -177,11 +190,12 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
return
false
;
}
// CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way:
return
getActions
().
removeAll
(
Collections
.
singleton
(
a
));
return
get
OrCreate
Actions
().
removeAll
(
Collections
.
singleton
(
a
));
}
/**
* Removes any actions of the specified type.
* Removes any actions of the specified type. Note calls to {@link #getAllActions()} that happen before calls to
* this method may not see the update.
*
* @param clazz the type of actions to remove
* @return {@code true} if this actions changed as a result of the call
...
...
@@ -195,7 +209,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
// CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way:
List
<
Action
>
old
=
new
ArrayList
<
Action
>();
List
<
Action
>
current
=
getActions
();
List
<
Action
>
current
=
get
OrCreate
Actions
();
for
(
Action
a
:
current
)
{
if
(
clazz
.
isInstance
(
a
))
{
old
.
add
(
a
);
...
...
@@ -205,7 +219,8 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
/**
* Replaces any actions of the specified type by the supplied action.
* Replaces any actions of the specified type by the supplied action. Note calls to {@link #getAllActions()} that
* happen before calls to this method may not see the update.
*
* @param clazz the type of actions to replace
* @param a the action to replace with
...
...
@@ -220,7 +235,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
}
// CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way:
List
<
Action
>
old
=
new
ArrayList
<
Action
>();
List
<
Action
>
current
=
getActions
();
List
<
Action
>
current
=
get
OrCreate
Actions
();
boolean
found
=
false
;
for
(
Action
a1
:
current
)
{
if
(!
found
&&
a
.
equals
(
a1
))
{
...
...
core/src/main/java/hudson/model/Computer.java
浏览文件 @
92234d4d
...
...
@@ -268,13 +268,6 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return
Collections
.
unmodifiableList
(
result
);
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
void
addAction
(
Action
a
)
{
if
(
a
==
null
)
throw
new
IllegalArgumentException
();
super
.
getActions
().
add
(
a
);
}
/**
* This is where the log from the remote agent goes.
* The method also creates a log directory if required.
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
92234d4d
...
...
@@ -349,7 +349,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
((
RunAction2
)
a
).
onLoad
(
this
);
}
catch
(
RuntimeException
x
)
{
LOGGER
.
log
(
WARNING
,
"failed to load "
+
a
+
" from "
+
getDataFile
(),
x
);
getActions
().
remove
(
a
);
// if possible; might be in an inconsistent state
removeAction
(
a
);
// if possible; might be in an inconsistent state
}
}
else
if
(
a
instanceof
RunAction
)
{
((
RunAction
)
a
).
onLoad
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录