EGitPatchHistoryTest: Open BufferedReader in try-with-resource
Change-Id: I74aede463c7b0a478a1e0e8b680c206d3964061d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
159388b1a6
commit
209bb6ea94
|
@ -202,28 +202,28 @@ static abstract class CommitReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
void read() throws IOException, InterruptedException {
|
void read() throws IOException, InterruptedException {
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(
|
try (BufferedReader in = new BufferedReader(
|
||||||
proc.getInputStream(), ISO_8859_1));
|
new InputStreamReader(proc.getInputStream(), ISO_8859_1))) {
|
||||||
String commitId = null;
|
String commitId = null;
|
||||||
TemporaryBuffer buf = null;
|
TemporaryBuffer buf = null;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
String line = in.readLine();
|
String line = in.readLine();
|
||||||
if (line == null)
|
if (line == null)
|
||||||
break;
|
break;
|
||||||
if (line.startsWith("commit ")) {
|
if (line.startsWith("commit ")) {
|
||||||
if (buf != null) {
|
if (buf != null) {
|
||||||
buf.close();
|
buf.close();
|
||||||
onCommit(commitId, buf.toByteArray());
|
onCommit(commitId, buf.toByteArray());
|
||||||
buf.destroy();
|
buf.destroy();
|
||||||
|
}
|
||||||
|
commitId = line.substring("commit ".length());
|
||||||
|
buf = new TemporaryBuffer.LocalFile(null);
|
||||||
|
} else if (buf != null) {
|
||||||
|
buf.write(line.getBytes(ISO_8859_1));
|
||||||
|
buf.write('\n');
|
||||||
}
|
}
|
||||||
commitId = line.substring("commit ".length());
|
|
||||||
buf = new TemporaryBuffer.LocalFile(null);
|
|
||||||
} else if (buf != null) {
|
|
||||||
buf.write(line.getBytes(ISO_8859_1));
|
|
||||||
buf.write('\n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.close();
|
|
||||||
assertEquals(0, proc.waitFor());
|
assertEquals(0, proc.waitFor());
|
||||||
proc = null;
|
proc = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue