drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] vvysotskyi commented on a change in pull request #1656: DRILL-7056: Drill fails with NPE when starting in distributed mode & …
Date Fri, 01 Mar 2019 18:28:46 GMT
vvysotskyi commented on a change in pull request #1656: DRILL-7056: Drill fails with NPE when
starting in distributed mode & …
URL: https://github.com/apache/drill/pull/1656#discussion_r261700193
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
 ##########
 @@ -467,43 +452,64 @@ public void close() throws Exception {
     if (embeddedJetty != null) {
       embeddedJetty.stop();
     }
-    //Deleting temp directory
-    FileUtils.deleteDirectory(getTmpJavaScriptDir());
+    // Deleting temp directory, if it exists
+    if (tmpJavaScriptDir != null) {
+      FileUtils.deleteDirectory(tmpJavaScriptDir);
+    }
+  }
+
+  /**
+   * Creates if not exists, and returns File for temporary Javascript directory
+   * @return File handle
+   */
+  public File getOrCreateTmpJavaScriptDir() {
+    if (tmpJavaScriptDir == null && this.drillbit.getContext() != null) {
+      tmpJavaScriptDir = org.apache.drill.shaded.guava.com.google.common.io.Files.createTempDir();
+      // Perform All auto generated files at this point
+      try {
+        generateOptionsDescriptionJSFile();
+        generateFunctionJS();
+      } catch (IOException e) {
+        logger.error("Unable to create temp dir for JavaScripts. {}", e);
+      }
+    }
+    return tmpJavaScriptDir;
   }
 
+
   /**
    * Generate Options Description JavaScript to serve http://drillhost/options ACE library
search features
    * @throws IOException
    */
   private void generateOptionsDescriptionJSFile() throws IOException {
-    //Obtain list of Options & their descriptions
+    // Obtain list of Options & their descriptions
     OptionManager optionManager = this.drillbit.getContext().getOptionManager();
     OptionList publicOptions = optionManager.getPublicOptionList();
     List<OptionValue> options = new ArrayList<>(publicOptions);
-    //Add internal options
+    // Add internal options
     OptionList internalOptions = optionManager.getInternalOptionList();
     options.addAll(internalOptions);
     Collections.sort(options);
     int numLeftToWrite = options.size();
 
-    //Template source Javascript file
+    // Template source Javascript file
     InputStream optionsDescripTemplateStream = Resource.newClassPathResource(OPTIONS_DESCRIBE_TEMPLATE_JS).getInputStream();
-    //Generated file
-    File optionsDescriptionFile = new File(getTmpJavaScriptDir(), OPTIONS_DESCRIBE_JS);
+    // Generated file
+    File optionsDescriptionFile = new File(getOrCreateTmpJavaScriptDir(), OPTIONS_DESCRIBE_JS);
     final String file_content_footer = "};";
     optionsDescriptionFile.deleteOnExit();
 
 Review comment:
   Please remove these calls for subfolders of `tmpJavaScriptDir` since they will be deleted
with this dir.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message