Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
ed03fbbc
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
ed03fbbc
编写于
10月 07, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "[FIXED JENKINS-18629]"
This reverts commit
d15c1550
.
上级
d15c1550
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
121 deletion
+1
-121
core/pom.xml
core/pom.xml
+1
-1
core/src/main/java/hudson/model/Descriptor.java
core/src/main/java/hudson/model/Descriptor.java
+0
-75
test/src/test/java/hudson/model/DescriptorTest.java
test/src/test/java/hudson/model/DescriptorTest.java
+0
-45
未找到文件。
core/pom.xml
浏览文件 @
ed03fbbc
...
...
@@ -42,7 +42,7 @@ THE SOFTWARE.
<properties>
<staplerFork>
true
</staplerFork>
<stapler.version>
1.2
20
</stapler.version>
<stapler.version>
1.2
18
</stapler.version>
<spring.version>
2.5.6.SEC03
</spring.version>
<groovy.version>
1.8.9
</groovy.version>
</properties>
...
...
core/src/main/java/hudson/model/Descriptor.java
浏览文件 @
ed03fbbc
...
...
@@ -29,7 +29,6 @@ import hudson.RelativePath;
import
hudson.XmlFile
;
import
hudson.BulkChange
;
import
hudson.Util
;
import
hudson.init.Initializer
;
import
hudson.model.listeners.SaveableListener
;
import
hudson.util.FormApply
;
import
hudson.util.FormValidation.CheckMethod
;
...
...
@@ -63,7 +62,6 @@ import java.util.HashMap;
import
java.util.Locale
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Stack
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -987,77 +985,4 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
public
static
final
class
Self
{}
protected
static
Class
self
()
{
return
Self
.
class
;
}
/**
* Register a global {@link BindInterceptor} that uses {@link Descriptor#newInstance(StaplerRequest, JSONObject)}
* for instantiation
*/
@Initializer
public
static
void
initGlobalBindInterceptor
()
{
boolean
newInstance
=
WebApp
.
get
(
Jenkins
.
getInstance
().
servletContext
).
bindInterceptors
.
add
(
new
BindInterceptor
()
{
final
class
Input
{
final
Class
type
;
final
JSONObject
json
;
private
Input
(
Class
type
,
JSONObject
json
)
{
this
.
type
=
type
;
this
.
json
=
json
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Input
rhs
=
(
Input
)
o
;
return
json
==
rhs
.
json
&&
type
==
rhs
.
type
;
}
@Override
public
int
hashCode
()
{
return
31
*
type
.
hashCode
()
+
json
.
hashCode
();
}
}
private
final
ThreadLocal
<
Stack
<
Input
>>
inputs
=
new
ThreadLocal
<
Stack
<
Input
>>()
{
protected
Stack
<
Input
>
initialValue
()
{
return
new
Stack
<
Input
>();
}
};
@Override
public
Object
instantiate
(
Class
actualType
,
JSONObject
json
)
{
if
(
Describable
.
class
.
isAssignableFrom
(
actualType
))
{
Descriptor
d
=
Jenkins
.
getInstance
().
getDescriptor
(
actualType
);
if
(
d
!=
null
)
{
try
{
// only when Descriptor.newInstance is overridden
Method
m
=
d
.
getClass
().
getMethod
(
"newInstance"
,
StaplerRequest
.
class
,
JSONObject
.
class
);
if
(
m
.
getDeclaringClass
()
!=
Descriptor
.
class
)
{
Input
newFrame
=
new
Input
(
actualType
,
json
);
if
(!
inputs
.
get
().
contains
(
newFrame
))
{
// prevent infinite recursion in case Descriptor.newInstance calls right back into
// bindJSON
inputs
.
get
().
push
(
newFrame
);
try
{
StaplerRequest
req
=
Stapler
.
getCurrentRequest
();
if
(
req
!=
null
)
return
d
.
newInstance
(
req
,
json
);
}
finally
{
inputs
.
get
().
pop
();
}
}
}
}
catch
(
NoSuchMethodException
e
)
{
throw
new
AssertionError
(
e
);
// this can't happen because Descriptor defines such a method
}
catch
(
FormException
e
)
{
throw
new
IllegalArgumentException
(
e
);
}
}
}
return
DEFAULT
;
}
});
}
}
test/src/test/java/hudson/model/DescriptorTest.java
浏览文件 @
ed03fbbc
...
...
@@ -27,17 +27,10 @@ package hudson.model;
import
hudson.model.Descriptor.PropertyType
;
import
hudson.tasks.Shell
;
import
static
org
.
junit
.
Assert
.*;
import
net.sf.json.JSONObject
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.TestExtension
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
import
java.util.concurrent.Callable
;
public
class
DescriptorTest
{
...
...
@@ -58,42 +51,4 @@ public class DescriptorTest {
}
}
/**
* Make sure Descriptor.newInstance gets invoked.
*/
@Bug
(
18629
)
@Test
public
void
callDescriptor_newInstance
()
throws
Exception
{
rule
.
executeOnServer
(
new
Callable
<
Object
>()
{
@Override
public
Object
call
()
throws
Exception
{
DataBoundBean
v
=
Stapler
.
getCurrentRequest
().
bindJSON
(
DataBoundBean
.
class
,
new
JSONObject
());
assertEquals
(
5
,
v
.
x
);
return
null
;
}
});
}
public
static
class
DataBoundBean
extends
AbstractDescribableImpl
<
DataBoundBean
>
{
int
x
;
// not @DataBoundConstructor
public
DataBoundBean
(
int
x
)
{
this
.
x
=
x
;
}
@TestExtension
public
static
class
DescriptorImpl
extends
Descriptor
<
DataBoundBean
>
{
@Override
public
String
getDisplayName
()
{
return
""
;
}
@Override
public
DataBoundBean
newInstance
(
StaplerRequest
req
,
JSONObject
formData
)
throws
FormException
{
return
new
DataBoundBean
(
5
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录