SAP / kafka-connect-sap

Kafka Connect SAP is a set of connectors, using the Apache Kafka Connect framework for reliably connecting Kafka with SAP systems
Apache License 2.0
122 stars 56 forks source link

fix date/time related issues #39

Closed elakito closed 4 years ago

elakito commented 4 years ago

This PR fixes two date/time related issues.

  1. java.util.Date is instantiated with the local time zone and this may result in a Date instance with a non-hour value or the wrong date value. It may be unnoticed or results in the error.

    Caused by: org.apache.kafka.connect.errors.DataException: Kafka Connect Date type should not have any time fields set to non-zero values.
    at org.apache.kafka.connect.data.Date.fromLogical(Date.java:64)
    at io.confluent.connect.avro.AvroData$6.convert(AvroData.java:281)
    at io.confluent.connect.avro.AvroData.fromConnectData(AvroData.java:425)
    at io.confluent.connect.avro.AvroData.fromConnectData(AvroData.java:612)
    at io.confluent.connect.avro.AvroData.fromConnectData(AvroData.java:371)
    at io.confluent.connect.avro.AvroConverter.fromConnectData(AvroConverter.java:80)
    at org.apache.kafka.connect.storage.Converter.fromConnectData(Converter.java:62)
    at org.apache.kafka.connect.runtime.WorkerSourceTask.lambda$convertTransformedRecord$2(WorkerSourceTask.java:290)
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:128)
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:162)
    ... 11 more
  2. sql.Timestamp is instantiated at GenericJdbcTypeConverter.convertToJdbcTimeTypeFromAvroTimeType from the default string representation of avro date and not directly from its internal representation. As a result, the sub-seconds are dropped.