Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1971 from daspilker/JENKINS-31932
[JENKINS-31932] avoid synchronization for Jenkinsget/setJDKs
(cherry picked from commit 0a5b036)
  • Loading branch information
daniel-beck authored and olivergondza committed Feb 3, 2016
1 parent de9835a commit 3be09ad
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -431,7 +431,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
private transient volatile boolean isQuietingDown;
private transient volatile boolean terminating;

private List<JDK> jdks = new ArrayList<JDK>();
private volatile List<JDK> jdks = new ArrayList<JDK>();

private transient volatile DependencyGraph dependencyGraph;
private final transient AtomicBoolean dependencyGraphDirty = new AtomicBoolean();
Expand Down Expand Up @@ -886,6 +886,17 @@ public void run(Reactor reactor) throws Exception {
executeReactor(null, graphBuilder);
}

/**
* Maintains backwards compatibility. Invoked by XStream when this object is de-serialized.
*/
@SuppressWarnings({"unused"})
private Object readResolve() {
if (jdks == null) {
jdks = new ArrayList<>();
}
return this;
}

/**
* Executes a reactor.
*
Expand Down Expand Up @@ -1663,9 +1674,7 @@ public String getDisplayName() {
return Messages.Hudson_DisplayName();
}

public synchronized List<JDK> getJDKs() {
if(jdks==null)
jdks = new ArrayList<JDK>();
public List<JDK> getJDKs() {
return jdks;
}

Expand All @@ -1676,7 +1685,7 @@ public synchronized List<JDK> getJDKs() {
* set JDK installations from external code.
*/
@Restricted(NoExternalUse.class)
public synchronized void setJDKs(Collection<? extends JDK> jdks) {
public void setJDKs(Collection<? extends JDK> jdks) {
this.jdks = new ArrayList<JDK>(jdks);
}

Expand Down

0 comments on commit 3be09ad

Please sign in to comment.