private int addFramesForCompleteMessage() {
        boolean added = false;
        EncryptFrame frame = null;
        int delta = 0;

        while (!added && (frame = m_encryptedFrames.poll()) != null) {
            if (!frame.isLast()) {
                //TODO: Review - I don't think this synchronized(m_partialMessages) is required.
                // This is the only method with synchronized(m_partialMessages) and
                // it doesn't look like this method will be called from multiple threads concurrently.
                // Take this out 8.0 release.
                synchronized(m_partialMessages) {
                    m_partialMessages.add(frame);
                    ++m_partialSize;
                }
                continue;
            }

            final int partialSize = m_partialSize;
            if (partialSize > 0) {
                assert frame.chunks == partialSize + 1
                        : "partial frame buildup has wrong number of preceding pieces";

                //TODO: Review - I don't think this synchronized(m_partialMessages) is required.
                // See comment above.
                // Take this out 8.0 release.
                synchronized(m_partialMessages) {
                    for (EncryptFrame frm: m_partialMessages) {
                        m_encryptedMessages.addComponent(true, frm.frame);
                        delta += frm.delta;
                    }
                    m_partialMessages.clear();
                    m_partialSize = 0;
                }
            }
            m_encryptedMessages.addComponent(true, frame.frame);
            delta += frame.delta;

            m_numEncryptedMessages += frame.msgs;
            added = true;
        }
        return added ? delta : -1;
    }
private int addFramesForCompleteMessage ( ) { boolean added = false ; EncryptFrame frame = null ; int delta = 0 ; while ( ! added && ( frame = m_encryptedFrames . poll ( ) ) != null ) { if ( ! frame . isLast ( ) ) { synchronized ( m_partialMessages ) { m_partialMessages . add ( frame ) ; ++ m_partialSize ; } continue ; } final int partialSize = m_partialSize ; if ( partialSize > 0 ) { assert frame . chunks == partialSize + 1 : "partial frame buildup has wrong number of preceding pieces" ; synchronized ( m_partialMessages ) { for ( EncryptFrame frm : m_partialMessages ) { m_encryptedMessages . addComponent ( true , frm . frame ) ; delta += frm . delta ; } m_partialMessages . clear ( ) ; m_partialSize = 0 ; } } m_encryptedMessages . addComponent ( true , frame . frame ) ; delta += frame . delta ; m_numEncryptedMessages += frame . msgs ; added = true ; } return added ? delta : - 1 ; }
Gather all the frames that comprise a whole Volt Message
Returns the delta between the original message byte count and encrypted message byte count.