Skip to content

Commit e510206

Browse files
author
Dan Smillie
committed
Improve error messaging in HollowIncrementalCyclePopulator when Type being removed from IncrementalProducer does not have a primary key.
Previously, a generic NPE would be thrown when trying to construct the HollowPrimaryKeyIndex. Now the offending type will be included in the error.
1 parent 1fd1a84 commit e510206

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hollow/src/main/java/com/netflix/hollow/api/producer/HollowIncrementalCyclePopulator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ private BitSet markTypeRecordsToRemove(HollowReadStateEngine priorStateEngine, f
105105
HollowSchema schema = priorReadState.getSchema();
106106
int populatedOrdinals = priorReadState.getPopulatedOrdinals().length();
107107
if(schema.getSchemaType() == HollowSchema.SchemaType.OBJECT) {
108+
HollowObjectSchema objectSchema = (HollowObjectSchema) schema;
109+
if (objectSchema.getPrimaryKey() == null) {
110+
throw new IllegalArgumentException("Type " + type + " does not have a primary key defined");
111+
}
112+
108113
final HollowPrimaryKeyIndex idx = new HollowPrimaryKeyIndex(priorStateEngine, ((HollowObjectSchema) schema).getPrimaryKey()); ///TODO: Should we scan instead? Can we create this once and do delta updates?
109114

110115
ThreadSafeBitSet typeRecordsToRemove = new ThreadSafeBitSet(ThreadSafeBitSet.DEFAULT_LOG2_SEGMENT_SIZE_IN_BITS, populatedOrdinals);

0 commit comments

Comments
 (0)