Menu

java5 pertable manager.java.vm

2007-08-27
2013-04-25
  • Carl J. Mosca

    Carl J. Mosca - 2007-08-27

    I am wondering about the decodeResultSetAsList method in this template.  The version I am working with contains the following:

    Is this code not clearing v if it is not null in all cases? (in the finally block)

        //28
        public List<$beanClass> decodeResultSetAsList(ResultSet rs, int[] fieldList, int startRow, int numRows) throws DAOException
        {
            List<$beanClass> v = new ArrayList<$beanClass>();
            int count = 0;
            try
            {
                if (rs.absolute(startRow) && numRows!=0)
                {
                    do
                    {
                        if(fieldList == null)
                            v.add(decodeRow(rs));
                        else
                            v.add(decodeRow(rs, fieldList));
                        count++;
                    } while ( (count<numRows||numRows<0) && rs.next() );
                }
                return v;
            }
            catch(SQLException e)
            {
                throw new DataAccessException(e);
            }
            finally
            {
                if (v != null) { v.clear(); v = null;}
            }
        }

     
    • Alain Fagot Béarez

      It was the intent in the other version, returning an array contructed directly from the temporary list.  Now this list itself should be returned, not erased!

      Thanks for finding this bug (now corrected;-).

      Alain.

       
    • Carl J. Mosca

      Carl J. Mosca - 2007-08-28

      Thank you Alain.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.