if (ref == null) { log.warn("Could not find reference for message"); }
   public List undelivered(Filter filter)   {      // unreliable messages first      List undelivered = super.undelivered(filter);      try      {         List persisted = pm.messages(channelID);         for(Iterator i = persisted.iterator(); i.hasNext(); )         {            StorageIdentifier id = (StorageIdentifier)i.next();            if (!id.storeID.equals(ms.getStoreID()))            {               // TODO maybe the channel could have access to multiple stores               throw new IllegalStateException("My current message store (id=" + ms.getStoreID() +                                               ") cannot reference messages being maintained by " +                                               "the store with id=" + id.storeID);            }            // TODO filtering could be probably pushed to the database            MessageReference ref = ms.getReference(id.messageID);            // TODO very inefficient. Get rid of this when a reference will be able to fully support headers/properties            Message m = ref.getMessage();            if (filter == null || filter.accept(m))            {               undelivered.add(ref);            }         }      }      catch(Throwable t)      {         log.error("Cannot get message list from persistence manager", t);         return null;      }      return undelivered;   }