提交 29dc1d5f 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-9062] Fixed a bug in persisting user configuration that causes NPE in some plugins

上级 08b7541d
......@@ -60,6 +60,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Fixed a bug in persisting user configuration that causes NPE in some plugins
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9062">issue 9062</a>)
<li class=bug>
Replacement of some maven properties is not working
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-8573">issue 8573</a>)
......
......@@ -455,7 +455,8 @@ public class User extends AbstractModelObject implements AccessControlled, Savea
p.setUser(this);
}
props.add(p);
if (p!=null)
props.add(p);
}
this.properties = props;
......
package hudson.model;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;
/**
* @author Kohsuke Kawaguchi
*/
public class UserPropertyTest extends HudsonTestCase {
@Bug(9062)
public void test9062() throws Exception {
User u = User.get("foo");
u.addProperty(new UserProperty1());
configRoundtrip(u);
for (UserProperty p : u.getAllProperties())
assertNotNull(p);
}
public static class UserProperty1 extends UserProperty {
@TestExtension
public static class DescriptorImpl extends UserPropertyDescriptor {
public String getDisplayName() {
return "UserProperty1";
}
@Override
public UserProperty newInstance(User user) {
return new UserProperty1();
}
}
}
public static class UserProperty2 extends UserProperty {
@TestExtension
public static class DescriptorImpl extends UserPropertyDescriptor {
public String getDisplayName() {
return "UserProperty2";
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public UserProperty newInstance(User user) {
return new UserProperty1();
}
}
}
}
<j:jelly xmlns:j="jelly:core"/>
\ No newline at end of file
<j:jelly xmlns:j="jelly:core"/>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册