public void putMessage(MqttWireMessage message,MqttToken token) throws MqttException {
  BufferedMessage bufferedMessage=new BufferedMessage(message,token);
synchronized (bufLock) {
    if (buffer.size() < bufferOpts.getBufferSize()) {
      buffer.add(bufferedMessage);
    }
 else     if (bufferOpts.isDeleteOldestMessages() == true) {
      buffer.remove(0);
      buffer.add(bufferedMessage);
    }
 else {
      throw new MqttException(MqttException.REASON_CODE_DISCONNECTED_BUFFER_FULL);
    }
  }
}

public void putMessage ( MqttWireMessage message , MqttToken token ) throws MqttException { BufferedMessage bufferedMessage = new BufferedMessage ( message , token ) ; synchronized ( bufLock ) { if ( buffer . size ( ) < bufferOpts . getBufferSize ( ) ) { buffer . add ( bufferedMessage ) ; } else if ( bufferOpts . isDeleteOldestMessages ( ) == true ) { buffer . remove ( 0 ) ; buffer . add ( bufferedMessage ) ; } else { throw new MqttException ( MqttException . REASON_CODE_DISCONNECTED_BUFFER_FULL ) ; } } }
this will add a new message to the offline buffer , if the buffer is full and deleteoldestmessages is enabled then the 0th item in the buffer will be deleted and the new message will be added . if it is not enabled then an mqttexception will be thrown .
