]> source.dussan.org Git - jgit.git/commitdiff
Fix DeltaTask infinite loop 71/28071/1
authorHugo Arès <hugo.ares@ericsson.com>
Thu, 5 Jun 2014 19:16:26 +0000 (15:16 -0400)
committerHugo Arès <hugo.ares@ericsson.com>
Thu, 5 Jun 2014 19:20:04 +0000 (15:20 -0400)
DeltaTask$Block.partitionTask was doing an infinite loop if number of
threads was greater than the totalWeight. The weightPerThread was 0
which was causing the infinite loop. Set the weightPerThread to a
minimal value of one.

Bug: 420915
Change-Id: Ia8e3ad956d53d8193937b7fa1bc19aafde9767ff
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java

index c4b01949d1da4ada98c9ac1a6aa36ad501bd9872..9534053bfe16c56747fb48b55731f1a5d2ff2631 100644 (file)
@@ -121,7 +121,7 @@ final class DeltaTask implements Callable<Object> {
                        ArrayList<WeightedPath> topPaths = computeTopPaths();
                        Iterator<WeightedPath> topPathItr = topPaths.iterator();
                        int nextTop = 0;
-                       long weightPerThread = totalWeight / threads;
+                       long weightPerThread = Math.max(totalWeight / threads, 1);
                        for (int i = beginIndex; i < endIndex;) {
                                DeltaTask task = new DeltaTask(this);
                                long w = 0;