NIFI-9790: This closes #5860. Fixed race condition in which SwappablePriorityQueue could attempt to access the 0th element of an empty collection

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
Mark Payne 2022-03-11 16:28:31 -05:00 committed by Joe Witt
parent 237e481c4a
commit 7ff70706ee
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
1 changed files with 2 additions and 0 deletions

View File

@ -460,6 +460,8 @@ public class SwappablePriorityQueue {
// Because we cannot obtain the write lock while already holding the read lock, we set a flag so that we
// can migrate swap to active queue only after we've released the read lock.
mustMigrateSwapToActive = true;
} else if (swapQueue.isEmpty()) {
return FlowFileAvailability.ACTIVE_QUEUE_EMPTY;
} else {
top = swapQueue.get(0);
}