未验证 提交 cad09c4b 编写于 作者: J Jesse Glick 提交者: GitHub

Merge pull request #4137 from jglick/PeepholePermalink-leak-JENKINS-58733

[JENKINS-58733] Avoid a file handle leak in PeepholePermalink
......@@ -18,6 +18,7 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
......@@ -144,8 +145,8 @@ public abstract class PeepholePermalink extends Permalink implements Predicate<R
Map<String, Integer> cache = new TreeMap<>();
File storage = storageFor(buildDir);
if (storage.isFile()) {
try {
Files.lines(storage.toPath(), StandardCharsets.UTF_8).forEach(line -> {
try (Stream<String> lines = Files.lines(storage.toPath(), StandardCharsets.UTF_8)) {
lines.forEach(line -> {
int idx = line.indexOf(' ');
if (idx == -1) {
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册