提交 67f4dd51 编写于 作者: O Oleg Nenashev

Merge pull request #1692 from daspilker/JENKINS-28292

[JENKINS-28292] fixed synchronization issue when setting JDK installations
......@@ -166,11 +166,8 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
return Jenkins.getInstance().getJDKs().toArray(new JDK[0]);
}
// this isn't really synchronized well since the list is Hudson.jdks :(
public @Override synchronized void setInstallations(JDK... jdks) {
List<JDK> list = Jenkins.getInstance().getJDKs();
list.clear();
list.addAll(Arrays.asList(jdks));
public @Override void setInstallations(JDK... jdks) {
Jenkins.getInstance().setJDKs(Arrays.asList(jdks));
}
@Override
......
......@@ -1640,12 +1640,23 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
return Messages.Hudson_DisplayName();
}
public List<JDK> getJDKs() {
public synchronized List<JDK> getJDKs() {
if(jdks==null)
jdks = new ArrayList<JDK>();
return jdks;
}
/**
* Replaces all JDK installations with those from the given collection.
*
* Use {@link hudson.model.JDK.DescriptorImpl#setInstallations(JDK...)} to
* set JDK installations from external code.
*/
@Restricted(NoExternalUse.class)
public synchronized void setJDKs(Collection<? extends JDK> jdks) {
this.jdks = new ArrayList<JDK>(jdks);
}
/**
* Gets the JDK installation of the given name, or returns null.
*/
......@@ -2852,8 +2863,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
systemMessage = Util.nullify(req.getParameter("system_message"));
jdks.clear();
jdks.addAll(req.bindJSONToList(JDK.class,json.get("jdks")));
setJDKs(req.bindJSONToList(JDK.class, json.get("jdks")));
boolean result = true;
for (Descriptor<?> d : Functions.getSortedDescriptorsForGlobalConfigUnclassified())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册