From e6d124b31942eb18bd095fbc2ac4d1a3fd0f7dd4 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 18 Mar 2011 11:37:01 +0100 Subject: [PATCH] fix "JDBC resource opened but not safely closed" inspection in the presence of try-with-resources --- .../com/siyeh/ig/resources/ChannelResourceInspection.java | 2 +- .../src/com/siyeh/ig/resources/JDBCResourceInspection.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/ChannelResourceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/ChannelResourceInspection.java index 576f245e16d8..6e230e184f28 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/ChannelResourceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/ChannelResourceInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/JDBCResourceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/JDBCResourceInspection.java index 9ddccb073c4b..9bf4043f492b 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/JDBCResourceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/JDBCResourceInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,8 @@ public class JDBCResourceInspection extends ResourceInspection { return; } final PsiElement parent = getExpressionParent(expression); - if (parent instanceof PsiReturnStatement) { + if (parent instanceof PsiReturnStatement || + parent instanceof PsiResourceVariable) { return; } final PsiVariable boundVariable = getVariable(parent);