Skip to content

Commit 8b38aef

Browse files
dpursehouseGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "ReceiveCommits: Don't synchronize on non-final fields"
2 parents c4f708e + ce51db6 commit 8b38aef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,7 @@ public Void call()
17551755
insertChange(threadLocalDb);
17561756
}
17571757
}
1758-
synchronized (newProgress) {
1759-
newProgress.update(1);
1760-
}
1758+
synchronizedIncrement(newProgress);
17611759
return null;
17621760
}
17631761
}));
@@ -2174,9 +2172,7 @@ public PatchSet.Id call() throws OrmException, IOException,
21742172
}
21752173
}
21762174
} finally {
2177-
synchronized (replaceProgress) {
2178-
replaceProgress.update(1);
2179-
}
2175+
synchronizedIncrement(replaceProgress);
21802176
}
21812177
}
21822178
}));
@@ -2846,4 +2842,10 @@ private static boolean isHead(final ReceiveCommand cmd) {
28462842
private static boolean isConfig(final ReceiveCommand cmd) {
28472843
return cmd.getRefName().equals(RefNames.REFS_CONFIG);
28482844
}
2845+
2846+
private static void synchronizedIncrement(Task p) {
2847+
synchronized (p) {
2848+
p.update(1);
2849+
}
2850+
}
28492851
}

0 commit comments

Comments
 (0)