Files
gerrit/java
Alice Kober-Sotzek ddf6fe57d1 Make porting comments resilient to diff failures
The diff computation can run into various errors, ranging from a diff
temporarily not being available due to replication lag in a multi-master
setup to the diff not existing as the auto-merge commit creation failed.
As comments are ported from various patchsets and sources
(e.g. patchset commits vs. parent commits vs. auto-merge commit), a
single failure would have meant that no ported comments were available
with the previous code even though some of them could have been
successfully ported.

This change increases the resilience of the ported comments endpoint by
catching individual diff errors and mapping only the affected comments
to a fallback position instead. At the moment, the fallback is the
patchset-level. If the diff errors don't occur on a later request
anymore, the corresponding comments will be ported as usual.

To test this error situation, we add unit tests. Unfortunately,
ChangeNotes is a very rich class referring to many other non-value
classes. Hence, we mock it. To simplify unit testing, we might consider
to refactor CommentPorter in the future to not use ChangeNotes as method
parameter. Instead, we could introduce a new value class which
provides the small amount of value classes (Change, Patchset instances,
Project.NameKey) CommentPorter needs.

Change-Id: I307c9b3a2d93668097b84d5f83345f8c9f49a1d4
2020-09-09 15:16:24 +02:00
..
2020-07-29 13:05:45 +02:00