diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java index 1022eb2ee..170e4ddbe 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2009, Google Inc. + * Copyright (C) 2008-2010, Google Inc. * Copyright (C) 2008-2009, Robin Rosenberg * Copyright (C) 2008, Shawn O. Pearce * and other copyright owners as documented in the project's IP log. @@ -72,11 +72,11 @@ class PacketLineIn { private final InputStream in; - private final byte[] lenbuffer; + private final byte[] lineBuffer; PacketLineIn(final InputStream i) { in = i; - lenbuffer = new byte[4]; + lineBuffer = new byte[SideBandOutputStream.SMALL_BUF]; } AckNackResult readACK(final MutableObjectId returnedId) throws IOException { @@ -124,22 +124,27 @@ class PacketLineIn { len -= 4; // length header (4 bytes) - final byte[] raw = new byte[len]; + byte[] raw; + if (len <= lineBuffer.length) + raw = lineBuffer; + else + raw = new byte[len]; + IO.readFully(in, raw, 0, len); return RawParseUtils.decode(Constants.CHARSET, raw, 0, len); } int readLength() throws IOException { - IO.readFully(in, lenbuffer, 0, 4); + IO.readFully(in, lineBuffer, 0, 4); try { - final int len = RawParseUtils.parseHexInt16(lenbuffer, 0); + final int len = RawParseUtils.parseHexInt16(lineBuffer, 0); if (len != 0 && len < 4) throw new ArrayIndexOutOfBoundsException(); return len; } catch (ArrayIndexOutOfBoundsException err) { throw new IOException("Invalid packet line header: " - + (char) lenbuffer[0] + (char) lenbuffer[1] - + (char) lenbuffer[2] + (char) lenbuffer[3]); + + (char) lineBuffer[0] + (char) lineBuffer[1] + + (char) lineBuffer[2] + (char) lineBuffer[3]); } } }