Issue Details (XML | Word | Printable)

Key: DERBY-406
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Philip Wilder
Reporter: Kathey Marsden
Votes: 0
Watchers: 0
Operations

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

Client DataSource should not require user property to be set

Created: 30/Jun/05 06:02 AM   Updated: 26/Jan/06 02:01 AM
Return to search
Component/s: Network Client
Affects Version/s: 10.1.1.0, 10.2.1.6
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works DataSourceNoUser.java 2005-06-30 06:02 AM Kathey Marsden 2 kB
Text File Licensed for inclusion in ASF works Derby406_409_410.patch 2005-07-06 10:31 PM Philip Wilder 11 kB

Resolution Date: 18/Sep/05 12:05 AM


 Description  « Hide
ClientDataSource should not require user to be set. It should default to user APP as described in:
http://incubator.apache.org/derby/docs/adminguide/cadminappsclient.html

This all seems to work ok for for DriverManager connections but fails for ClientDataSource
run the attached repro


$ java DataSourceNoUser
embedded no userid/password
client userid/password set
client no password
client no userid/no password
org.apache.derby.client.am.SqlException: null userid not supported
        at org.apache.derby.client.net.NetConnection.checkUser(NetConnection.java:998)
        at org.apache.derby.client.net.NetConnection.flowConnect(NetConnection.java:380)
        at org.apache.derby.client.net.NetConnection.initialize(NetConnection.java:233)
        at org.apache.derby.client.net.NetConnection.<init>(NetConnection.java:201)
        at org.apache.derby.jdbc.ClientDataSource.getConnection(ClientDataSource.java:156)
        at org.apache.derby.jdbc.ClientDataSource.getConnection(ClientDataSource.java:135)
        at DataSourceNoUser.main(DataSourceNoUser.java:42)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Philip Wilder added a comment - 02/Jul/05 03:08 AM
A Combined patch for DERBY-406, DERBY-409 and DERBY-410

#Warning#
When testing this patch there were locale (en_CA vs en_US) and version (10.2.0.0 vs 10.1.0.0) issues which I believe to be unique to my machine. While this should not affect anyone who wishes to test this patch, running the derbynetclientmats suite would be advisable prior to commit.

For local the problem test was:
derbynet/sysinfo.java

For version info the problem tests were:
jdbcapi/dbMetaDataJdbc30.java
jdbcapi/metadata.java
jdbcapi/odbc_metadata.java
jdbcapi/metadataJdbc20.java

Kathey Marsden added a comment - 02/Jul/05 07:50 AM
I ran derbynetclientmatsand dataSourcePermissions_net.java under jcc for this patch and all passed. The patch looks good to me, but there are still some outstanding questions/comments from Dan, so I won't commit after all as I will be off-line for the next week. Hopefully some other committer will pick this up after these issues are resolved.


Dan's comments are in email at:
http://mail-archives.apache.org/mod_mbox/db-derby-dev/200507.mbox/%3c42C5952B.8090304@debrunners.com%3e


Philip Wilder added a comment - 04/Jul/05 09:51 PM
Sorry for any redundancy on this issue but I would like to make sure that everyone is on the same page as per the status of this patch.

The July 1 patch makes the following changes:

- Set user to default to "APP"
- Set the default servername to "localhost"
- Changed
 databaseName_ = dataSource.getDatabaseName() + attrString;
 to
 databaseName_ = dataSource.getDatabaseName() + ";" + attrString;
 in the connection class to avoid database names like myDBcreate=true when the setConnectionAttributes method is used.
- Changed the dataSourcePermissions_net to include additional tests to check bug fixes and changed the associated.out file to match new output.
- Commented sections of code associated with the fixes
- Provided javadoc for new methods in dataSourcePermissions_net.java and the getPassword() method in ClientBaseDataSource.java
- Changed the password, user and servername attributes to private so as to hopefully not conflict with his changes, as per his "Client data source published api javadoc cleanup" email.

Daniel John Debrunner added a comment - 06/Jul/05 02:27 AM
Can you remove these changes from your patch?

> - Changed the password, user and servername attributes to private so as to hopefully not conflict with his changes, as per his "Client data source published api javadoc cleanup" email.

I need some more research to see if these changes are in fact correct.

Thanks,
Dan.

Philip Wilder added a comment - 06/Jul/05 10:31 PM
Removed the changes proposed by Dan Debrunner for an alternate patch.

