Description
The convertToDecimal function does a best-effort conversion of an arbitrary Object to a BigDecimal. Generally when a conversion cannot take place (such as when an unknown subclass is passed-in) the function throws a DataException. However, specifically for String inputs with valid number within, a ClassCastException is thrown.
This is because there is an extra "doubleValue" call in the implementation: https://github.com/apache/kafka/blob/ead2431c37ace9255df88ffe819bb905311af088/connect/api/src/main/java/org/apache/kafka/connect/data/Values.java#L427 which immediately causes a ClassCastException in the caller: https://github.com/apache/kafka/blob/ead2431c37ace9255df88ffe819bb905311af088/connect/api/src/main/java/org/apache/kafka/connect/data/Values.java#L305
This appears accidental, because the case for String is explicitly handled, it just behaves poorly. Instead of the ClassCastException, the number should be parsed correctly.
Attachments
Issue Links
- is related to
-
KAFKA-16289 Values.parseString on heterogeneous lists and maps sometimes corrupts data by inferring incorrect schema
- Resolved
- links to