Skip to content

Commit

Permalink
RANGER-4439: fixed duplicate resource IDs in security zone service re…
Browse files Browse the repository at this point in the history
…sources

Signed-off-by: Madhan Neethiraj <[email protected]>
  • Loading branch information
suchnit authored and mneethiraj committed Sep 28, 2023
1 parent 83978aa commit 00fd78a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ public RangerSecurityZoneServiceHelper(RangerSecurityZoneService zoneService, St
zoneService.setResourcesBaseInfo(this.resourcesBaseInfo);
}

// compute nextResourceId
for (RangerSecurityZoneResourceBase baseInfo : resourcesBaseInfo) {
if (baseInfo.getId() != null && nextResourceId <= baseInfo.getId()) {
nextResourceId = baseInfo.getId() + 1;
}
}

// make sure resourcesBaseInfo has as many entries as resources
for (int i = resourcesBaseInfo.size(); i < resources.size(); i++) {
RangerSecurityZoneResourceBase baseInfo = new RangerSecurityZoneResourceBase();
Expand All @@ -223,13 +230,6 @@ public RangerSecurityZoneServiceHelper(RangerSecurityZoneService zoneService, St
resourcesBaseInfo.remove(i);
}

// compute nextResourceId
for (RangerSecurityZoneResourceBase baseInfo : resourcesBaseInfo) {
if (baseInfo.getId() != null && nextResourceId <= baseInfo.getId()) {
nextResourceId = baseInfo.getId() + 1;
}
}

// set missing IDs
for (RangerSecurityZoneResourceBase baseInfo : resourcesBaseInfo) {
if (baseInfo.getId() == null) {
Expand Down

0 comments on commit 00fd78a

Please sign in to comment.