Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-2582

JBossMQ recovery is closing result sets/statements in the wrong order

XMLWordPrintable

      The JBossMQ message recovery is closing result sets in the wrong order.
      This does not lead to a problem, but can lead to a "noisy" warning.

      synchronized protected void resolveAllUncommitedTXs() throws JMSException
      {
      TransactionManagerStrategy tms = new TransactionManagerStrategy();
      tms.startTX();
      Connection c = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      boolean threadWasInterrupted = Thread.interrupted();
      try

      { c = this.getConnection(); // Find out what the next TXID should be stmt = c.prepareStatement(SELECT_MAX_TX); rs = stmt.executeQuery(); if (rs.next()) nextTransactionId.set(rs.getLong(1) + 1); // HERE Missing rs.close() stmt.close(); <snip/> }

      finally
      {
      try

      { if (rs != null) rs.close(); }

      catch (Throwable ignore)
      {
      }
      try

      { if (stmt != null) stmt.close(); }

      catch (Throwable ignore)
      {
      }
      try

      { if (c != null) c.close(); }

      catch (Throwable ignore)
      {
      }
      tms.endTX();

      // Restore the interrupted state of the thread
      if (threadWasInterrupted)
      Thread.currentThread().interrupt();
      }
      }

      Additionally, if it is going to close JDBC artifacts inside the try block,
      it should "null" the object rather redundantly duplicating the close in the finally block and eating any exception.

      i.e.

      stmt.close();
      stmt = null;

              adrian.brock Adrian Brock (Inactive)
              adrian.brock Adrian Brock (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: