This is an automated email from the ASF dual-hosted git repository.
benyoka pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.6 by this push:
new 34ecd4c AMBARI-25230 improve fast-hdfs tool exception handling
(benyoka) (#2915)
34ecd4c is described below
commit 34ecd4ceacbe905dca52e9118a7d327420ab285c
Author: benyoka <[email protected]>
AuthorDate: Thu Apr 11 13:47:13 2019 +0200
AMBARI-25230 improve fast-hdfs tool exception handling (benyoka) (#2915)
---
.../main/java/org/apache/ambari/fast_hdfs_resource/Runner.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Runner.java
b/contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Runner.java
index 98119b0..ab0d08a 100644
---
a/contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Runner.java
+++
b/contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Runner.java
@@ -31,7 +31,7 @@ import com.google.gson.Gson;
public class Runner {
public static void main(String[] args)
- throws IOException, URISyntaxException {
+ throws IOException, URISyntaxException, Exception {
// 1 - Check arguments
if (args.length != 1) {
System.err.println("Incorrect number of arguments. Please provide:\n"
@@ -65,7 +65,7 @@ public class Runner {
// 4 - Connect to HDFS
System.out.println("Using filesystem uri: " +
FileSystem.getDefaultUri(conf).toString());
dfs.initialize(FileSystem.getDefaultUri(conf), conf);
-
+
for (Resource resource : resources) {
System.out.println("Creating: " + resource);
@@ -104,12 +104,14 @@ public class Runner {
catch(Exception e) {
System.out.println("Exception occurred, Reason: " + e.getMessage());
e.printStackTrace();
+ throw e;
}
finally {
- dfs.close();
+ if (null != dfs) {
+ dfs.close();
+ }
}
System.out.println("All resources created.");
}
-
}