Fix problem when call 'context.errantRecordReporter()' will result in a NoSuchMethodException or NoClassDefFoundError when the sink connector is deployed to Connect runtimes older than Kafka 2.6
@@ -75,7 +75,12 @@ public class CamelSinkTask extends SinkTask {
CamelSinkConnectorConfig config = getCamelSinkConnectorConfig(actualProps);
if (context != null) {
+ try {
reporter = context.errantRecordReporter();
+ } catch (NoSuchMethodError | NoClassDefFoundError e) {
+ LOG.warn("Unable to instantiate ErrantRecordReporter. Method 'SinkTaskContext.errantRecordReporter' does not exist.");
+ reporter = null;
+ }
}
try {
