Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3430

FP S2095(UnclosedResourcesCheck) on java.sql.ResultSet

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      According to the java documentation of java.sql.Statement#close():

      Note: When a Statement object is closed, its current ResultSet object, if one exists, is also closed.
      

      It's not mandatory to close the ResultSet if the Statement is properly closed. The following issue is a false-positive:

          try(Statement stmt = con.createStatement()) {
            ResultSet rs = stmt.executeQuery("SELECT a FROM tbl"); // false-positive
            // ...
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              alban.auzeill Alban Auzeill
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: