Skip to content

Commit

Permalink
[JENKINS-31954] Merged #1952.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Dec 11, 2015
2 parents 8f38e20 + 60a23e5 commit ef5f6bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class="major bug">
Various kinds of settings could not be saved since 1.640.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-31954">issue 31954</a>)
</ul>
</div><!--=TRUNK-END=-->
<h3><a name=v1.641>What's new in 1.641</a> (2015/12/09)</h3>
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/hudson/model/Descriptor.java
Expand Up @@ -578,13 +578,13 @@ public T newInstance(@CheckForNull StaplerRequest req, @Nonnull JSONObject formD
BindInterceptor oldInterceptor = req.getBindInterceptor();
try {
NewInstanceBindInterceptor interceptor;
if ((oldInterceptor instanceof NewInstanceBindInterceptor)) {
if (oldInterceptor instanceof NewInstanceBindInterceptor) {
interceptor = (NewInstanceBindInterceptor) oldInterceptor;
} else {
interceptor = new NewInstanceBindInterceptor(oldInterceptor);
req.setBindInterceptor(interceptor);
}
interceptor.processed.put(formData, null);
interceptor.processed.put(formData, true);
return verifyNewInstance(req.bindJSON(clazz, formData));
} finally {
req.setBindInterceptor(oldInterceptor);
Expand Down Expand Up @@ -612,7 +612,7 @@ public T newInstance(@CheckForNull StaplerRequest req, @Nonnull JSONObject formD
private static class NewInstanceBindInterceptor extends BindInterceptor {

private final BindInterceptor oldInterceptor;
private final Map<JSONObject,Void> processed = new IdentityHashMap<>();
private final Map<JSONObject,Boolean> processed = new IdentityHashMap<>();

NewInstanceBindInterceptor(BindInterceptor oldInterceptor) {
LOGGER.log(Level.FINER, "new interceptor delegating to {0}", oldInterceptor);
Expand All @@ -628,7 +628,7 @@ private boolean isApplicable(Class type, JSONObject json) {
LOGGER.log(Level.FINER, "ignoring non-Describable {0} {1}", new Object[] {type.getName(), json});
return false;
}
if (processed.containsKey(json)) {
if (Boolean.TRUE.equals(processed.put(json, true))) {
LOGGER.log(Level.FINER, "already processed {0} {1}", new Object[] {type.getName(), json});
return false;
}
Expand Down
10 changes: 10 additions & 0 deletions test/src/test/java/hudson/model/RunParameterDefinitionTest.java
Expand Up @@ -49,6 +49,16 @@ public class RunParameterDefinitionTest {
@Rule
public JenkinsRule j = new JenkinsRule();

@Issue("JENKINS-31954")
@Test public void configRoundtrip() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(new RunParameterDefinition("build", "p", "", RunParameterFilter.COMPLETED)));
j.configRoundtrip(p);
RunParameterDefinition rpd = (RunParameterDefinition) p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("build");
assertEquals("p", rpd.getProjectName());
assertEquals(RunParameterFilter.COMPLETED, rpd.getFilter());
}

@Issue("JENKINS-16462")
@Test public void inFolders() throws Exception {
MockFolder dir = j.createFolder("dir");
Expand Down

0 comments on commit ef5f6bf

Please sign in to comment.