Commit 3a3a941a by tonihei Committed by Oliver Woodman

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
parent 887116cd
...@@ -1052,12 +1052,15 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment