Commit a095673
Fix UnnecessaryThrows to check actual close() method exceptions (#812)
The recipe was incorrectly removing throws declarations from methods
using try-with-resources because it made blanket assumptions that all
Closeable types throw IOException and all AutoCloseable types throw
Exception.
Instead, the fix looks up the actual close() method on the resource
type and checks what exceptions it declares, using the same mechanism
already used for method invocations.
Fixes #728
Co-authored-by: Tim te Beek <tim@mac.home>1 parent a32c4e3 commit a095673
File tree
2 files changed
+27
-4
lines changed- src
- main/java/org/openrewrite/staticanalysis
- test/java/org/openrewrite/staticanalysis
2 files changed
+27
-4
lines changedLines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
88 | 109 | | |
89 | 110 | | |
90 | 111 | | |
| |||
0 commit comments