IOStreamConstructorInspection: do not suggest fix in cases when FileNotFoundException is already handled (IDEA-288738)

GitOrigin-RevId: f55d0d899196a9db2fc9dfc2ab01fc7c5edb51bf
This commit is contained in:
Artemiy Sartakov authored and intellij-monorepo-bot committed 2022-02-16 15:37:05 +00:00
1 parent 0d90827381
commit a028df8220
5 files changed
+87

No files matched your search

@@ -0,0 +1,20 @@
// "Replace with 'Files.newInputStream'" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
class Foo {
void test(String str) {
try {
if (str.length() < 3) throw new FileNotFoundException("e");
try (InputStream in = Files.newInputStream(Paths.get(str))) {
}
catch (IOException e) {
System.out.println("Don't know what happened");
}
}
catch (FileNotFoundException e) {
System.out.println("file not found exception");
}
}
}
@@ -0,0 +1,15 @@
// "Replace with 'Files.newInputStream'" "false"
import java.io.*;
class Foo {
void test(String str) {
try(InputStream in = new FileInputStream(s<caret>tr)) {
}
catch (FileNotFoundException e) {
System.out.println("file not found exception");
}
catch (IOException e) {
System.out.println("Don't know what happened");
}
}
}
@@ -0,0 +1,15 @@
// "Replace with 'Files.newInputStream'" "false"
import java.io.*;
class Foo {
void test(String str) {
try(InputStream in = new FileInputStream(s<caret>tr)) {
}
catch (FileNotFoundException | RuntimeException e) {
System.out.println("file not found exception");
}
catch (IOException e) {
System.out.println("Don't know what happened");
}
}
}
@@ -0,0 +1,18 @@
// "Replace with 'Files.newInputStream'" "true"
import java.io.*;
class Foo {
void test(String str) {
try {
if (str.length() < 3) throw new FileNotFoundException("e");
try (InputStream in = new FileInputStream(st<caret>r)) {
}
catch (IOException e) {
System.out.println("Don't know what happened");
}
}
catch (FileNotFoundException e) {
System.out.println("file not found exception");
}
}
}