Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -15,6 +15,7 @@
*/
package io.polaris.core.persistence;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import io.polaris.core.entity.PolarisEntity;
import io.polaris.core.entity.PolarisGrantRecord;
Expand Down Expand Up @@ -45,6 +46,7 @@ public ResolvedPolarisEntity(
}

public ResolvedPolarisEntity(EntityCacheEntry cacheEntry) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public ResolvedPolarisEntity(EntityCacheEntry cacheEntry) {
public ResolvedPolarisEntity(@NotNull EntityCacheEntry cacheEntry) {

Preconditions.checkNotNull(cacheEntry, "An entity cache can't be null.");
Copy link
Member

Choose a reason for hiding this comment

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

The check is redundant, because recent JVMs throw meaningful NPEs telling that cacheEntry is null - the proposed message doesn't give any advice to users.

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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ private void validateMetadataFileInTableDir(
return storageInfoEntity;
}

private class BasePolarisViewOperations extends BaseViewOperations {
protected class BasePolarisViewOperations extends BaseViewOperations {
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was violating the visibility of BasePolarisViewOperations .

private final TableIdentifier identifier;
private final String fullViewName;
private FileIO viewFileIO;
Expand Down