Conversation View Color Exception fix #2319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Reviewed the checklist
Reviewed feedback from the "Sonar Cloud" bot. Note that you have to wait
for the "CI / Unit Tests") to complete first. Failed Unit tests can be
debugged by adding the label "verbose logging" to the GitHub PR.
Description of the Change
The issue was caused due to the (sender < colorPositions.length) check in the
DefaultConversationColorProvider
, where the sender is a vertex id and the colorPositions.length is graph Vertex count. The vertex ids are not in order for graphs created by file importer as it adds 2 vertices for each transaction and then merge unique vertices accordingly. This results in certain vertex Ids > graph Vertex count, failing the above check for certain valid Vertices.The same scenario can also occur on a graph manually created: On nodes last added after deleting some previously added nodes. (As explained below)
This is the intentional behavior of the code in in ElementStore.java: Vertex/Element ids are not guaranteed to be in order (stored in position2id) , only the Element positions (stored in id2position) are meant to be in order (and each being below Vertex count).

Hence I removed that check as it appears to lack any clear purpose. If we ever need to add a check here, we can validate the Element position instead.
Alternate Designs
If we ever need to add a check here, we can validate the Element position instead.
Initially I tried to rearrange the id2position array, to be similar to a graph opened by constellation, but it doesn't fix the issue on a graph later edited by removing nodes. Also the purpose of 2 arrays in ElementStore is also to facilitate this, making it an incorrect fix.
Why Should This Be In Core?
Fix exception
Benefits
Possible Drawbacks
n/a
Verification Process
Applicable Issues
#2271