Copilot commented on code in PR #684:
URL:
https://github.com/apache/doris-flink-connector/pull/684#discussion_r3719119369
##########
flink-doris-connector/flink-doris-connector-base/src/main/java/org/apache/doris/flink/table/DorisRowDataInputFormat.java:
##########
@@ -97,17 +98,37 @@ public void closeInputFormat() {
*/
@Override
public void open(DorisTableInputSplit inputSplit) throws IOException {
- valueReader = new DorisValueReader(inputSplit.partition, options,
readOptions);
+ valueReader = createValueReader(inputSplit.partition);
hasNext = valueReader.hasNext();
}
+ /**
+ * Creates the {@link ValueReader} for a partition. Default behavior
constructs a {@link
+ * DorisValueReader} (thrift). Protected to allow tests to substitute a
fake reader without
+ * opening a real Doris BE connection.
+ */
+ protected ValueReader createValueReader(PartitionDefinition partition) {
+ return new DorisValueReader(partition, options, readOptions);
+ }
+
/**
* Closes all resources used.
*
* @throws IOException Indicates that a resource could not be closed.
*/
@Override
- public void close() throws IOException {}
+ public void close() throws IOException {
+ if (valueReader == null) {
+ return;
+ }
+ try {
+ valueReader.close();
+ } catch (Exception e) {
+ LOG.warn("Failed to close doris value reader.", e);
+ } finally {
+ valueReader = null;
+ }
+ }
Review Comment:
If `valueReader.close()` throws `InterruptedException` (or wraps it), this
code logs and swallows it without restoring the thread interrupt flag. Please
handle interruption explicitly (e.g., catch `InterruptedException`, call
`Thread.currentThread().interrupt()`, then log), so task cancellation semantics
aren’t accidentally broken.
##########
flink-doris-connector/flink-doris-connector-base/src/test/java/org/apache/doris/flink/table/DorisRowDataInputFormatTest.java:
##########
@@ -0,0 +1,184 @@
+// 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.doris.flink.table;
+
+import org.apache.flink.table.types.logical.IntType;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.doris.flink.cfg.DorisReadOptions;
+import org.apache.doris.flink.rest.PartitionDefinition;
+import org.apache.doris.flink.source.reader.ValueReader;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.junit.Assert.assertEquals;
+
+/** Unit tests for {@link DorisRowDataInputFormat}, focusing on reader
lifecycle. */
+public class DorisRowDataInputFormatTest {
+
+ /** A ValueReader that records how many times close() is invoked. */
+ private static final class RecordingValueReader extends ValueReader {
+ final AtomicInteger closeCount = new AtomicInteger(0);
+
+ @Override
+ public boolean hasNext() {
+ return false;
+ }
+
+ @Override
+ public List next() {
+ return Collections.emptyList();
+ }
Review Comment:
The test implementation uses raw `List` in `next()`, which can introduce
unchecked warnings and reduce type clarity. Prefer matching the
`ValueReader.next()` generic signature (or add a targeted suppression) to keep
the test code aligned with the production API and avoid noisy compiler warnings.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]