You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2020/01/23 14:55:44 UTC

[flink] 01/02: [hotfix][tests] Setup closable resources in BeforeClass

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit ca53dd6084726773f7add95a327756145d7ae1b0
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Wed Jan 22 10:34:56 2020 +0100

    [hotfix][tests] Setup closable resources in BeforeClass
    
    Having static final resources that are closed in an @AfterClass method prevents the test from being run in a loop within the IDE, since the static fields aren't re-initialized.
---
 .../taskexecutor/TaskExecutorPartitionLifecycleTest.java      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorPartitionLifecycleTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorPartitionLifecycleTest.java
index f59fac9..b8a5a40 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorPartitionLifecycleTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorPartitionLifecycleTest.java
@@ -72,6 +72,7 @@ import org.apache.flink.util.function.TriConsumer;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -101,9 +102,9 @@ public class TaskExecutorPartitionLifecycleTest extends TestLogger {
 
 	private static final Time timeout = Time.seconds(10L);
 
-	private static final TestingRpcService RPC = new TestingRpcService();
+	private static TestingRpcService RPC;
 
-	private static final MetricRegistryImpl metricRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+	private static MetricRegistryImpl metricRegistry;
 
 	private String metricQueryServiceAddress;
 
@@ -128,6 +129,12 @@ public class TaskExecutorPartitionLifecycleTest extends TestLogger {
 		RPC.clearGateways();
 	}
 
+	@BeforeClass
+	public static void setupClass() {
+		RPC = new TestingRpcService();
+		metricRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
+	}
+
 	@AfterClass
 	public static void shutdownClass() throws ExecutionException, InterruptedException {
 		RPC.stopService().get();