Source:
private void execute(TopicPartition topicPart) throws IOException { Queue<SinkRecord> records = buffer.get(topicPart); if (states.get(topicPart).compareTo(State.WRITE_STARTED) < 0) { recover(topicPart); } while(!records.isEmpty()) { try { switch (states.get(topicPart)) { case WRITE_STARTED: pause(topicPart); nextState(topicPart); case WRITE_PARTITION_PAUSED: if (!schemas.containsKey(topicPart)) { getVersion(topicPart); } SinkRecord record = records.peek(); Schema valueSchema = record.valueSchema(); if (shouldRotate(topicPart)) { nextState(topicPart); } else if (shouldChangeSchema(topicPart, valueSchema)) { schemas.put(topicPart, valueSchema); versions.put(topicPart, valueSchema.version()); if (recordCounters.containsKey(topicPart) && recordCounters.get(topicPart) > 0) { nextState(topicPart); } else { break; } } else { SinkRecord projectedRecord = project(topicPart, record); writeRecord(topicPart, projectedRecord); records.poll(); break; } case SHOULD_ROTATE: closeTempfile(topicPart); nextState(topicPart); case TEMP_FILE_CLOSED: appendToWAL(topicPart); nextState(topicPart); case WAL_APPENDED: commitFile(topicPart); nextState(topicPart); case FILE_COMMITTED: setState(topicPart, State.WRITE_PARTITION_PAUSED); break; default: log.error("{} is not a valid state to write record.", states.get(topicPart)); } } catch (IllegalWorkerStateException e) { throw e; } catch (SchemaProjectorException e) { throw e; } catch (IOException | CopycatException e) { log.error("Exception on {}", topicPart); recordFailureTime(topicPart); setRetryBackoff(backOffMs); break; } } if (records.isEmpty()) { resume(topicPart); setState(topicPart, State.WRITE_STARTED); } }

Target:
private void execute(TopicPartition topicPart) throws IOException { Queue<SinkRecord> records = buffer.get(topicPart); if (states.get(topicPart).compareTo(State.WRITE_STARTED) < 0) { recover(topicPart); } while(!records.isEmpty()) { try { switch (states.get(topicPart)) { case WRITE_STARTED: pause(topicPart); nextState(topicPart); case WRITE_PARTITION_PAUSED: if (!schemas.containsKey(topicPart)) { getLastUsedSchema(topicPart); } SinkRecord record = records.peek(); Schema valueSchema = record.valueSchema(); if (shouldRotate(topicPart)) { nextState(topicPart); } else if (shouldChangeSchema(topicPart, valueSchema)) { schemas.put(topicPart, valueSchema); if (recordCounters.containsKey(topicPart) && recordCounters.get(topicPart) > 0) { nextState(topicPart); } else { break; } } else { SinkRecord projectedRecord = project(topicPart, record); writeRecord(topicPart, projectedRecord); records.poll(); break; } case SHOULD_ROTATE: closeTempfile(topicPart); nextState(topicPart); case TEMP_FILE_CLOSED: appendToWAL(topicPart); nextState(topicPart); case WAL_APPENDED: commitFile(topicPart); nextState(topicPart); case FILE_COMMITTED: setState(topicPart, State.WRITE_PARTITION_PAUSED); break; default: log.error("{} is not a valid state to write record.", states.get(topicPart)); } } catch (IllegalWorkerStateException e) { throw e; } catch (SchemaProjectorException e) { throw new RuntimeException(e); } catch (IOException | CopycatException e) { log.error("Exception on {}", topicPart); recordFailureTime(topicPart); setRetryBackoff(backOffMs); break; } } if (records.isEmpty()) { resume(topicPart); setState(topicPart, State.WRITE_STARTED); } }