Issue Details (XML | Word | Printable)

Key: DERBY-375
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Deepa Remesh
Reporter: A B
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Specification of incomplete server properties on command line causes NPE with NetworkServerControl when starting the server.

Created: 19/Jun/05 04:11 PM   Updated: 21/Oct/05 09:03 AM
Return to search
Component/s: Network Server
Affects Version/s: 10.1.1.0, 10.2.1.6
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Issue & Sub-Tasks
Issue Only
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-375.diff 2005-10-15 08:48 AM Deepa Remesh 11 kB
File Licensed for inclusion in ASF works derby-375.status 2005-10-15 08:48 AM Deepa Remesh 0.6 kB
Text File Licensed for inclusion in ASF works derbyall_report.txt 2005-10-15 08:48 AM Deepa Remesh 13 kB
Environment: Running Derby Network Server and using command line API to start the server.

Resolution Date: 21/Oct/05 09:02 AM

Sub-Tasks  All   Open   
No sub-tasks match this view.

 Description  « Hide
When using the command line to start the Network Server, there a couple of cases where if a property is specified on the command line but no value is given (ex. "-Dderby.drda.maxThreads" instead of "-Dderby.drda.maxThreads=3"), a Null Pointer Exception will result, when the correct behavior should be to use some kind of default.

For example:

> java -Dderby.drda.maxThreads org.apache.derby.drda.NetworkServerControl start -p 1528
java.lang.NullPointerException
        at org.apache.derby.impl.drda.NetworkServerControlImpl.localizeMessage(NetworkServerControlImpl.java)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessageWork(NetworkServerControlImpl.java)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessage(NetworkServerControlImpl.java)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.getIntPropVal(NetworkServerControlImpl.java)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.getPropertyInfo(NetworkServerControlImpl.java)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.<init>(NetworkServerControlImpl.java)
        at org.apache.derby.drda.NetworkServerControl.main(NetworkServerControl.java)

Note that even though we see this NPE, it appears that the server still starts up, although the startup may not be complete (subsequent attempts to connect might lead to errors like "Invalid reply from network server: Insufficient data.").

For other properties, this will just result in the default value being used, which is the correct behavior. For example:

> java -Dderby.drda.host org.apache.derby.drda.NetworkServerControl start -p 1528
Server is ready to accept connections on port 1528.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Andrew McIntyre added a comment - 30/Jun/05 05:50 AM
Moving to 10.2

Andrew McIntyre made changes - 30/Jun/05 05:50 AM
Field Original Value New Value
Fix Version/s 10.1.1.0 [ 10993 ]
Fix Version/s 10.2.0.0 [ 11187 ]
Affects Version/s 10.2.0.0 [ 11187 ]
Deepa Remesh made changes - 12/Oct/05 07:15 AM
Assignee Deepa Remesh [ deepa ]
Deepa Remesh added a comment - 13/Oct/05 09:50 AM
The default values for network server properties mentioned in Derby Server and Administration Guide are:

derby.drda.host - If no host name is specified, the Network Server listens on the loopback address of the current machine (localhost).
derby.drda.keepAlive - true
derby.drda.logConnections - false
derby.drda.maxThreads - 1
derby.drda.minThreads - 1
derby.drda.portNumber - If no port number is specified, 1527 is the default.
derby.drda.startNetworkServer - false
derby.drda.timeSlice - 1
derby.drda.traceAll - false
derby.drda.traceDirectory - If the derby.system.home property has been set, it is the default. Otherwise, the default is the current directory.
derby.drda.debug - false

However, in the code, default value of minThreads, maxThreads and timeSlice is '0'. In my patch too, I am using '0' as the default value for these. I also saw a test (maxThread.java) which tests default value of maxThreads as '0'. I think the document needs to be updated. Also, the property 'derby.drda.debug' is not listed in the admin guide. Is this an internal property not exposed to users?

Repository Revision Date User Message
ASF #321274 Sat Oct 15 01:22:15 UTC 2005 kmarsden 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
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties
MODIFY /db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties
MODIFY /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant

Deepa Remesh added a comment - 15/Oct/05 08:48 AM
Attaching a patch 'derby-375.diff' for this problem. Network server was giving NPE when system properties were specified without values. When a system property is specified without any value, the getProperty method in java.util.Properties returns an empty string. For the following network server properties (minThreads, maxThreads, timeSlice and portNumber), 'getPropertyInfo' method in NetworkServerControlImpl will pass this empty string to 'getIntPropVal'. This will try to get the Integer value and will cause an exception. To display this exception, 'localizeMessage' method is used. At this point, 'langUtil' which is passed to 'localizeMessage' is not yet initialized and this results in the NPE.

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.

Ran derbyall on Windows XP with Sun jdk 1.4.2. 1 test failed (derbyall/derbyall.fail:lang/ConcurrentImplicitCreateSchema.java). The failure is not related to this change.

This patch also fixes DERBY-613 (Intended location of network server tracing files is not clear.). Please review/commit this patch. I'll open a sub-task to update documentation with the correct default values for maxThreads, minThreads and timeSlice.

