Ensure messages get deleted if they throw an exception.

If a PlayerMessage throws an exception, it is currently not deleted from the
list of pending messages. This may be problematic as the list of pending
messages is kept when the player is retried without reset and the message is
sent again in such a case.

PiperOrigin-RevId: 247414494
This commit is contained in:
tonihei 2019-05-09 14:40:51 +01:00 committed by Oliver Woodman
parent 887116cd2d
commit 3a3a941abd

View File

@ -1052,12 +1052,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
&& nextInfo.resolvedPeriodIndex == currentPeriodIndex && nextInfo.resolvedPeriodIndex == currentPeriodIndex
&& nextInfo.resolvedPeriodTimeUs > oldPeriodPositionUs && nextInfo.resolvedPeriodTimeUs > oldPeriodPositionUs
&& nextInfo.resolvedPeriodTimeUs <= newPeriodPositionUs) { && nextInfo.resolvedPeriodTimeUs <= newPeriodPositionUs) {
try {
sendMessageToTarget(nextInfo.message); sendMessageToTarget(nextInfo.message);
} finally {
if (nextInfo.message.getDeleteAfterDelivery() || nextInfo.message.isCanceled()) { if (nextInfo.message.getDeleteAfterDelivery() || nextInfo.message.isCanceled()) {
pendingMessages.remove(nextPendingMessageIndex); pendingMessages.remove(nextPendingMessageIndex);
} else { } else {
nextPendingMessageIndex++; nextPendingMessageIndex++;
} }
}
nextInfo = nextInfo =
nextPendingMessageIndex < pendingMessages.size() nextPendingMessageIndex < pendingMessages.size()
? pendingMessages.get(nextPendingMessageIndex) ? pendingMessages.get(nextPendingMessageIndex)