VXQUERY-139: Fixed the NPE for the compile only flag.

Previously executing queries with compileonly flag gave NPE, which was due to 
null value of IHyracksClientConnection.
Submitted by: ankitladhania (on github)


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/47815f89
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/47815f89
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/47815f89

Branch: refs/heads/site
Commit: 47815f899547f5e23a2d12a7da3ab038649d307f
Parents: bb39a04
Author: Preston Carman <[email protected]>
Authored: Tue Mar 22 17:29:24 2016 -0700
Committer: Preston Carman <[email protected]>
Committed: Tue Mar 22 17:29:24 2016 -0700

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 .../java/org/apache/vxquery/cli/VXQuery.java    | 30 ++++++++++----------
 2 files changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/47815f89/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index fdde96a..65263b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 .project
 .settings
 .classpath
+.idea
 target
 /ClusterControllerService/

http://git-wip-us.apache.org/repos/asf/vxquery/blob/47815f89/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
----------------------------------------------------------------------
diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java 
b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
index 53b352f..a02c65d 100644
--- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
+++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
@@ -81,8 +81,7 @@ public class VXQuery {
     /**
      * Constructor to use command line options passed.
      *
-     * @param opts
-     *            Command line options object
+     * @param opts Command line options object
      */
     public VXQuery(CmdLineOptions opts) {
         this.opts = opts;
@@ -240,23 +239,24 @@ public class VXQuery {
      * @throws Exception
      */
     private String[] getNodeList() throws Exception {
-        Map<String, NodeControllerInfo> nodeControllerInfos = 
hcc.getNodeControllerInfos();
-        String[] nodeList = new String[nodeControllerInfos.size()];
-        int index = 0;
-        for (String node : nodeControllerInfos.keySet()) {
-            nodeList[index++] = node;
+        if (hcc != null) {
+            Map<String, NodeControllerInfo> nodeControllerInfos = 
hcc.getNodeControllerInfos();
+            String[] nodeList = new String[nodeControllerInfos.size()];
+            int index = 0;
+            for (String node : nodeControllerInfos.keySet()) {
+                nodeList[index++] = node;
+            }
+            return nodeList;
         }
-        return nodeList;
+        return new String[0];
     }
 
     /**
      * Creates a Hyracks dataset, if not already existing with the job frame 
size, and 1 reader. Allocates a new buffer of size specified in the frame of 
Hyracks
      * node. Creates new dataset reader with the current job ID and result set 
ID. Outputs the string in buffer for each frame.
      *
-     * @param spec
-     *            JobSpecification object, containing frame size. Current 
specified job.
-     * @param writer
-     *            Writer for output of job.
+     * @param spec   JobSpecification object, containing frame size. Current 
specified job.
+     * @param writer Writer for output of job.
      * @throws Exception
      */
     private void runJob(JobSpecification spec, PrintWriter writer) throws 
Exception {
@@ -339,8 +339,7 @@ public class VXQuery {
     /**
      * Reads the contents of file given in query into a String. The file is 
always closed. For XML files UTF-8 encoding is used.
      *
-     * @param query
-     *            The query with filename to be processed
+     * @param query The query with filename to be processed
      * @return UTF-8 formatted query string
      * @throws IOException
      */
@@ -362,7 +361,8 @@ public class VXQuery {
      * Helper class with fields and methods to handle all command line options
      */
     private static class CmdLineOptions {
-        @Option(name = "-available-processors", usage = "Number of available 
processors. (default: java's available processors)")
+        @Option(name = "-available-processors",
+                usage = "Number of available processors. (default: java's 
available processors)")
         private int availableProcessors = -1;
 
         @Option(name = "-client-net-ip-address", usage = "IP Address of the 
ClusterController.")

Reply via email to