diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-14 09:35:08 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-14 10:44:23 +0900 |
commit | ed9ede3446f0c95e80eb6feb1dec5dfa698184a9 (patch) | |
tree | a2ce580f9fbb7ee6499b685f96a6fad07f4a3655 /org.eclipse.jgit.pgm | |
parent | 6344e7a0718f722b5b4f9f72b2ea83c0c4dc892b (diff) | |
download | jgit-ed9ede3446f0c95e80eb6feb1dec5dfa698184a9.tar.gz jgit-ed9ede3446f0c95e80eb6feb1dec5dfa698184a9.zip |
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>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java index bbc1b0f330..f39ecbecf2 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java @@ -125,12 +125,13 @@ class ShowPackDelta extends TextBuiltin { ptr++; ptr++; - @SuppressWarnings("resource" /* java 7 */) - TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(bufArray.length); - InflaterInputStream inf = new InflaterInputStream( - new ByteArrayInputStream(bufArray, ptr, bufArray.length)); - raw.copy(inf); - inf.close(); - return raw.toByteArray(); + try (TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap( + bufArray.length); + InflaterInputStream inf = new InflaterInputStream( + new ByteArrayInputStream(bufArray, ptr, + bufArray.length))) { + raw.copy(inf); + return raw.toByteArray(); + } } } |