Deepa Remesh made changes - 15/Oct/05 08:48 AM
Attachment derby-375.diff [ 12314891 ]
Attachment derbyall_report.txt [ 12314893 ]
Attachment derby-375.status [ 12314892 ]
Kathey Marsden added a comment - 15/Oct/05 10:34 AM
Reviewed and committed this patch to the trunk. Looks good. Thanks for fixing DERBY-613 too!
My only comment would be that perhaps it would be better to use a substitute to something generic rather than a delete of the traceDirectory lines. If you feel so motivated you could submit a followon patch.

Date: Fri Oct 14 18:22:15 2005
New Revision: 321274

URL: http://svn.apache.org/viewcvs?rev=321274&view=rev


Repository Revision Date User Message
ASF #326289 Tue Oct 18 22:58:08 UTC 2005 djd DERBY-375 DERBY-613
Fix test failure for derbynet/getCurrentProperties.java

1. Removes the following permission from derbynet.jar and classes
directory. This is not required after the patch for DERBY-375.
permission java.io.FilePermission "${user.dir}${/}*", "write";

2. Grants the following permission to derbynet.jar. This is required
since tracing file location now defaults to ${derby.system.home}. The
test derbynet/getCurrentProperties.java uses this.
// tracing files default to derby.system.home,
derbynet/getCurrentProperties.java
permission java.io.FilePermission "${derby.system.home}${/}*", "write";

3. Grants the following permission to derbynet.jar and classes
directory. This is required by the test jdbcapi/secureUsers1.sql when
run using sane builds.
// sane=true, jdbcapi/secureUsers1.sql
permission java.io.FilePermission "${user.dir}${/}CloudLDAP.out", "write";

Contributed by Deepa Remesh dremesh@gmail.com
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy

A B added a comment - 20/Oct/05 03:47 AM
The patch for this has been committed and I verified that the example shown in this description now works against the trunk, as do the new test cases in derbynet/testProperties. Should this fix be ported to 10.1? The Fix version is only specified as 10.2.0.0, so if that's correct, I'll go ahead and resolve/close this issue...

Deepa Remesh added a comment - 20/Oct/05 04:02 AM
Thanks for verifying. I was not planning to merge this to 10.1. You may close this issue.

A B added a comment - 20/Oct/05 04:12 AM
Patch was reviewed and applied to trunk with svn 321274. I verified that the issue has been fixed in the trunk, so I am now resolving and closing this issue.

A B made changes - 20/Oct/05 04:12 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
A B made changes - 20/Oct/05 04:13 AM
Status Resolved [ 5 ] Closed [ 6 ]
Repository Revision Date User Message
ASF #327018 Thu Oct 20 22:39:09 UTC 2005 kmarsden DERBY-375 - Specification of incomplete server properties on command line causes NPE with NetworkServerControl when starting the server.
merge from trunk
DERBY-613 - Change default tracing location to derby.system.home

svn merge -r 321273:321274 https://svn.apache.org/repos/asf/db/derby/code/trunk
svn merge -r 326288:326289 https://svn.apache.org/repos/asf/db/derby/code/trunk

Contributed by Deepa Remesh
Files Changed
MODIFY /db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/getCurrentProperties_sed.properties)
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant
MODIFY /db/derby/code/branches/10.1/java/drda/org/apache/derby/drda/NetworkServerControl.java

Deepa Remesh added a comment - 21/Oct/05 06:48 AM
Re-opening to merge fix to 10.1

Deepa Remesh made changes - 21/Oct/05 06:48 AM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Deepa Remesh added a comment - 21/Oct/05 06:52 AM
I merged this fix to my 10.1 codeline and ran derbyall with Sun JDK 1.4.2 on Windows XP. 2 failures:
derbyall/derbyall.fail:unit/T_Diagnosticable.unit (This test passed when I re-ran it)
derbyall/derbyall.fail:i18n/iepnegativetests_ES.sql (master update issue)

Merge command:
svn merge -r 321273:321274 https://svn.apache.org/repos/asf/db/derby/code/trunk
svn merge -r 326288:326289 https://svn.apache.org/repos/asf/db/derby/code/trunk

Please merge this to 10.1 branch. Thanks.

Deepa Remesh made changes - 21/Oct/05 06:52 AM
Fix Version/s 10.1.2.0 [ 12310270 ]
Kathey Marsden added a comment - 21/Oct/05 07:44 AM
Checked this fix which also fixes DERBY-613 into 10.1

Date: Thu Oct 20 15:39:09 2005
New Revision: 327018

URL: http://svn.apache.org/viewcvs?rev=327018&view=rev

Deepa Remesh added a comment - 21/Oct/05 09:02 AM
Verified in 10.1 by running the example in description.

Deepa Remesh made changes - 21/Oct/05 09:02 AM
Status Reopened [ 4 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Deepa Remesh made changes - 21/Oct/05 09:03 AM
Status Resolved [ 5 ] Closed [ 6 ]