In a Java 21 project, the storage of account members was changed and selection of the primary member for display was added.
You need to review the PR and find exactly 2 defects in the modified code after the changes. Both defects must be justified by the contract below and reproducible from the code. At least one defect is critical.
Contract for the mergeMembers function:
memberId, not by display name;memberId already exists, the already existing object from current must be preserved;memberId: first elements from current, then only new memberIds from incoming;primaryMemberName must return the name of the first member in the result, or "" if the result is empty.Execution context:
Reproduction steps for checking the contract:
javac/java without frameworks.mergeMembers on data where two different members have the same displayName but different memberId.mergeMembers on data where incoming contains the same memberId that is already present in current, but with a different displayName.primaryMemberName on an empty result and on a result with multiple members.You must specify which lines of the PR violate the contract, how it manifests, and how to verify the behavior.
Java 21, standard library, run in a normal JVM mode without frameworks and without hidden dependencies.
Use line comments to explain the problem, its impact, the fix and how to test it.