#vulnerable code 
                              @Test
  public void testExecutionWithNotSupportedMethods(
      @Mocked final JDBCDatabaseMetaData meta) {
    try {
      new Expectations() {
        {
          // prevent calls to functions that also call resultSet.next
          meta.getDatabaseProductName();
          result = "hsqldb";
          // prevent calls to functions that also call resultSet.next
          meta.getDatabaseProductVersion();
          result = "1.0";

          // emulate apache hive behavior
          meta.supportsTransactionIsolationLevel(4);
          result = new SQLException("Method not supported");
        }
      };
      SqlLine sqlLine = new SqlLine();
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      PrintStream sqllineOutputStream =
          new PrintStream(os, false, StandardCharsets.UTF_8.name());
      sqlLine.setOutputStream(sqllineOutputStream);
      sqlLine.setErrorStream(sqllineOutputStream);
      String[] args = {
          "-d",
          "org.hsqldb.jdbcDriver",
          "-u",
          "jdbc:hsqldb:res:scott",
          "-n",
          "SCOTT",
          "-p",
          "TIGER"
      };
      DispatchCallback dc = new DispatchCallback();
      sqlLine.initArgs(args, dc);
      os.reset();
      sqlLine.runCommands(dc,
          "!set incremental true",
          "values 1;");
      final String output = os.toString("UTF8");
      final String line0 = "+-------------+";
      final String line1 = "|     C1      |";
      final String line2 = "+-------------+";
      final String line3 = "| 1           |";
      final String line4 = "+-------------+";
      assertThat(output,
          CoreMatchers.allOf(containsString(line0),
              containsString(line1),
              containsString(line2),
              containsString(line3),
              containsString(line4)));
    } catch (Throwable t) {
      // fail
      throw new RuntimeException(t);
    }
  } 
                            #location 24 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              @Test
  public void testExecutionWithNotSupportedMethods(
      @Mocked final JDBCDatabaseMetaData meta) {
    try {
      new Expectations() {
        {
          // prevent calls to functions that also call resultSet.next
          meta.getDatabaseProductName();
          result = "hsqldb";
          // prevent calls to functions that also call resultSet.next
          meta.getDatabaseProductVersion();
          result = "1.0";

          // emulate apache hive behavior
          meta.supportsTransactionIsolationLevel(4);
          result = new SQLException("Method not supported");
        }
      };
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      PrintStream sqllineOutputStream =
          new PrintStream(os, false, StandardCharsets.UTF_8.name());
      sqlLine.setOutputStream(sqllineOutputStream);
      sqlLine.setErrorStream(sqllineOutputStream);
      String[] args = {
          "-d",
          "org.hsqldb.jdbcDriver",
          "-u",
          "jdbc:hsqldb:res:scott",
          "-n",
          "SCOTT",
          "-p",
          "TIGER"
      };
      DispatchCallback dc = new DispatchCallback();
      sqlLine.initArgs(args, dc);
      os.reset();
      sqlLine.runCommands(dc,
          "!set incremental true",
          "values 1;");
      final String output = os.toString("UTF8");
      final String line0 = "+-------------+";
      final String line1 = "|     C1      |";
      final String line2 = "+-------------+";
      final String line3 = "| 1           |";
      final String line4 = "+-------------+";
      assertThat(output,
          CoreMatchers.allOf(containsString(line0),
              containsString(line1),
              containsString(line2),
              containsString(line3),
              containsString(line4)));
    } catch (Throwable t) {
      // fail
      throw new RuntimeException(t);
    }
  }