Index: monitor/src/main/java/org/apache/kylin/monitor/FileUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- monitor/src/main/java/org/apache/kylin/monitor/FileUtils.java	(date 1439174700000)
+++ monitor/src/main/java/org/apache/kylin/monitor/FileUtils.java	(date 1439198982000)
@@ -47,7 +47,9 @@
                 return false;
             }
         } catch (Exception e) {
+            if(fs != null) {
-            fs.close();
+                fs.close();
+            }
             logger.info("Failed to init:", e);
         }
         return true;
@@ -68,10 +70,14 @@
         } catch (Exception e) {
             logger.info("Exception", e);
         } finally {
+            if(writer != null) {
-            writer.close();
+                writer.close();
+            }
+            if(fs != null) {
-            fs.close();
-        }
-    }
+                fs.close();
+            }
+        }
+    }
 
     /*
     * write parse result to hdfs
@@ -91,11 +97,17 @@
         } catch (Exception e) {
             logger.info("Exception", e);
         } finally {
+            if(writer != null) {
-            writer.close();
+                writer.close();
+            }
+            if(cwriter != null) {
-            cwriter.close();
+                cwriter.close();
+            }
+            if(fs != null) {
-            fs.close();
-        }
-    }
+                fs.close();
+            }
+        }
+    }
 
     /*
      * get hdfs fileSystem
@@ -107,7 +119,9 @@
         try {
             fs = FileSystem.newInstance(conf);
         } catch (IOException e) {
+            if(fs != null) {
-            fs.close();
+                fs.close();
+            }
             logger.info("Failed to get hdfs FileSystem", e);
         }
         return fs;
Index: monitor/src/main/java/org/apache/kylin/monitor/QueryParser.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- monitor/src/main/java/org/apache/kylin/monitor/QueryParser.java	(date 1439174700000)
+++ monitor/src/main/java/org/apache/kylin/monitor/QueryParser.java	(date 1439198982000)
@@ -98,7 +98,9 @@
                 this.writeResultToHdfs(QueryParser.QUERY_PARSE_RESULT_PATH, QueryParser.KYLIN_QUERY_CSV_HEADER);
             }
         } catch (IOException e) {
+            if(fs != null) {
-            fs.close();
+                fs.close();
+            }
             logger.info("Failed to init:", e);
         }
     }
@@ -172,10 +174,16 @@
         } catch (IOException ex) {
             logger.info("Failed to write to hdfs:", ex);
         } finally {
+            if(writer != null) {
-            writer.close();
+                writer.close();
+            }
+            if(cwriter != null) {
-            cwriter.close();
+                cwriter.close();
+            }
+            if(fs != null) {
-            fs.close();
-        }
+                fs.close();
+            }
+        }
 
         logger.info("Finish parsing file " + filePath + " !");
 
@@ -199,11 +207,17 @@
         } catch (IOException e) {
             logger.info("Exception", e);
         } finally {
+            if(writer != null) {
-            writer.close();
+                writer.close();
+            }
+            if(cwriter != null) {
-            cwriter.close();
+                cwriter.close();
+            }
+            if(fs != null) {
-            fs.close();
-        }
-    }
+                fs.close();
+            }
+        }
+    }
 
 
     /*
@@ -240,7 +254,9 @@
         try {
             fs = FileSystem.get(conf);
         } catch (IOException e) {
+            if(fs != null) {
-            fs.close();
+                fs.close();
+            }
             logger.info("Failed to get hdfs FileSystem", e);
         }
         return fs;
\ No newline at end of file
