Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
eefafb2b
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
eefafb2b
编写于
3月 21, 2016
作者:
O
Oliver Gondža
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-33683] Clarify Action methods can return null
上级
e4d7da60
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
27 addition
and
17 deletion
+27
-17
core/src/main/java/hudson/Functions.java
core/src/main/java/hudson/Functions.java
+1
-1
core/src/main/java/hudson/model/Action.java
core/src/main/java/hudson/model/Action.java
+8
-4
core/src/main/java/hudson/model/ManagementLink.java
core/src/main/java/hudson/model/ManagementLink.java
+8
-5
core/src/main/java/hudson/model/User.java
core/src/main/java/hudson/model/User.java
+3
-2
core/src/main/java/hudson/model/View.java
core/src/main/java/hudson/model/View.java
+1
-1
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+6
-2
test/src/test/java/hudson/model/ManagementLinkTest.java
test/src/test/java/hudson/model/ManagementLinkTest.java
+0
-2
未找到文件。
core/src/main/java/hudson/Functions.java
浏览文件 @
eefafb2b
...
...
@@ -1540,7 +1540,7 @@ public class Functions {
*/
public
static
String
getActionUrl
(
String
itUrl
,
Action
action
)
{
String
urlName
=
action
.
getUrlName
();
if
(
urlName
==
null
)
return
null
;
//
to avoid NPE and fail to render the whole page
if
(
urlName
==
null
)
return
null
;
//
Should not be displayed
try
{
if
(
new
URI
(
urlName
).
isAbsolute
())
{
return
urlName
;
...
...
core/src/main/java/hudson/model/Action.java
浏览文件 @
eefafb2b
...
...
@@ -25,6 +25,8 @@ package hudson.model;
import
hudson.Functions
;
import
javax.annotation.CheckForNull
;
/**
* Object that contributes additional information, behaviors, and UIs to {@link ModelObject}
* (more specifically {@link Actionable} objects, which most interesting {@link ModelObject}s are.)
...
...
@@ -90,15 +92,17 @@ public interface Action extends ModelObject {
* @see Functions#isAnonymous()
* @see Functions#getIconFilePath(Action)
*/
String
getIconFileName
();
@CheckForNull
String
getIconFileName
();
/**
* Gets the string to be displayed.
*
* The convention is to capitalize the first letter of each word,
* such as "Test Result".
* such as "Test Result".
*
* @return Can be null in case the action is hidden.
*/
String
getDisplayName
();
@CheckForNull
String
getDisplayName
();
/**
* Gets the URL path name.
...
...
@@ -124,5 +128,5 @@ public interface Action extends ModelObject {
* (when you do that, be sure to also return null from {@link #getIconFileName()}.
* @see Functions#getActionUrl(String, Action)
*/
String
getUrlName
();
@CheckForNull
String
getUrlName
();
}
core/src/main/java/hudson/model/ManagementLink.java
浏览文件 @
eefafb2b
...
...
@@ -33,6 +33,9 @@ import jenkins.model.Jenkins;
import
java.util.List
;
import
org.kohsuke.stapler.interceptor.RequirePOST
;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
/**
* Extension point to add icon to <tt>http://server/hudson/manage</tt> page.
*
...
...
@@ -59,7 +62,7 @@ public abstract class ManagementLink implements ExtensionPoint, Action {
* This is useful for defining {@link ManagementLink} that only shows up under
* certain circumstances.
*/
public
abstract
String
getIconFileName
();
public
abstract
@CheckForNull
String
getIconFileName
();
/**
* Returns a short description of what this link does. This text
...
...
@@ -80,7 +83,7 @@ public abstract class ManagementLink implements ExtensionPoint, Action {
* so relative paths are interpreted against the root {@link Jenkins} object.
*/
@Override
public
abstract
String
getUrlName
();
public
abstract
@CheckForNull
String
getUrlName
();
/**
* Allows implementations to request that this link show a confirmation dialog, and use POST if confirmed.
...
...
@@ -102,16 +105,16 @@ public abstract class ManagementLink implements ExtensionPoint, Action {
public
static
final
List
<
ManagementLink
>
LIST
=
ExtensionListView
.
createList
(
ManagementLink
.
class
);
/**
* All reg
si
tered instances.
* All reg
is
tered instances.
*/
public
static
ExtensionList
<
ManagementLink
>
all
()
{
public
static
@Nonnull
ExtensionList
<
ManagementLink
>
all
()
{
return
ExtensionList
.
lookup
(
ManagementLink
.
class
);
}
/**
* @return permission required for user to access this management link, in addition to {@link Jenkins#ADMINISTER}
*/
public
Permission
getRequiredPermission
()
{
public
@CheckForNull
Permission
getRequiredPermission
()
{
return
null
;
}
...
...
core/src/main/java/hudson/model/User.java
浏览文件 @
eefafb2b
...
...
@@ -73,6 +73,7 @@ import java.util.HashSet;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
...
...
@@ -903,11 +904,11 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
public
Object
getDynamic
(
String
token
)
{
for
(
Action
action:
getTransientActions
()){
if
(
action
.
getUrlName
().
equals
(
token
))
if
(
Objects
.
equals
(
action
.
getUrlName
(),
token
))
return
action
;
}
for
(
Action
action:
getPropertyActions
()){
if
(
action
.
getUrlName
().
equals
(
token
))
if
(
Objects
.
equals
(
action
.
getUrlName
(),
token
))
return
action
;
}
return
null
;
...
...
core/src/main/java/hudson/model/View.java
浏览文件 @
eefafb2b
...
...
@@ -544,7 +544,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
for
(
Action
a
:
getActions
())
{
String
url
=
a
.
getUrlName
();
if
(
url
==
null
)
continue
;
if
(
a
.
getUrlName
()
.
equals
(
token
))
if
(
url
.
equals
(
token
))
return
a
;
}
return
null
;
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
eefafb2b
...
...
@@ -191,6 +191,8 @@ import hudson.views.DefaultViewsTabBar;
import
hudson.views.MyViewsTabBar
;
import
hudson.views.ViewsTabBar
;
import
hudson.widgets.Widget
;
import
java.util.Objects
;
import
java.util.TimerTask
;
import
java.util.concurrent.CountDownLatch
;
import
jenkins.ExtensionComponentSet
;
...
...
@@ -3274,7 +3276,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
return
a
;
}
for
(
Action
a
:
getManagementLinks
())
if
(
a
.
getUrlName
().
equals
(
token
))
if
(
Objects
.
equals
(
a
.
getUrlName
(),
token
))
return
a
;
return
null
;
}
...
...
@@ -4292,7 +4294,9 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
// TODO consider caching (expiring cache when actions changes)
for
(
Action
a
:
getActions
())
{
if
(
a
instanceof
UnprotectedRootAction
)
{
names
.
add
(
a
.
getUrlName
());
String
url
=
a
.
getUrlName
();
if
(
url
==
null
)
continue
;
names
.
add
(
url
);
}
}
return
names
;
...
...
test/src/test/java/hudson/model/ManagementLinkTest.java
浏览文件 @
eefafb2b
...
...
@@ -35,9 +35,7 @@ import org.jvnet.hudson.test.Issue;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.JenkinsRule.WebClient
;
import
org.jvnet.hudson.test.TestExtension
;
import
org.xml.sax.SAXException
;
import
java.io.IOException
;
import
java.util.List
;
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录