tillrohrmann commented on a change in pull request #11963: URL: https://github.com/apache/flink/pull/11963#discussion_r420741940
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/util/TestingFatalErrorHandlerResource.java ########## @@ -0,0 +1,91 @@ +/* + * 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.runtime.util; + +import org.apache.flink.util.Preconditions; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import javax.annotation.Nullable; + +/** + * Resource which provides a {@link TestingFatalErrorHandler} and checks whether no exception + * has been caught when calling {@link #after()}. + */ +public final class TestingFatalErrorHandlerResource implements TestRule { + + @Nullable + private TestingFatalErrorHandler testingFatalErrorHandler; + + public TestingFatalErrorHandlerResource() { + testingFatalErrorHandler = null; + } + + @Override + public Statement apply(Statement base, Description description) { + return statement(base); + } + + private Statement statement(Statement base) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + before(); + + try (CloseableStatement closeableStatement = new CloseableStatement(base)) { Review comment: I will add a comment. Looking at `o.a.f.util.ExternalResource`, it has a slightly different API. I guess at some point we could unify them but first we would have to discuss whether one really needs to distinguish between the failure and success case for `after`. I think `afterTestSuccess` could be a bit misleading because the default implementation also calls this method in the failure case. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org