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>
This commit is contained in:
parent
6344e7a071
commit
ed9ede3446
|
@ -125,12 +125,13 @@ public void select(ObjectToPack otp, StoredObjectRepresentation next) {
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue