Alexis Mestag created COLLECTIONS-592:
-----------------------------------------
Summary: Deletions/insertions get lost in the ReplacementsFinder
if they're at the end of the compared sequences
Key: COLLECTIONS-592
URL: https://issues.apache.org/jira/browse/COLLECTIONS-592
Project: Commons Collections
Issue Type: Bug
Affects Versions: 4.1, 4.0
Reporter: Alexis Mestag
Priority: Minor
In the {{sequence}} package, when comparing 2 lists with a
{{SequencesComparator}} and visiting the {{EditScript}} with a
{{ReplacementsFinder}}, pending deletions and insertions get lost in the
{{ReplacementsFinder}} when they're at the end of the sequences.
The {{ReplacementsFinder}} stores the deletions and insertions until it
encounters a {{KeepCommand}}, when it flushes the pending commands by
triggering the {{handleReplacement}} method of its {{ReplacementHandler}}.
The problem is, when edit commands are at the end of the sequences, the
{{ReplacementsFinder}} will never encounter a {{KeepCommand}} to flush them, so
they're stuck here and will never be handed over the {{ReplacementHandler}}.
To fix this behavior in client code, one can manually call
{{ReplacementsFinder.visitKeepCommand(null)}} after the {{EditScript.visit()}}
call.
I patched this bug in the library by adding a {{CommandVisitor.endOfVisit}}
method and calling it at the end of the {{EditScript.visit}} method, so it
allows to flush the pending deletions/insertions in the {{ReplacementsFinder}}
when the end of the {{EditScript}} is reached.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)