mikewalch closed pull request #988: Closed file system which is not eventually 
closed.
URL: https://github.com/apache/fluo/pull/988
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java 
b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
index e7117057..8d717f32 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
@@ -324,9 +324,7 @@ public static String copyDirToDfs(String dfsRoot, String 
appName, String srcDir,
     String dfsAppRoot = dfsRoot + "/" + appName;
     String dfsDestDir = dfsAppRoot + "/" + destDir;
 
-    FileSystem fs;
-    try {
-      fs = FileSystem.get(new URI(dfsRoot), new Configuration());
+    try (FileSystem fs = FileSystem.get(new URI(dfsRoot), new 
Configuration())) {
       fs.delete(new Path(dfsDestDir), true);
       fs.mkdirs(new Path(dfsAppRoot));
       fs.copyFromLocalFile(new Path(srcDir), new Path(dfsDestDir));
@@ -340,11 +338,19 @@ private String copyJarsToDfs(String jars, String destDir) 
{
     String dfsAppRoot = config.getDfsRoot() + "/" + 
config.getApplicationName();
     String dfsDestDir = dfsAppRoot + "/" + destDir;
 
-    FileSystem fs;
+    FileSystem fs = null;
     try {
       fs = FileSystem.get(new URI(config.getDfsRoot()), new Configuration());
       fs.mkdirs(new Path(dfsDestDir));
     } catch (Exception e) {
+      logger.error("Failed to create DFS directory {}", dfsDestDir);
+      if (fs != null) {
+        try {
+          fs.close();
+        } catch (IOException ioe) {
+          throw new IllegalStateException(ioe);
+        }
+      }
       throw new IllegalStateException(e);
     }
 
@@ -356,12 +362,23 @@ private String copyJarsToDfs(String jars, String destDir) 
{
         fs.copyFromLocalFile(new Path(jarPath), new Path(dfsDestDir));
       } catch (IOException e) {
         logger.error("Failed to copy file {} to DFS directory {}", jarPath, 
dfsDestDir);
+        try {
+          fs.close();
+        } catch (IOException ioe) {
+          throw new IllegalStateException(ioe);
+        }
         throw new IllegalStateException(e);
       }
       if (classpath.length() != 0) {
         classpath.append(",");
       }
-      classpath.append(dfsDestDir + "/" + jarName);
+      classpath.append(dfsDestDir).append("/").append(jarName);
+    }
+
+    try {
+      fs.close();
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
     }
     return classpath.toString();
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to