Handle null chosenHandler in RuntimeDelegatingTypeHandler
private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeDelegatingTypeHandler.class);
- // TODO: Use Optional
private TypeHandler<T> delegateHandler;
private TypeInfo<T> typeInfo;
private TypeSerializationLibrary typeSerializationLibrary;
@@ -96,6 +95,11 @@ public PersistedData serializeNonNull(T value, PersistedDataSerializer serialize
.orElse(delegateHandler);
}
+ if (chosenHandler == null) {
+ LOGGER.error("Could not find appropriate TypeHandler for runtime type {}", runtimeClass);
+ return serializer.serializeNull();
+ }
+
if (chosenHandler == delegateHandler) {
return delegateHandler.serialize(value, serializer);
}
