Skip to content
Permalink
Browse files
Merge pull request #1692 from daspilker/JENKINS-28292
[JENKINS-28292] fixed synchronization issue when setting JDK installations
  • Loading branch information
oleg-nenashev committed Jun 13, 2015
2 parents 3f0e292 + 44eeb10 commit 67f4dd516633a5ef0f6d0085c0f1b90c5ebf3c8e
Showing with 15 additions and 8 deletions.
  1. +2 −5 core/src/main/java/hudson/model/JDK.java
  2. +13 −3 core/src/main/java/jenkins/model/Jenkins.java
@@ -166,11 +166,8 @@ public String getDisplayName() {
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 String getDisplayName() {
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 synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp

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())

0 comments on commit 67f4dd5

Please sign in to comment.