hollow
hollow copied to clipboard
Thread safety issue in implicit type state initialization
I have a class I use only in the populator that isn't part of my API (I need to feed MemoizedLists as early as I can and I need a intermediate holder so it gets the correct type). That means that the type state isn't initialized when I start producing these objects concurrently, which leads to:
Exception in thread "DefaultDispatcher-worker-9" java.lang.NullPointerException
at com.netflix.hollow.core.write.objectmapper.HollowTypeMapper.cycleSpecificAssignedOrdinalBits(HollowTypeMapper.java:81)
at com.netflix.hollow.core.write.objectmapper.HollowListTypeMapper.write(HollowListTypeMapper.java:64)
at com.netflix.hollow.core.write.objectmapper.HollowObjectTypeMapper$MappedField.copy(HollowObjectTypeMapper.java:452)
at com.netflix.hollow.core.write.objectmapper.HollowObjectTypeMapper.write(HollowObjectTypeMapper.java:165)
at com.netflix.hollow.core.write.objectmapper.HollowObjectMapper.add(HollowObjectMapper.java:70)
at com.netflix.hollow.api.producer.CloseableWriteState.add(CloseableWriteState.java:48)
Looks like a race on getting the HollowWriteStateEngine set via com.netflix.hollow.core.write.HollowTypeWriteState#setStateEngine, though if this can race, there's probably other parts of type write state init that's not thread safe.
I worked around the issue by adding an explicit call to writeState.objectMapper.initializeTypeState() for that class before I start producing them.