Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
fix(tags): NPE if tag has no restricted groups
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGeraud authored and aelamrani committed May 3, 2019
1 parent 01fd4f6 commit b0b4c29
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import static io.gravitee.repository.management.model.Audit.AuditProperties.TAG;
import static io.gravitee.repository.management.model.Tag.AuditEvent.*;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
Expand Down Expand Up @@ -188,8 +189,8 @@ public Set<String> findByUser(final String user) {
.map(TagEntity::getId)
.collect(toSet());
} else {
final Set<String> restrictedTags = findAll().stream()
.filter(tag -> !tag.getRestrictedGroups().isEmpty())
final Set<String> restrictedTags = tags.stream()
.filter(tag -> tag.getRestrictedGroups()!= null && !tag.getRestrictedGroups().isEmpty())
.map(TagEntity::getId)
.collect(toSet());

Expand All @@ -198,7 +199,7 @@ public Set<String> findByUser(final String user) {
.collect(toSet());

return tags.stream()
.filter(tag -> !restrictedTags.contains(tag.getId()) || anyMatch(tag.getRestrictedGroups(), groups))
.filter(tag -> !restrictedTags.contains(tag.getId()) || (tag.getRestrictedGroups()!= null && anyMatch(tag.getRestrictedGroups(), groups)))
.map(TagEntity::getId)
.collect(toSet());
}
Expand Down

0 comments on commit b0b4c29

Please sign in to comment.