Browse Source

IO: Open TemporaryBuffer.Heap in try-with-resource

Change-Id: I78a947fd1263b47b3df17bcc6e9b32497e68dd4a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 6 years ago
parent
commit
a0f69ff387
  1. 13
      org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java

13
org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java

@ -203,12 +203,13 @@ public class IO {
if (last < 0)
return ByteBuffer.wrap(out, 0, pos);
@SuppressWarnings("resource" /* java 7 */)
TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
tmp.write(out);
tmp.write(last);
tmp.copy(in);
return ByteBuffer.wrap(tmp.toByteArray());
try (TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(
Integer.MAX_VALUE)) {
tmp.write(out);
tmp.write(last);
tmp.copy(in);
return ByteBuffer.wrap(tmp.toByteArray());
}
}
/**

Loading…
Cancel
Save