Browse Source

DirCacheCheckoutTest: Open FileInputStream in try-with-resource

Change-Id: I3ceef36803752a19a4d74910b4db26c01279fd99
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
b9a03c69b3
  1. 24
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java

24
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java

@ -1923,18 +1923,20 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
if (file.isFile()) {
assertNotNull("found unexpected file for path " + path
+ " in workdir", expectedValue);
FileInputStream is = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
int offset = 0;
int numRead = 0;
while (offset < buffer.length
&& (numRead = is.read(buffer, offset, buffer.length
- offset)) >= 0) {
offset += numRead;
try (FileInputStream is = new FileInputStream(file)) {
byte[] buffer = new byte[(int) file.length()];
int offset = 0;
int numRead = 0;
while (offset < buffer.length
&& (numRead = is.read(buffer, offset,
buffer.length - offset)) >= 0) {
offset += numRead;
}
assertArrayEquals(
"unexpected content for path " + path
+ " in workDir. ",
buffer, i.get(path).getBytes());
}
is.close();
assertArrayEquals("unexpected content for path " + path
+ " in workDir. ", buffer, i.get(path).getBytes());
nrFiles++;
} else if (file.isDirectory()) {
String[] files = file.list();

Loading…
Cancel
Save