Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.polaris.core.entity.PolarisGrantRecord;
import io.polaris.core.persistence.cache.EntityCacheEntry;
import java.util.List;
import org.jetbrains.annotations.NotNull;

public class ResolvedPolarisEntity {
private final PolarisEntity entity;
Expand All @@ -44,7 +45,7 @@ public ResolvedPolarisEntity(
this.grantRecordsAsSecurable = grantRecordsAsSecurable;
}

public ResolvedPolarisEntity(EntityCacheEntry cacheEntry) {
public ResolvedPolarisEntity(@NotNull EntityCacheEntry cacheEntry) {
this.entity = PolarisEntity.of(cacheEntry.getEntity());
this.grantRecordsAsGrantee = ImmutableList.copyOf(cacheEntry.getGrantRecordsAsGrantee());
this.grantRecordsAsSecurable = ImmutableList.copyOf(cacheEntry.getGrantRecordsAsSecurable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ public PolarisResolvedPathWrapper getResolvedTopLevelEntity(
if (resolvedCacheEntry == null) {
return null;
}
return new PolarisResolvedPathWrapper(
List.of(getResolvedRootContainerEntity(), new ResolvedPolarisEntity(resolvedCacheEntry)));

ResolvedPolarisEntity resolvedRootContainerEntity = getResolvedRootContainerEntity();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are more calls to getResolvedRootContainerEntity() that can fail with a direct or indirect NPE.
@collado-mike WDYT?

return resolvedRootContainerEntity == null
? new PolarisResolvedPathWrapper(List.of(new ResolvedPolarisEntity(resolvedCacheEntry)))
: new PolarisResolvedPathWrapper(
List.of(resolvedRootContainerEntity, new ResolvedPolarisEntity(resolvedCacheEntry)));
}
}