GC: Close File.lines stream
From File#lines javadoc: The returned stream from File Lines encapsulates a Reader. If timely disposal of file system resources is required, the try-with-resources construct should be used to ensure that the stream's close method is invoked after the stream operations are completed. Wrap File.lines with try-with-resources. Signed-off-by: Xing Huang <xingkhuang@google.com> Change-Id: I82c6faa3ef1083f6c7e964f96e9540b4db18eee8 Signed-off-by: Xing Huang <xingkhuang@google.com>
This commit is contained in:
parent
228e4de484
commit
172a207945
|
@ -1792,8 +1792,9 @@ private void failedToLock() {
|
||||||
|
|
||||||
private void gcAlreadyRunning() {
|
private void gcAlreadyRunning() {
|
||||||
close();
|
close();
|
||||||
try {
|
Optional<String> s;
|
||||||
Optional<String> s = Files.lines(pidFile).findFirst();
|
try (Stream<String> lines = Files.lines(pidFile)) {
|
||||||
|
s = lines.findFirst();
|
||||||
String machine = null;
|
String machine = null;
|
||||||
String pid = null;
|
String pid = null;
|
||||||
if (s.isPresent()) {
|
if (s.isPresent()) {
|
||||||
|
|
Loading…
Reference in New Issue