Skip to content

Commit 32ee220

Browse files
committed
use try with resources
1 parent 156e3df commit 32ee220

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/ChecksumEnforcingInputStreamTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ public class ChecksumEnforcingInputStreamTest {
3232
private final MessageDigest digest = EndToEndChecksumHandler.getMessageDigestInstance();
3333

3434
public void test(int payloadSize) throws Exception {
35-
ChecksumEnforcingInputStream testInstance = setUpData(payloadSize);
3635
// read 1000 bytes at a time
3736
// Since checksum should be correct, do not expect IOException
38-
byte[] buf = new byte[1000];
39-
try {
37+
try (ChecksumEnforcingInputStream testInstance = setUpData(payloadSize)) {
38+
byte[] buf = new byte[1000];
4039
while (testInstance.read(buf, 0, 1000) != -1) {
4140
// do nothing with the bytes read
4241
}
4342
} catch (IOException e) {
4443
fail("checksum verification failed!");
45-
} finally {
46-
testInstance.close();
4744
}
4845
}
4946

0 commit comments

Comments
 (0)