Fix three null-safety bugs introduced with the map-based endpoints refactor#472
Merged
Conversation
Contributor
pathob
commented
May 11, 2026
- setUsers passed map values directly to setUser, which called findUser with a null username when the UserModel had no username field set; now passes the map key as a fallback username via a new setUser(directoryId, username, model) overload
- addUserToGroups silently omitted groups from the response when the user was already a member (MembershipAlreadyExistsException); the group is now included
- ApplicationLinkModelUtil.toApplicationLinkDetails passed a null Boolean to ApplicationLinkDetails.Builder.isPrimary(boolean), causing NPE when the primary field is absent in the request; now defaults to false via Boolean.TRUE.equals()
b85be0f to
943c325
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses three null-safety/edge-case regressions introduced by the map-based endpoints refactor in the Crowd users service and commons application link utilities.
Changes:
- Added
setUser(directoryId, username, model)and updatedsetUsers(...)to pass the map key as the username fallback. - Updated group-assignment behavior so groups are included in the response even when membership already exists.
- Made
ApplicationLinkModelUtil.toApplicationLinkDetails(...)null-safe forprimaryby defaulting tofalse.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crowd/src/main/java/com/deftdevs/bootstrapi/crowd/service/UsersServiceImpl.java |
Adds username-aware setUser overload, updates setUsers to use map keys, and includes already-existing group memberships in results. |
crowd/src/test/java/com/deftdevs/bootstrapi/crowd/service/UsersServiceTest.java |
Updates mocks for new overloads and adds tests for the new behavior (with a noted coverage gap for the setUsers null-username regression). |
commons/src/main/java/com/deftdevs/bootstrapi/commons/model/util/ApplicationLinkModelUtil.java |
Prevents NPE by converting nullable Boolean primary into a primitive boolean safely. |
commons/src/test/java/com/deftdevs/bootstrapi/commons/model/util/ApplicationLinkModelUtilTest.java |
Adds a regression test asserting primary == null results in isPrimary() == false. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…factor - setUsers passed map values directly to setUser, which called findUser with a null username when the UserModel had no username field set; now passes the map key as the lookup username via a new setUser(directoryId, username, model) overload, with the model's username used only as the desired new name on update (rename) - addUserToGroups silently omitted groups from the response when the user was already a member (MembershipAlreadyExistsException); the group is now included - ApplicationLinkModelUtil.toApplicationLinkDetails passed a null Boolean to ApplicationLinkDetails.Builder.isPrimary(boolean), causing NPE when the primary field is absent in the request; now defaults to false via Boolean.TRUE.equals()
943c325 to
8f64781
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


