use of org.apache.kafka.connect.errors.DataException in project kafka by apache.
the class OffsetUtils method validateFormat.
public static <K, V> void validateFormat(Map<K, V> offsetData) {
// that there's not usable concept of offsets in your source system.
if (offsetData == null)
return;
for (Map.Entry<K, V> entry : offsetData.entrySet()) {
if (!(entry.getKey() instanceof String))
throw new DataException("Offsets may only use String keys");
Object value = entry.getValue();
if (value == null)
continue;
Schema.Type schemaType = ConnectSchema.schemaType(value.getClass());
if (schemaType == null)
throw new DataException("Offsets may only contain primitive types as values, but field " + entry.getKey() + " contains " + value.getClass());
if (!schemaType.isPrimitive())
throw new DataException("Offsets may only contain primitive types as values, but field " + entry.getKey() + " contains " + schemaType);
}
}
Aggregations