IDEA-103114 ("Surround with try-with-resources" fixed to not lose last declaration element)

This commit is contained in:
Roman Shevchenko
2013-03-25 18:30:12 +01:00
parent 1fa59f5c65
commit a45a48cdac
4 changed files with 57 additions and 49 deletions
@@ -0,0 +1,13 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
class C {
void m(File file) throws IOException {
<caret>FileInputStream stream = new FileInputStream(file);
stream.getFD();
FileChannel channel1 = stream.getChannel(), channel2 = stream.getChannel();
channel1.close();
channel2.close();
}
}
@@ -0,0 +1,17 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
class C {
void m(File file) throws IOException {
FileChannel channel1;
FileChannel channel2;
try (FileInputStream stream = new FileInputStream(file)) {
stream.getFD();
channel1 = stream.getChannel();
channel2 = stream.getChannel();
}
channel1.close();
channel2.close();
}
}