Skip to content
Permalink
Browse files
[JENKINS-28292] fixed synchronization issue
  • Loading branch information
daspilker committed May 18, 2015
1 parent f06add2 commit 44eeb10461b0f49fe6c0125a9727f57480d10f10
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 44eeb10

Please sign in to comment.