Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2515#discussion_r173858341
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/CurrentUserEndpointMerger.java
---
@@ -53,6 +54,23 @@ protected void mergeResponses(final CurrentUserEntity
clientEntity, final Map<No
mergePermissions(clientEntity.getPoliciesPermissions(),
entity.getPoliciesPermissions());
mergePermissions(clientEntity.getProvenancePermissions(),
entity.getProvenancePermissions());
mergePermissions(clientEntity.getTenantsPermissions(),
entity.getTenantsPermissions());
+ mergePermissions(clientEntity.getSystemPermissions(),
entity.getSystemPermissions());
+ mergePermissions(clientEntity.getTenantsPermissions(),
entity.getTenantsPermissions());
+
+ final Set<ComponentRestrictionPermissionDTO>
clientEntityComponentRestrictionsPermissions =
clientEntity.getComponentRestrictionPermissions();
+ final Set<ComponentRestrictionPermissionDTO>
entityComponentRestrictionsPermissions =
entity.getComponentRestrictionPermissions();
+
+ // only retain the component restriction permissions in
common
+
clientEntityComponentRestrictionsPermissions.retainAll(entityComponentRestrictionsPermissions);
+
+ // merge the component restriction permissions
+
clientEntityComponentRestrictionsPermissions.forEach(clientEntityPermission -> {
+ final ComponentRestrictionPermissionDTO
entityPermission =
entityComponentRestrictionsPermissions.stream().filter(entityComponentRestrictionsPermission
-> {
+ return
entityComponentRestrictionsPermission.getRequiredPermission().getId().equals(clientEntityPermission.getRequiredPermission().getId());
+ }).findFirst().orElse(null);
--- End diff --
Are we guaranteed at this point that there will be at least one entry? If
so, then we should probably just use findFirst().get() because it makes this
more clear. If not, then we could end up with a null value here, and the next
line would then throw a NPE.
---