hulincup commented on code in PR #685:
URL:
https://github.com/apache/doris-flink-connector/pull/685#discussion_r3755737200
##########
flink-doris-connector/flink-doris-connector-base/src/main/java/org/apache/doris/flink/source/reader/DorisSourceSplitReader.java:
##########
@@ -107,7 +115,13 @@ public void wakeUp() {}
@Override
public void close() throws Exception {
if (valueReader != null) {
- valueReader.close();
+ try {
+ valueReader.close();
+ } catch (Exception e) {
+ LOG.warn("Error while closing value reader: {}",
e.getMessage());
+ } finally {
+ valueReader = null;
+ }
}
}
Review Comment:
Fixed in a5a839b — the throwable is now passed to `LOG.warn(..., e)` so the
full stack trace is preserved. Also added an explicit `InterruptedException`
clause that restores the thread interrupt flag, matching the close() handling
in #684.
##########
flink-doris-connector/flink-doris-connector-base/src/test/java/org/apache/doris/flink/source/reader/DorisSourceSplitReaderTest.java:
##########
@@ -0,0 +1,194 @@
+// 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.source.reader;
+
+import
org.apache.flink.connector.base.source.reader.splitreader.SplitsAddition;
+
+import org.apache.doris.flink.cfg.DorisOptions;
+import org.apache.doris.flink.cfg.DorisReadOptions;
+import org.apache.doris.flink.rest.PartitionDefinition;
+import org.apache.doris.flink.source.split.DorisSourceSplit;
+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 DorisSourceSplitReader}, focusing on reader lifecycle.
+ */
+public class DorisSourceSplitReaderTest {
+
+ /**
+ * A ValueReader that records how many times close() is invoked. hasNext()
returns true so
+ * fetch() does not finish the split, leaving the reader open for close()
to exercise.
+ */
+ private static final class RecordingValueReader extends ValueReader {
+ final AtomicInteger closeCount = new AtomicInteger(0);
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public List next() {
+ return Collections.emptyList();
+ }
Review Comment:
Fixed in a5a839b — the stub now declares `List<Object> next()`.
##########
flink-doris-connector/flink-doris-connector-base/src/test/java/org/apache/doris/flink/source/reader/DorisSourceSplitReaderTest.java:
##########
@@ -0,0 +1,194 @@
+// 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.source.reader;
+
+import
org.apache.flink.connector.base.source.reader.splitreader.SplitsAddition;
+
+import org.apache.doris.flink.cfg.DorisOptions;
+import org.apache.doris.flink.cfg.DorisReadOptions;
+import org.apache.doris.flink.rest.PartitionDefinition;
+import org.apache.doris.flink.source.split.DorisSourceSplit;
+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 DorisSourceSplitReader}, focusing on reader lifecycle.
+ */
+public class DorisSourceSplitReaderTest {
+
+ /**
+ * A ValueReader that records how many times close() is invoked. hasNext()
returns true so
+ * fetch() does not finish the split, leaving the reader open for close()
to exercise.
+ */
+ private static final class RecordingValueReader extends ValueReader {
+ final AtomicInteger closeCount = new AtomicInteger(0);
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public List next() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void close() throws Exception {
+ closeCount.incrementAndGet();
+ }
+ }
+
+ /**
+ * A ValueReader whose close() always throws, to verify best-effort
swallowing + field nulling.
+ */
+ private static final class ThrowingValueReader extends ValueReader {
+ final AtomicInteger closeCount = new AtomicInteger(0);
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public List next() {
+ return Collections.emptyList();
+ }
Review Comment:
Fixed in a5a839b — this stub also declares `List<Object> next()` now.
--
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]