This patch makes the following changes
- Sets the username to start with the default value ("APP", Derby-406 Fix)
- Sets the server name to start with the default value ("localhost", Derby-410 Fix)
- Adds a semi-colon in the connection class to avoid databasenames like
myDBcreate=true resulting from no dividing semi-colon (Deby-409 Fix).
- Add javadoced methods in the derbynet/dataSourcePermissions_net.java file to test this new functionality
- Altered the output file for derbynet/dataSourcePermissions_net.java to accomodate for new tests.

Running the suite derbynetclientmats caused no problems. Running derbyall cause a single problem of the form:
 org.apache.derby.iapi.services.context.ShutdownException:
 agentThread[DRDAConnThread_5,5,derby.daemons]

Further investigation revealed that this was an intermittant problem for both the clean version of derby and my patched version. I ran 3 groups of test, each group running derbynet/dataSourcePermissions_net.java 20 times and these were my results (Apologies if there are formatting errors here):
                    Clean Patched
Test 1 1/20 (5%) 5/20 (25%)
Test 2 3/20 (15%) 3/20 (15%)
Test 3 3/20 (15%) 4/20 (20%)
Total 7/60 (11.66%) 12/60 (20%)

While the patched version does have a somewhat higher error rate it should be noted that as part of my added tests I add two additional calls to the dataSourcePermissions_net.java shutdown method.

Daniel John Debrunner added a comment - 07/Jul/05 01:56 AM
I'm working on committing this patch, currently looking at the shutdown exceptions.

Philip Wilder added a comment - 07/Jul/05 02:21 AM
I think the issue of intermittent failures of this test is discussed in the DERBY-273 issue.

Daniel John Debrunner added a comment - 07/Jul/05 04:01 AM
Committed Revision: 209498 ( Derby406_409_410.patch)
As Phil pointed out, DERBY-273 already covers the test failure.

I do not believe that this patch fully addresses these issues so they should not be closed, though it is good progress.
My concern is about the concept of defaults for DataSource properties, in these cases

406 - user - default of APP
409 - connectionAttributes - default of empty string
410 - serverName - default of localhost

All these properties are set to the default when the object is created, however if the values are set to null
(e.g. setConnecitonAttributes(null)) then should their values revert to the default or remain at null?
Existing data sources do not have any properties that have a default.

In the case that the property remains at null, then tests would be needed to ensure null is handled correctly,
at least for connectionAttributes I think a NullPointerException will occur.

Philip Wilder added a comment - 07/Jul/05 04:49 AM
"Existing data sources do not have any properties that have a default."

Perhaps I am misunderstanding your comment. While EmbeddedSimpleDataSource did not have any default values ClientCaseDataSource is more of a mixed bag. There already existed propertyDefaults for loginTimeout, portNumber, securityMechanism, retrieveMessageText and others. Even user had a propertyDefault of "APP" prior to the patch, it was simply not set.

This said I acknowledge that it is an ongoing derby goal to have Client functionality more closely match Embedded. However, if this is the case then it might be necessary to undo considerably more then just user and servername.

Daniel John Debrunner added a comment - 07/Jul/05 05:14 AM
I meant, prior to the client data sources, Derby's embedded implementation of DataSource apis did not have the concept for default values for any of their Java Bean properties. Thus this default concept is new to Derby.
Note that the Derby *engine* provides the default of APP for the user name., not EmbeddedDataSource. Its getUser method (corrresponding to its user property) will return null for a newly created EmbeddedDataSource.

So I'm not saying defaults are bad, just that we need to define what happens if the property is set to null, does it mean the property returns to its default value, or does it take on the null value? The point about no prior defaults means there is no prior behaviour to follow.

Daniel John Debrunner added a comment - 07/Jul/05 09:16 AM
One more minor issue for 409, the code currently has a default of "" (empty string) for connectionAttributes, but the functional spec
http://incubator.apache.org/derby/papers/DerbyClientSpec.html#data_source_props
indicates no default for this property. It's probably related to the code that uses the property will give a NPE if connectionAttributes is null.
Kathey implies in 409 that it should only be used "if set"

Satheesh Bandaram added a comment - 21/Jul/05 10:58 AM
Ported this fix from trunk to 10.1 with change number: 209498

Philip Wilder added a comment - 16/Sep/05 03:20 AM
Freeing this issue to anyone else who sees a way in which Dan's concerns about a lack of prior behaviour can be addressed.

Philip Wilder added a comment - 18/Sep/05 12:05 AM
The July 6, patch addressed the original concerns of this issue. While Dan brought up the potential issue of null handling further investigations appear to indicate null values are handled appropriately.

Kathey Marsden added a comment - 20/Sep/05 02:55 AM
This did not actually go in until 10.1.2

Deepa Remesh added a comment - 30/Sep/05 01:39 AM
Add fix version 10.1.1.1