Skip to content

Commit

Permalink
MID-8582 fix: another NPE fix, roleRef.getOid() can also be null
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Mar 14, 2023
1 parent e71e18b commit e98eaa1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,12 @@ private void addAssignmentPathValueMetadataValues(PrismReferenceValue roleRef,
ObjectReferenceType assignmentTargetRef = assignment.getTargetRef();
// We can get here with roleRef->X and assignment/targetRef->Y, in which case we do nothing.
if (assignmentTargetRef != null
// assignmentTargetRef.getOid can be null?! e.g. during TestAssignmentApprovalGlobal#initSystem
&& roleRef.getOid().equals(assignmentTargetRef.getOid())
// assignmentTargetRef.getOid can be null, e.g. for dynamically evaluated refs with filter
// TODO: This actually means that this is not the best place for this metadata logic.
// It probably really should be somewhere in TargetEvaluation/TargetMembershipCollector#collect.
// That would also fix the case of metadata for such refs with filter - which is now BROKEN.
// TestPreviewChangesCoD.test150 also randomly creates state when roleRef.getOid() is null.
&& Objects.equals(roleRef.getOid(), assignmentTargetRef.getOid())
&& QNameUtil.match(assignmentTargetRef.getRelation(), roleRef.getRelation())) {
addAssignmentPathValueMetadataValue(roleRef, evaluatedAssignment,
new AssignmentPathType().segment(new AssignmentPathSegmentType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ public void test560AddUserAndThenAddApproverAssignment() throws Exception {
.isEqualTo(SchemaConstants.ORG_APPROVER);
}

// TODO add assignment with targetRef with filter

private void segmentsHaveExpectedRelations(
UserAsserter<Void> userAsserter, String membershipTargetOid, QName... expectedRelations)
throws SchemaException {
Expand Down

0 comments on commit e98eaa1

Please sign in to comment.