Skip to content

Commit

Permalink
fix: added a check to address NPE in home page when user has no organ…
Browse files Browse the repository at this point in the history
…ization (appsmithorg#8259)
  • Loading branch information
nayan-rafiq authored Oct 8, 2021
1 parent 8590ff3 commit 72dd22d
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@ public Mono<UserHomepageDTO> getAllApplications() {
User user = userAndUserDataTuple.getT1();
UserData userData = userAndUserDataTuple.getT2();

UserHomepageDTO userHomepageDTO = new UserHomepageDTO();
userHomepageDTO.setUser(user);

Set<String> orgIds = user.getOrganizationIds();
if(CollectionUtils.isEmpty(orgIds)) {
userHomepageDTO.setOrganizationApplications(new ArrayList<>());
return Mono.just(userHomepageDTO);
}

// create a set of org id where recently used ones will be at the beginning
List<String> recentlyUsedOrgIds = userData.getRecentlyUsedOrgIds();
Set<String> orgIdSortedSet = new LinkedHashSet<>(orgIds.size());
Set<String> orgIdSortedSet = new LinkedHashSet<>();
if(recentlyUsedOrgIds != null && recentlyUsedOrgIds.size() > 0) {
// user has a recently used list, add them to the beginning
orgIdSortedSet.addAll(recentlyUsedOrgIds);
Expand All @@ -86,9 +93,6 @@ public Mono<UserHomepageDTO> getAllApplications() {
.findByMultipleOrganizationIds(orgIds, READ_APPLICATIONS)
.collectMultimap(Application::getOrganizationId, Function.identity());

UserHomepageDTO userHomepageDTO = new UserHomepageDTO();
userHomepageDTO.setUser(user);

return organizationService
.findByIdsIn(orgIds, READ_ORGANIZATIONS)
.collectMap(Organization::getId, v -> v)
Expand Down

0 comments on commit 72dd22d

Please sign in to comment.