From 7476baebfc457e75c984de61dc8ae08a359b52e8 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 5 Apr 2017 09:10:10 +0200 Subject: [PATCH] Fixed NP dereference error reported by ecj in UploadPack.stopBuffering() Introduced via commit 3b2508b51467c3cb0541c004488eaabae2842f9e. Change-Id: I2b6175c095aea2868a8c302103095accde5170e3 Signed-off-by: Andrey Loskutov --- .../src/org/eclipse/jgit/transport/UploadPack.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 6b16f550d..ddb2fbf01 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -72,7 +72,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -1588,12 +1587,10 @@ public class UploadPack { private final OutputStream rawOut; private OutputStream out; - @Nullable - private ByteArrayOutputStream buffer; ResponseBufferedOutputStream(OutputStream rawOut) { this.rawOut = rawOut; - this.out = this.buffer = new ByteArrayOutputStream(); + this.out = new ByteArrayOutputStream(); } @Override @@ -1622,9 +1619,8 @@ public class UploadPack { } void stopBuffering() throws IOException { - if (buffer != null) { - buffer.writeTo(rawOut); - buffer = null; + if (out != rawOut) { + ((ByteArrayOutputStream) out).writeTo(rawOut); out = rawOut; } }