You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2014/11/11 16:34:00 UTC

svn commit: r1638186 - in /lucene/dev/branches/lucene_solr_4_10/solr: CHANGES.txt bin/solr bin/solr.cmd

Author: thelabdude
Date: Tue Nov 11 15:33:59 2014
New Revision: 1638186

URL: http://svn.apache.org/r1638186
Log:
SOLR-6662: better validation when parsing command-line options that expect a value

Modified:
    lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
    lucene/dev/branches/lucene_solr_4_10/solr/bin/solr
    lucene/dev/branches/lucene_solr_4_10/solr/bin/solr.cmd

Modified: lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt?rev=1638186&r1=1638185&r2=1638186&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt Tue Nov 11 15:33:59 2014
@@ -30,6 +30,9 @@ Bug Fixes
   it caused long startup times on lage indexes even when it wasn't used.
   (yonik)
 
+* SOLR-6662: better validation when parsing command-line options that expect a value
+  (Timothy Potter)
+
 
 ==================  4.10.2 ==================
 

Modified: lucene/dev/branches/lucene_solr_4_10/solr/bin/solr
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/bin/solr?rev=1638186&r1=1638185&r2=1638186&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/bin/solr (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/bin/solr Tue Nov 11 15:33:59 2014
@@ -312,7 +312,7 @@ function stop_solr() {
 
   DIR="$1"
   SOLR_PORT="$2"
-  STOP_PORT="79${SOLR_PORT: -2}"
+  STOP_PORT=`expr $SOLR_PORT - 1000`
   STOP_KEY="$3"
   SOLR_PID="$4"
 
@@ -378,7 +378,7 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; t
     while true; do  
       case $1 in
           -c|-collection)
-              if [ "${2:0:1}" == "-" ]; then
+              if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
                 print_usage "$SCRIPT_CMD" "Expected collection name but found $2 instead!"
                 exit 1            
               fi
@@ -386,7 +386,7 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; t
               shift 2
           ;;
           -z|-zkhost)          
-              if [ "${2:0:1}" == "-" ]; then
+              if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
                 print_usage "$SCRIPT_CMD" "Expected a ZooKeeper connection string but found $2 instead!"
                 exit 1            
               fi          
@@ -446,7 +446,7 @@ if [ $# -gt 0 ]; then
             shift
         ;;
         -d|-dir)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected directory but found $2 instead!"
               exit 1            
             fi
@@ -460,7 +460,7 @@ if [ $# -gt 0 ]; then
             shift 2
         ;;
         -s|-solr.home)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected directory but found $2 instead!"
               exit 1
             fi
@@ -469,7 +469,7 @@ if [ $# -gt 0 ]; then
             shift 2
         ;;
         -e|-example)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected example name but found $2 instead!"
               exit 1            
             fi
@@ -481,7 +481,7 @@ if [ $# -gt 0 ]; then
             shift
         ;;
         -h|-host)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected hostname but found $2 instead!"
               exit 1            
             fi
@@ -489,7 +489,7 @@ if [ $# -gt 0 ]; then
             shift 2
         ;;
         -m|-memory)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected memory setting but found $2 instead!"
               exit 1            
             fi            
@@ -497,7 +497,7 @@ if [ $# -gt 0 ]; then
             shift 2
         ;;
         -p|-port)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected port number but found $2 instead!"
               exit 1            
             fi            
@@ -505,7 +505,7 @@ if [ $# -gt 0 ]; then
             shift 2
         ;;
         -z|-zkhost)
-            if [ "${2:0:1}" == "-" ]; then
+            if [[ "$2" == "" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Expected ZooKeeper connection string but found $2 instead!"
               exit 1            
             fi
@@ -708,7 +708,7 @@ if [ "$SOLR_PORT" == "" ]; then
 fi
 
 if [ "$STOP_PORT" == "" ]; then
-  STOP_PORT="79${SOLR_PORT: -2}"
+  STOP_PORT=`expr $SOLR_PORT - 1000`
 fi
 
 if [[ "$SCRIPT_CMD" == "start" ]]; then
@@ -840,7 +840,7 @@ fi
 function launch_solr() {
 
   run_in_foreground="$1"
-  stop_port="79${SOLR_PORT: -2}"
+  stop_port="$STOP_PORT"
   
   SOLR_ADDL_ARGS="$2"
 

Modified: lucene/dev/branches/lucene_solr_4_10/solr/bin/solr.cmd
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/bin/solr.cmd?rev=1638186&r1=1638185&r2=1638186&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/bin/solr.cmd (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/bin/solr.cmd Tue Nov 11 15:33:59 2014
@@ -230,6 +230,10 @@ goto parse_args
 :set_server_dir
 
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Directory name is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected directory but found %2 instead!
@@ -249,6 +253,10 @@ goto parse_args
 :set_solr_home_dir
 
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Directory name is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected directory but found %2 instead!
@@ -262,6 +270,10 @@ goto parse_args
 :set_example
 
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Example name is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected example name but found %2 instead!
@@ -276,6 +288,10 @@ goto parse_args
 :set_memory
 
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Memory setting is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected memory setting but found %2 instead!
@@ -289,6 +305,10 @@ goto parse_args
 
 :set_host
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Hostname is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected hostname but found %2 instead!
@@ -302,6 +322,10 @@ goto parse_args
 
 :set_port
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Port is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected port but found %2 instead!
@@ -315,12 +339,15 @@ goto parse_args
 
 :set_stop_key
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=Stop key is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
-  set SCRIPT_ERROR=Expected port but found %2 instead!
+  set SCRIPT_ERROR=Expected stop key but found %2 instead!
   goto invalid_cmd_line
 )
-
 set STOP_KEY=%~2
 SHIFT
 SHIFT
@@ -329,6 +356,10 @@ goto parse_args
 :set_zookeeper
 
 set "arg=%~2"
+IF "%arg%"=="" (
+  set SCRIPT_ERROR=ZooKeeper connection string is required!
+  goto invalid_cmd_line
+)
 set firstChar=%arg:~0,1%
 IF "%firstChar%"=="-" (
   set SCRIPT_ERROR=Expected ZooKeeper connection string but found %2 instead!