User: dmaplesden
  Date: 01/09/02 14:33:21

  Modified:    src/main/org/jboss/mq/pm/file PersistenceManager.java
  Log:
  Fix reported bug in file PM.  You could get a NPE if transactFiles was null.
  
  Revision  Changes    Path
  1.5       +27 -22    jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManager.java
  
  Index: PersistenceManager.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistenceManager.java   2001/09/01 03:00:59     1.4
  +++ PersistenceManager.java   2001/09/02 21:33:21     1.5
  @@ -35,7 +35,7 @@
    *  persistence.
    *
    * @author     Paul Kendall ([EMAIL PROTECTED])
  - * @version    $Revision: 1.4 $
  + * @version    $Revision: 1.5 $
    */
   public class PersistenceManager extends ServiceMBeanSupport implements 
PersistenceManagerMBean, org.jboss.mq.pm.PersistenceManager
   {
  @@ -143,30 +143,32 @@
         //reconstruct TXs
         TreeSet txs = new TreeSet();
         File[] transactFiles = dataDirFile.listFiles();
  -      for (int i = 0; i < transactFiles.length; i++)
  +      if(transactFiles != null)
         {
  -         try
  +         for (int i = 0; i < transactFiles.length; i++)
            {
  -            Long tx = new Long(Long.parseLong(transactFiles[i].getName()));
  -            java.util.ArrayList removingMessages = readTxFile(transactFiles[i]);
  -            if (testRollBackTx(tx, removingMessages))
  +            try
               {
  -               txs.add(tx);
  +               Long tx = new Long(Long.parseLong(transactFiles[i].getName()));
  +               java.util.ArrayList removingMessages = readTxFile(transactFiles[i]);
  +               if (testRollBackTx(tx, removingMessages))
  +               {
  +                  txs.add(tx);
  +               }
               }
  -         }
  -         catch (NumberFormatException e)
  -         {
  -            System.out.println("Ignoring invalid transaction record file " + 
transactFiles[i].getAbsolutePath());
  -            transactFiles[i] = null;
  -         }
  -         catch (IOException e)
  -         {
  -            JMSException jmse = new SpyJMSException("IO Error when restoring.");
  -            jmse.setLinkedException(e);
  -            throw jmse;
  +            catch (NumberFormatException e)
  +            {
  +               System.out.println("Ignoring invalid transaction record file " + 
transactFiles[i].getAbsolutePath());
  +               transactFiles[i] = null;
  +            }
  +            catch (IOException e)
  +            {
  +               JMSException jmse = new SpyJMSException("IO Error when restoring.");
  +               jmse.setLinkedException(e);
  +               throw jmse;
  +            }
            }
         }
  -
         if (!txs.isEmpty())
         {
            this.tidcounter = ((Long)txs.last()).longValue() + 1;
  @@ -199,11 +201,14 @@
         }
   
         //all txs now committed or rolled back so delete tx files
  -      for (int i = 0; i < transactFiles.length; i++)
  +      if(transactFiles != null)
         {
  -         if (transactFiles[i] != null)
  +         for (int i = 0; i < transactFiles.length; i++)
            {
  -            deleteTxFile(transactFiles[i]);
  +            if (transactFiles[i] != null)
  +            {
  +               deleteTxFile(transactFiles[i]);
  +            }
            }
         }
      }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to