diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ConvertCatchToThrowsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ConvertCatchToThrowsIntention.java index df340db6e5da..683a87083e2a 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ConvertCatchToThrowsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ConvertCatchToThrowsIntention.java @@ -61,7 +61,7 @@ public class ConvertCatchToThrowsIntention extends Intention { addToThrowsList(throwsList, catchType); final PsiTryStatement tryStatement = catchSection.getTryStatement(); final PsiCatchSection[] catchSections = tryStatement.getCatchSections(); - if (catchSections.length > 1 || tryStatement.getResourceList() != null) { + if (catchSections.length > 1 || tryStatement.getResourceList() != null || tryStatement.getFinallyBlock() != null) { catchSection.delete(); } else { diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection.java new file mode 100644 index 000000000000..3792dd44a789 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection.java @@ -0,0 +1,13 @@ +class C { + void f() { + try { + System.out.println(); + } + catch (Exception exception) { + exception.printStackTrace(); + } + finally { + System.out.println(); + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection_after.java new file mode 100644 index 000000000000..8118a5cddccb --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/exceptions/catchToThrows/LeaveFinallySection_after.java @@ -0,0 +1,9 @@ +class C { + void f() throws Exception { + try { + System.out.println(); + } finally { + System.out.println(); + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/exceptions/ConvertCatchToThrowsTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/exceptions/ConvertCatchToThrowsTest.java index 4d4814fca6bd..737d40e0cc39 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/exceptions/ConvertCatchToThrowsTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/exceptions/ConvertCatchToThrowsTest.java @@ -26,6 +26,7 @@ public class ConvertCatchToThrowsTest extends IPPTestCase { public void testArmWithSingleCatch() { doTest(); } public void testExistingThrows() { doTest(); } public void testLambda() { doTest(); } + public void testLeaveFinallySection() { doTest(); } @Override protected String getIntentionName() {