If no messages are added to a batch, don't call BatchWriter.finish() -

this allows the caller to avoid creating an empty packet by delaying
creation of the packet's header and trailer until something's written
to the packet's body. Changed the return semantics of
DatabaseComponent.generateBatch(ContactId, BatchWriter,
Collection<MessageId>) so that the IDs of messages considered for
inclusion in the batch but no longer sendable are also returned - this
allows the caller to remove them from the set of requested IDs.
This commit is contained in:
akwizgran
2011-07-28 11:17:33 +01:00
parent adee3e121c
commit cee4956b37
3 changed files with 48 additions and 30 deletions

View File

@@ -79,8 +79,9 @@ public interface DatabaseComponent {
/**
* Generates a batch of messages for the given contact from the given
* collection of requested messages, and returns the IDs of the messages
* added to the bacth.
* collection of requested messages, and returns the IDs of any messages
* that were either added to the batch, or were considered for inclusion
* but are no longer sendable to the contact.
*/
Collection<MessageId> generateBatch(ContactId c, BatchWriter b,
Collection<MessageId> requested) throws DbException, IOException;