flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljos...@apache.org
Subject [17/20] flink git commit: [FLINK-2268] Close Hadoop FS reflectively in TestBaseUtils
Date Wed, 27 Sep 2017 11:09:22 GMT
[FLINK-2268] Close Hadoop FS reflectively in TestBaseUtils

This removes the dependency on Hadoop and ensures that we only close if
Hadoop is available.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/23f3fded
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/23f3fded
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/23f3fded

Branch: refs/heads/master
Commit: 23f3fded80f512d545eaf56495b3a8d060053672
Parents: f5d3c72
Author: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Authored: Tue Aug 22 16:54:33 2017 +0200
Committer: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Committed: Wed Sep 27 10:05:11 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flink/test/util/TestBaseUtils.java     | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/23f3fded/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
----------------------------------------------------------------------
diff --git a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
index 007554a..d2237ad 100644
--- a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
+++ b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
@@ -39,7 +39,6 @@ import akka.pattern.Patterns;
 import akka.util.Timeout;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.hadoop.fs.FileSystem;
 import org.junit.Assert;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,6 +51,7 @@ import java.io.FileReader;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -211,7 +211,17 @@ public class TestBaseUtils extends TestLogger {
 			}
 
 			executor.stop();
-			FileSystem.closeAll();
+			try {
+				Class<?> hadoopFileSystemClass = Class.forName(
+					"org.apache.hadoop.fs.FileSystem",
+					true,
+					TestBaseUtils.class.getClassLoader());
+
+				Method closeAllMethod = hadoopFileSystemClass.getMethod("closeAll");
+				closeAllMethod.invoke(null);
+			} catch (Throwable e) {
+				// ignore
+			}
 			System.gc();
 
 			Assert.assertEquals("Not all broadcast variables were released.", 0, numUnreleasedBCVars);


Mime
View raw message