Copilot commented on code in PR #4368:
URL: https://github.com/apache/flink-cdc/pull/4368#discussion_r3057437176


##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-elasticsearch/src/main/java/org/apache/flink/cdc/connectors/elasticsearch/v2/Elasticsearch8AsyncWriter.java:
##########
@@ -166,13 +167,13 @@ private void handleFailedRequest(
         numRecordsOutErrorsCounter.inc(requestEntries.size());
 
         if (isRetryable(error.getCause())) {

Review Comment:
   `handleFailedRequest(...)` calls `isRetryable(error.getCause())`. If 
`error.getCause()` is null (which is possible for many exception types), this 
will lead to a `NullPointerException` inside 
`isRetryable`/`FatalExceptionClassifier`, masking the real failure. Pass a 
non-null throwable (e.g., `error.getCause() != null ? error.getCause() : 
error`) or update `isRetryable` to handle null safely.
   ```suggestion
           Throwable retryableError = error.getCause() != null ? 
error.getCause() : error;
           if (isRetryable(retryableError)) {
   ```



##########
flink-cdc-flink1-compat/src/main/java/org/apache/flink/connector/base/sink/AsyncSinkBaseAdapter.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.connector.base.sink;
+
+import org.apache.flink.api.connector.sink2.StatefulSinkWriterAdapter;
+import org.apache.flink.api.connector.sink2.WriterInitContext;
+import org.apache.flink.connector.base.sink.writer.BufferedRequestState;
+import org.apache.flink.connector.base.sink.writer.ElementConverter;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ * Compatibility adapter for Flink 1.20. This class is part of the 
multi-version compatibility layer
+ * that allows Flink CDC to work across different Flink versions.
+ */
+public abstract class AsyncSinkBaseAdapter<InputT, RequestEntryT extends 
Serializable>
+        extends AsyncSinkBase<InputT, RequestEntryT> {
+    protected AsyncSinkBaseAdapter(
+            ElementConverter<InputT, RequestEntryT> elementConverter,
+            int maxBatchSize,
+            int maxInFlightRequests,
+            int maxBufferedRequests,
+            long maxBatchSizeInBytes,
+            long maxTimeInBufferMS,
+            long maxRecordSizeInBytes) {
+        super(
+                elementConverter,
+                maxBatchSize,
+                maxInFlightRequests,
+                maxBufferedRequests,
+                maxBatchSizeInBytes,
+                maxTimeInBufferMS,
+                maxRecordSizeInBytes);
+    }
+
+    @Override
+    public StatefulSinkWriter<InputT, BufferedRequestState<RequestEntryT>> 
restoreWriter(
+            WriterInitContext context,
+            Collection<BufferedRequestState<RequestEntryT>> recoveredState)
+            throws IOException {

Review Comment:
   `StatefulSinkWriter` is referenced in the `restoreWriter(...)` override but 
isn’t imported or qualified anywhere in this file. Given this module targets 
Flink 1.20 where the writer type may be `StatefulSink.StatefulSinkWriter`, this 
currently won’t compile. Fix by using the correct fully-qualified type (or 
importing the proper Flink 1.20 type) so the override matches 
`AsyncSinkBase#restoreWriter`’s signature.
   ```suggestion
       public 
org.apache.flink.api.connector.sink2.StatefulSink.StatefulSinkWriter<
                       InputT, BufferedRequestState<RequestEntryT>>
               restoreWriter(
                       WriterInitContext context,
                       Collection<BufferedRequestState<RequestEntryT>> 
recoveredState)
                       throws IOException {
   ```



##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-elasticsearch/src/main/java/org/apache/flink/cdc/connectors/elasticsearch/v2/Elasticsearch8AsyncSink.java:
##########
@@ -84,8 +85,7 @@ protected Elasticsearch8AsyncSink(
      * @return a new instance of {@link Elasticsearch8AsyncWriter}.
      */
     @Override
-    public StatefulSinkWriter<InputT, BufferedRequestState<Operation>> 
createWriter(
-            InitContext context) {
+    public SinkWriter<InputT> createWriter(InitContext context) {

Review Comment:
   The Javadocs for `createWriter`/`restoreWriterAdapter` still refer to 
returning/creating a `StatefulSinkWriter`, but the method now returns 
`SinkWriter<InputT>` and the restore method returns 
`StatefulSinkWriterAdapter`. Please update the links/wording to match the new 
signatures to avoid misleading API documentation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to