[release/3.8] 修复 ManagedProcess#getLines 完成后不会解除锁定的问题 (#4982)
https://github.com/HMCL-dev/HMCL/pull/4913
This commit is contained in:
1 parent
d577e1fe30
commit
6ef823b5ba
1 file changed
+11
-8
@@ -113,16 +113,19 @@ public final class ManagedProcess {
|
||||
*/
|
||||
public List<String> getLines(Predicate<String> lineFilter) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (lineFilter == null)
|
||||
return List.copyOf(lines);
|
||||
|
||||
if (lineFilter == null)
|
||||
return List.copyOf(lines);
|
||||
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
for (String line : this.lines) {
|
||||
if (lineFilter.test(line))
|
||||
res.add(line);
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
for (String line : this.lines) {
|
||||
if (lineFilter.test(line))
|
||||
res.add(line);
|
||||
}
|
||||
return Collections.unmodifiableList(res);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
return Collections.unmodifiableList(res);
|
||||
}
|
||||
|
||||
public void addLine(String line) {
|
||||
|
||||
Reference in new issue
Block a user