Files
Tagir Valeev f801cdb18f Do not split try when expression is in the first resource without catch/finally
It's unnecessary and otherwise try-block is automatically unwrapped
(see com.intellij.psi.impl.source.tree.java.PsiTryStatementImpl.deleteChildInternal) causing EA-235365 - PIEAE: LazyParseablePsiElement.getContainingFile

GitOrigin-RevId: 4ea3e54f8ea27854e23537a8de22f2923feaf842
2020-07-20 05:04:11 +00:00

22 lines
557 B
Java

// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.*;
public class Main {
interface MyAutoCloseable {
void close();
}
void test(List<MyAutoCloseable> list) {
MyAutoCloseable found = null;
for (MyAutoCloseable myAutoCloseable : list) {
if (myAutoCloseable != null) {
found = myAutoCloseable;
break;
}
}
try(MyAutoCloseable ac = found) {
System.out.println(ac);
}
}
}