Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 95002 invoked from network); 15 Oct 2005 01:22:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Oct 2005 01:22:50 -0000 Received: (qmail 29459 invoked by uid 500); 15 Oct 2005 01:22:49 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 29440 invoked by uid 500); 15 Oct 2005 01:22:49 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 29429 invoked by uid 99); 15 Oct 2005 01:22:49 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 14 Oct 2005 18:22:48 -0700 Received: (qmail 94965 invoked by uid 65534); 15 Oct 2005 01:22:28 -0000 Message-ID: <20051015012228.94964.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r321274 - in /db/derby/code/trunk/java: drda/org/apache/derby/drda/ drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ Date: Sat, 15 Oct 2005 01:22:25 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kmarsden Date: Fri Oct 14 18:22:15 2005 New Revision: 321274 URL: http://svn.apache.org/viewcvs?rev=321274&view=rev Log: DERBY-375 Specification of incomplete server properties on command line causes NPE with NetworkServerControl when starting the server. The patch does the following: 1. Moves the call to 'init', which initializes 'langUtil', before the call to 'getPropertyInfo' method in the constructors of NetworkServerControlImpl. 2. If the system properties are specified without values, use defaults for them. 3. For 'derby.drda.traceDirectory' property following is mentioned in the doc - "If the derby.system.home property has been set, it is the default. Otherwise, the default is the current directory.". 'getPropertyInfo' was getting the value of 'derby.system.home' but not using it as default for 'derby.drda.traceDirectory'. So the current directory was always getting used as default. Changed this. 4. When I added the default for 'derby.drda.traceDirectory', the tests derbynet/getCurrentProperties.java and derbynet/sysinfo.java had additional lines for derby.drda.traceDirectory in their outputs. Since the directory listed is dependent on the test directory, I have sed out 'traceDirectory' lines for these tests. 5. Adds tests to derbynet/testProperties.java. 6. Fixes javadoc for 'traceDirectory' in NetworkServerControl. Contributed by Deepa Remesh Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties (with props) Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java (original) +++ db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java Fri Oct 14 18:22:15 2005 @@ -86,7 +86,8 @@ This changes where new trace files will be placed. For sessions with tracing already turned on, trace files remain in the previous location. - Default is clousdcape.system.home + Default is derby.system.home, if it is set. + Otherwise the default is the current directory.

