public List<ChangeEvent<SourceRecord, SourceRecord>> pollNext() throws Exception {
        synchronized (lock) {
            while (next == null && error == null) {
                lock.wait();
            }
            List<ChangeEvent<SourceRecord, SourceRecord>> n = next;
            if (n != null) {
                next = null;
                lock.notifyAll();
                return n;
            } else {
                ExceptionUtils.rethrowException(error, error.getMessage());

                // this statement cannot be reached since the above method always throws an
                // exception this is only here to silence the compiler and any warnings
                return Collections.emptyList();
            }
        }
    }
Polls the next element from the Handover, possibly blocking until the next element is
available. This method behaves similar to polling from a blocking queue.

<p>If an exception was handed in by the producer ({@link #reportError(Throwable)}), then that
exception is thrown rather than an element being returned.</p>

@return The next element (buffer of records, never null).
@throws ClosedException Thrown if the Handover was {@link #close() closed}.
@throws Exception Rethrows exceptions from the {@link #reportError(Throwable)} method.
inlong-sort/sort-flink/cdc-base/src/main/java/org/apache/inlong/sort/cdc/base/debezium/internal/Handover.java