diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java index 0a8c5945d..006c3c0a0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java @@ -291,13 +291,11 @@ public abstract class TemporaryBuffer extends OutputStream { if (overflow != null) { destroy(); } - if (inCoreLimit < Block.SZ) { - blocks = new ArrayList(1); - blocks.add(new Block(inCoreLimit)); - } else { + if (blocks != null) + blocks.clear(); + else blocks = new ArrayList(initialBlocks); - blocks.add(new Block()); - } + blocks.add(new Block(Math.min(inCoreLimit, Block.SZ))); } /**