Properties can be set in the derby.properties file or on the command line. Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original) +++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Fri Oct 14 18:22:15 2005 @@ -285,8 +285,8 @@ // constructor public NetworkServerControlImpl() throws Exception { - getPropertyInfo(); init(); + getPropertyInfo(); } @@ -299,12 +299,12 @@ */ public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception { + init(); getPropertyInfo(); this.hostAddress = address; this.portNumber = (portNumber <= 0) ? this.portNumber: portNumber; this.hostArg = address.getHostAddress(); - init(); } private void init() throws Exception @@ -2448,29 +2448,51 @@ "true")) setTraceAll(true); - setTraceDirectory(PropertyUtil.getSystemProperty( - Property.DRDA_PROP_TRACEDIRECTORY)); + //If the derby.system.home property has been set, it is the default. + //Otherwise, the default is the current directory. + //If derby.system.home is not set, directory will be null and trace files will get + //created in current directory. + propval = PropertyUtil.getSystemProperty(Property.DRDA_PROP_TRACEDIRECTORY,directory); + if(propval != null){ + if(propval.equals("")) + propval = directory; + setTraceDirectory(propval); + } + //DERBY-375 If a system property is specified without any value, getProperty returns + //an empty string. Use default values in such cases. propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_MINTHREADS); - if (propval != null) + if (propval != null){ + if(propval.equals("")) + propval = "0"; setMinThreads(getIntPropVal(Property.DRDA_PROP_MINTHREADS, propval)); + } propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_MAXTHREADS); - if (propval != null) + if (propval != null){ + if(propval.equals("")) + propval = "0"; setMaxThreads(getIntPropVal(Property.DRDA_PROP_MAXTHREADS, propval)); + } propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_TIMESLICE); - if (propval != null) + if (propval != null){ + if(propval.equals("")) + propval = "0"; setTimeSlice(getIntPropVal(Property.DRDA_PROP_TIMESLICE, propval)); + } propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_PORTNUMBER); - if (propval != null) + if (propval != null){ + if(propval.equals("")) + propval = String.valueOf(NetworkServerControl.DEFAULT_PORTNUMBER); portNumber = getIntPropVal(Property.DRDA_PROP_PORTNUMBER, propval); + } propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_KEEPALIVE); @@ -2480,9 +2502,12 @@ propval = PropertyUtil.getSystemProperty( Property.DRDA_PROP_HOSTNAME); - if (propval != null) - hostArg = propval; - + if (propval != null){ + if(propval.equals("")) + hostArg = DEFAULT_HOST; + else + hostArg = propval; + } propval = PropertyUtil.getSystemProperty( NetworkServerControlImpl.DRDA_PROP_DEBUG); if (propval != null && StringUtil.SQLEqualsIgnoreCase(propval, "true")) @@ -3214,6 +3239,11 @@ retval.put(Property.DRDA_PROP_TIMESLICE, new Integer(getTimeSlice()).toString()); retval.put(Property.DRDA_PROP_LOGCONNECTIONS, new Boolean(getLogConnections()).toString()); String startDRDA = PropertyUtil.getSystemProperty(Property.START_DRDA); + //DERBY-375 If a system property is specified without any value, getProperty returns + //an empty string. Use default values in such cases. + if(startDRDA!=null && startDRDA.equals("")) + startDRDA = "false"; + retval.put(Property.START_DRDA, (startDRDA == null)? "false" : startDRDA); //get the trace value for each session if tracing for all is not set Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out Fri Oct 14 18:22:15 2005 @@ -14,4 +14,22 @@ Successfully Connected org.apache.derby.drda.NetworkServerControl shutdown -p 1530 Shutdown successful. +Testing start server by specifying system properties without values +First shutdown server started on default port by the test harness +org.apache.derby.drda.NetworkServerControl shutdown -p 1527 +Shutdown successful. +-Dderby.drda.logConnections -Dderby.drda.traceAll -Dderby.drda.traceDirectory -Dderby.drda.keepAlive -Dderby.drda.timeSlice -Dderby.drda.host -Dderby.drda.portNumber -Dderby.drda.minThreads -Dderby.drda.maxThreads -Dderby.drda.startNetworkServer -Dderby.drda.debug org.apache.derby.drda.NetworkServerControl start +-- listing properties -- +derby.drda.maxThreads=0 +derby.drda.keepAlive=true +derby.drda.minThreads=0 +derby.drda.portNumber=1527 +derby.drda.logConnections=false +derby.drda.timeSlice=0 +derby.drda.startNetworkServer=false +derby.drda.host=localhost +derby.drda.traceAll=false +Successfully Connected +org.apache.derby.drda.NetworkServerControl shutdown -p 1527 +Shutdown successful. End test Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant Fri Oct 14 18:22:15 2005 @@ -7,6 +7,7 @@ dataSourcePermissions_net_sed.properties default_app.properties default_derby.properties +getCurrentProperties_sed.properties runtimeinfo_sed.properties sysinfo_sed.properties testij.sql Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties?rev=321274&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties Fri Oct 14 18:22:15 2005 @@ -0,0 +1,9 @@ +# Filters and substitutes for SED +# Multiple patterns for DELETE: comma separated +# delete=pattern1,pattern2,...,patternn +# No commas can be allowed in the patterns. +# +# Multiple patterns for SUBSTITUTE: comma separated pair +# substitute=pattern1;substitute1,pattern2;substitute2,...,patternn;substituten +# No commas or semicolons can be allowed in the patterns/subsitutes. +delete=traceDirectory \ No newline at end of file Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties Fri Oct 14 18:22:15 2005 @@ -1 +1 @@ -delete=Version,version,Java,OS,[0-9*].[0-9*].[0-9*],JRE - JDBC +delete=Version,version,Java,OS,[0-9*].[0-9*].[0-9*],JRE - JDBC,traceDirectory Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java?rev=321274&r1=321273&r2=321274&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java Fri Oct 14 18:22:15 2005 @@ -42,6 +42,9 @@ default The command line should take precedence + + It also tests start server by specifying system properties without values. + In this case the server will use default values. */ public class testProperties @@ -52,6 +55,21 @@ private static Vector vCmd; private static BufferedOutputStream bos = null; + //Command to start server specifying system properties without values + private static String[] startServerCmd = + new String[] { "-Dderby.drda.logConnections", + "-Dderby.drda.traceAll", + "-Dderby.drda.traceDirectory", + "-Dderby.drda.keepAlive", + "-Dderby.drda.timeSlice", + "-Dderby.drda.host", + "-Dderby.drda.portNumber", + "-Dderby.drda.minThreads", + "-Dderby.drda.maxThreads", + "-Dderby.drda.startNetworkServer", + "-Dderby.drda.debug", + "org.apache.derby.drda.NetworkServerControl", + "start"}; /** * Execute the given command and dump the results to standard out @@ -160,6 +178,14 @@ } } + private static void listProperties(String portString) throws Exception{ + int port = Integer.parseInt(portString); + NetworkServerControl derbyServer = new NetworkServerControl( InetAddress.getByName("localhost"), + port); + Properties p = derbyServer.getCurrentProperties(); + p.list(System.out); + } + public static void main (String args[]) throws Exception { if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) @@ -204,6 +230,22 @@ System.out.println("Successfully Connected"); //shutdown - with command line option derbyServerCmd("shutdown","1530"); + + /********************************************************************** + * Test start server specifying system properties without values + *********************************************************************/ + System.out.println("Testing start server by specifying system properties without values"); + System.out.println("First shutdown server started on default port by the test harness"); + + //Shutdown the server started by test + derbyServerCmd("shutdown","1527"); + execCmd(startServerCmd); + waitForStart("1527",15000); + //check that default properties are used + listProperties("1527"); + System.out.println("Successfully Connected"); + derbyServerCmd("shutdown","1527"); + System.out.println("End test"); bos.close(); }