GroupChat History message order


When I try a MUC groupchat and receive the history the messages sometimes come in a wrong order. This happens only sometimes and the order is random. Any idea whats going on there?I debug openfire3.6.4 the sound code, found sends a historic record after the joinRoom() method, Thread.sleep(1000), the historical demonstration is correct. why? And how do I solve it?

if (historyRequest == null) {
            Iterator history = roomHistory.getMessageHistory();
            while (history.hasNext()) {
                /**original is:
                 *joinRole.send( (Message);
                 */                 Message m = (Message);
                try {
                } catch (InterruptedException e) {

PATCH: CM out of order messages (plus more)