Browse Source

ShowPackDelta: Refactor to use try-with-resource

Remove the resource warning suppression and refactor the code to open
the TemporaryBuffer and InflaterInputStream in a try-with-resource.

Change-Id: I3082e5ac7565c5000d5a4364f750dd0a0952fc6e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago
parent
commit
ed9ede3446
  1. 15
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java

15
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java

@ -125,12 +125,13 @@ class ShowPackDelta extends TextBuiltin {
ptr++; ptr++;
ptr++; ptr++;
@SuppressWarnings("resource" /* java 7 */) try (TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(
TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(bufArray.length); bufArray.length);
InflaterInputStream inf = new InflaterInputStream( InflaterInputStream inf = new InflaterInputStream(
new ByteArrayInputStream(bufArray, ptr, bufArray.length)); new ByteArrayInputStream(bufArray, ptr,
raw.copy(inf); bufArray.length))) {
inf.close(); raw.copy(inf);
return raw.toByteArray(); return raw.toByteArray();
}
} }
} }

Loading…
Cancel
Save