zentol commented on code in PR #20229:
URL: https://github.com/apache/flink/pull/20229#discussion_r917810506
##########
flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CheckedThread.java:
##########
@@ -18,26 +18,42 @@
package org.apache.flink.core.testutils;
+import java.util.concurrent.TimeoutException;
+
/**
* A thread that additionally catches exceptions and offers a joining method
that re-throws the
* exceptions.
*
- * <p>Rather than overriding {@link Thread#run()} (or supplying a {@link
Runnable}), one needs to
- * extends this class and implement the {@link #go()} method. That method may
throw exceptions.
+ * <p>This class needs to supply a {@link RunnableWithException} that may
throw exceptions or
+ * override {@link #go()} method.
+ *
+ * <p>you can use it as the same way of using threads like: {@code new
Thread(Runnable runnable)} or
+ * {@Code new Thread()} and then override {@link Thread#run()} method. Just
change it to {@code new
+ * CheckedThread(RunnableWithException runnableWithException)} or {@Code new
CheckedThread()} and
+ * then override {@link CheckedThread#go()} method.
*
- * <p>Exception from the {@link #go()} method are caught and re-thrown when
joining this thread via
- * the {@link #sync()} method.
+ * <p>Exception from the {@link #runnable} or the override {@link #go()} are
caught and re-thrown
+ * when joining this thread via the {@link #sync()} method.
*/
-public abstract class CheckedThread extends Thread {
+public class CheckedThread extends Thread {
Review Comment:
we can make this final, remove `go()` and for force `runnable` to be
non-null.
##########
flink-tests/src/test/java/org/apache/flink/test/accumulators/AccumulatorLiveITCase.java:
##########
@@ -142,18 +142,16 @@ public void testStreaming() throws Exception {
submitJobAndVerifyResults(jobGraph);
}
- private static void submitJobAndVerifyResults(JobGraph jobGraph) throws
Exception {
+ private void submitJobAndVerifyResults(JobGraph jobGraph) throws Exception
{
Review Comment:
?
##########
flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CheckedThread.java:
##########
@@ -120,7 +154,7 @@ private void checkError() throws Exception {
private void checkFinished() throws Exception {
if (getState() != State.TERMINATED) {
- throw new Exception(
+ throw new TimeoutException(
Review Comment:
?
##########
flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/RunnableWithException.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.core.testutils;
+
+@FunctionalInterface
+public interface RunnableWithException {
+
+ /**
+ * The work method.
+ *
+ * @throws Exception Exceptions may be thrown.
+ */
+ void run() throws Exception;
+}
Review Comment:
Why aren't you copying the definition from `ThrowingRunnable`?
--
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]