Skip to content

Commit

Permalink
[JENKINS-40552] Remove unnecessary synchronization from method. (#100)
Browse files Browse the repository at this point in the history
* [JENKINS-40552] Remove unnecessary synchronization from method.

* Reduce the synchronized scope to not include owner.
  • Loading branch information
christ66 authored and oleg-nenashev committed Jan 16, 2017
1 parent 1d64009 commit f14b0d3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java
Expand Up @@ -214,18 +214,20 @@ private synchronized void safeAddToProcessesList(PromotionProcess p) {
}

@Override
protected synchronized void setOwner(AbstractProject<?,?> owner) {
protected void setOwner(AbstractProject<?,?> owner) {
super.setOwner(owner);

// readResolve is too early because we don't have our parent set yet,
// so use this as the initialization opportunity.
// CopyListener is also using setOwner to re-init after copying config from another job.
processes = new ArrayList<PromotionProcess>(ItemGroupMixIn.<String,PromotionProcess>loadChildren(
this,getRootDir(),ItemGroupMixIn.KEYED_BY_NAME).values());
try {
buildActiveProcess();
} catch (IOException e) {
throw new Error(e);
synchronized (this) {
processes = new ArrayList<PromotionProcess>(ItemGroupMixIn.<String, PromotionProcess>loadChildren(
this, getRootDir(), ItemGroupMixIn.KEYED_BY_NAME).values());
try {
buildActiveProcess();
} catch (IOException e) {
throw new Error(e);
}
}
}

Expand Down Expand Up @@ -324,7 +326,7 @@ public PromotionProcess createProcessFromXml(final String name, InputStream xml)
* Gets {@link AbstractProject} that contains us.
* @return Owner project
*/
public synchronized AbstractProject<?,?> getOwner() {
public AbstractProject<?,?> getOwner() {
return owner;
}

Expand Down

0 comments on commit f14b0d3

Please sign in to comment.