Skip to content

Commit

Permalink
Fixed handling of Instruction notifications in case of re-entrance.
Browse files Browse the repository at this point in the history
Now first clear the list, then notify to avoid that when re-entering the same instruction is notified multiple times.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Feb 8, 2024
1 parent 91fb6ec commit 63c9951
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,21 @@ public String toString()

private void notifyInstructionHandler()
{
if (!_instructions.isEmpty())
_handler.onInstructions(_instructions);
if (_instructions.isEmpty())
return;
// Copy the list to avoid re-entrance.
List<Instruction> instructions = List.copyOf(_instructions);
_instructions.clear();
_handler.onInstructions(instructions);
}

private void notifyMetaDataHandler(boolean wasBlocked)
{
if (_metaDataNotifications.isEmpty())
return;
// Copy the list to avoid re-entrance, where the call to
// notifyHandler() may end up calling again this method.
List<MetaDataNotification> notifications = new ArrayList<>(_metaDataNotifications);
List<MetaDataNotification> notifications = List.copyOf(_metaDataNotifications);
_metaDataNotifications.clear();
for (MetaDataNotification notification : notifications)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,12 @@ private static int encodeInsertCount(int reqInsertCount, int maxTableCapacity)

private void notifyInstructionHandler()
{
if (!_instructions.isEmpty())
_handler.onInstructions(_instructions);
if (_instructions.isEmpty())
return;
// Copy the list to avoid re-entrance.
List<Instruction> instructions = List.copyOf(_instructions);
_instructions.clear();
_handler.onInstructions(instructions);
}

InstructionHandler getInstructionHandler()
Expand Down

0 comments on commit 63c9951

Please sign in to comment.