Issue Details (XML | Word | Printable)

Key: DERBY-2559
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Kristian Waagan
Reporter: Myrna van Lunteren
Votes: 0
Watchers: 0
Operations

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

recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails

Created: 17/Apr/07 09:26 PM   Updated: 10/Mar/08 02:43 PM
Return to search
Component/s: Network Client
Affects Version/s: 10.3.1.4, 10.4.1.3
Fix Version/s: 10.3.3.0, 10.4.1.3

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-2559-1a.diff 2008-01-30 03:39 PM Kristian Waagan 3 kB
File Licensed for inclusion in ASF works derby-2559-2a-defenses.diff 2008-02-15 12:24 PM Kristian Waagan 2 kB
File Licensed for inclusion in ASF works derby-2559-3a-documentation.diff 2008-02-15 12:24 PM Kristian Waagan 6 kB
File Licensed for inclusion in ASF works derby-2559-3b-documentation.diff 2008-02-18 09:05 AM Kristian Waagan 6 kB

Resolution Date: 10/Mar/08 02:43 PM


 Description  « Hide
Consider the following code snippet from test DataSourceReferenceTest:
--------------------
        Referenceable refDS = (Referenceable) ds;
        Reference dsAsReference = refDS.getReference();
        String factoryClassName = dsAsReference.getFactoryClassName();
        ObjectFactory factory =
            (ObjectFactory) Class.forName(factoryClassName).newInstance();
        Object recreatedDS =
            factory.getObjectInstance(dsAsReference, null, null, null);
---------------------

When ds is a ClientDataSource40 (i.e. when running with jdk16), recreatedDS is null.

Note, that this showed up only after converting the test to junit, because the original test hardcoded the ds to be a ClientDataSource. I confirmed this not to be related to my changes for DERBY-2296 (which prompted me to convert the test), by backing out my changes to ClientBaseDataSource and client/am/Connection and rerunning the test (needed some minor adjustments of expected values table/array).

     

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kristian Waagan made changes - 30/Jan/08 01:50 PM
Field Original Value New Value
Assignee Kristian Waagan [ kristwaa ]
Kristian Waagan made changes - 30/Jan/08 01:50 PM
Status Open [ 1 ] In Progress [ 3 ]
Kristian Waagan added a comment - 30/Jan/08 03:39 PM
'derby-2559-1a.diff' is a patch that fixes the reported problem, where attempts to (re)create a data source through Reference returned null.
The cause was an if with entries for the pre-JDBC 4.0 classes (like ClientDataSource), but no entries for the JDBC 4.0 classes. I changed the factory class to use the same approach as the embedded driver, as it seemed to be easier to use reflection because of the mix between pre-JDBC 4.0 classes and JDBC 4.0 classes.
The patch also removes the workaround (disabling) in DataSourceReferenceTest.

I am not sure if the method behaves as documented. I don't think it will ever return null, but either succeed or throw an exception. I will look at the documentation in a separate patch.

I'm running tests and will post the results later.
Patch ready for review.

Kristian Waagan made changes - 30/Jan/08 03:39 PM
Attachment derby-2559-1a.diff [ 12374384 ]
Kristian Waagan made changes - 30/Jan/08 03:40 PM
Derby Info [Patch Available]
Fix Version/s 10.4.0.0 [ 12312540 ]
Repository Revision Date User Message
ASF #617492 Fri Feb 01 13:06:22 UTC 2008 kristwaa DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails. Incremental commit, which enables the factory to create all Derby (client) datasources. However, some mechanisms to avoid throwing exceptions must be added, for instance if a null object is passed. The test that was disabled has been enabled again.
Patch file: DERBY-2559-1a.diff
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/ClientDataSourceFactory.java

Kristian Waagan added a comment - 01/Feb/08 01:12 PM
Committed 'derby-2559-1a.diff' to trunk with revision 617492.
This commit is an incremental fix. More thought must be put into how the object factory is to be well behaved.
The factory will now create all the client data source objects, but it might/will fail if another type of object (or null) is passed as the first argument.

I'm also thinking about porting the fix to 10.3.

Kristian Waagan made changes - 01/Feb/08 01:12 PM
Derby Info [Patch Available]
Affects Version/s 10.4.0.0 [ 12312540 ]
Kristian Waagan added a comment - 15/Feb/08 12:24 PM
I have attached two more patches:
 - derby-2559-2a-defenses.diff: Does some defensive checking to ensure no exception is thrown when it should not be.
 - derby-2559-3a-documentation.diff: Fixes to the documentation, both formatting and content.

Patches ready for review. I'm especially awaiting comments on the 2a patch.

Kristian Waagan made changes - 15/Feb/08 12:24 PM
Attachment derby-2559-3a-documentation.diff [ 12375664 ]
Attachment derby-2559-2a-defenses.diff [ 12375663 ]
Kristian Waagan made changes - 15/Feb/08 12:24 PM
Derby Info [Patch Available]
Knut Anders Hatlen added a comment - 15/Feb/08 01:41 PM
2a looks good. Seems like the patch makes the implementation more in line with the description in the javadoc, so that's good.

Repository Revision Date User Message
ASF #628647 Mon Feb 18 08:48:46 UTC 2008 kristwaa DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails.
A followup patch to avoid throwing an exception when the input arguments are not as expected. The point is to allow another factory to try recreating the object, which will not happen if an exception is thrown. Null will now be returned for null objects and objects whose class does not start with "org.apache.derby.jdbc.Client".
Patch file: DERBY-2559-2a-defenses.diff
Files Changed
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/ClientDataSourceFactory.java

Repository Revision Date User Message
ASF #628654 Mon Feb 18 09:03:49 UTC 2008 kristwaa DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails.
Documentation / JavaDoc changes (contents and formatting).
Patch file: DERBY-2559-3b-documentation.diff
Files Changed
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/ClientDataSourceFactory.java

Kristian Waagan added a comment - 18/Feb/08 09:05 AM
Thanks for looking at the patch Knut Anders.

'derby-2559-3b-documentation.diff' adds a throw clause to the JavaDoc and corrects an invalid reference. I also refreshed the patch after applying patch 2a.

Committed 'derby-2559-2a-defenses.diff' to trunk with revision 628647.
Committed 'derby-2559-3b-documentation.diff' to trunk with revision 628654.

The previous code failed to create data sources when running with Java SE 6.
This suggest the patches could be backported to branches 10.2 and 10.3.
Patches 1 and 2 apply cleanly, the documentation patch (3) does not.

Kristian Waagan made changes - 18/Feb/08 09:05 AM
Attachment derby-2559-3b-documentation.diff [ 12375817 ]
Kristian Waagan added a comment - 18/Feb/08 09:06 AM
Clearing patch available flag, but considering backporting at least patches 1 and 2 to 10.2 and 10.3.

Kristian Waagan made changes - 18/Feb/08 09:06 AM
Derby Info [Patch Available]
Repository Revision Date User Message
ASF #632274 Fri Feb 29 09:45:23 UTC 2008 kristwaa DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails.
Merged fixes from trunk (10.4): r617492 and r628647.
Files Changed
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
MODIFY /db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java

Kristian Waagan added a comment - 29/Feb/08 09:53 AM
Merged patches 1 and 2 to 10.3 with revision 632274.
Tests ran cleanly.

For 10.2, the merge also worked (except that the test changes were skipped because the file doesn't exist), but I got one error:
derbyall/derbyall.fail:lang/timestampArith.java.
I also got this failure without the merge as well. I don't have time to investigate, so I will hold back the merge to 10.2.
If anyone wants to merge the fix, please go ahead.

If this issue is still open in one week, I'll mark it resolved.

Kristian Waagan made changes - 29/Feb/08 09:53 AM
Fix Version/s 10.3.2.2 [ 12312885 ]
Kristian Waagan added a comment - 29/Feb/08 09:49 PM
Seems I was bitten by this one, due to leap year issues: DERBY-3486.
Thus the merge also ran without failures on the 10.2 branch.
I leave it up to the release manager or someone else to do the merge if they feel it's worth the hassle.

A B added a comment - 03/Mar/08 07:48 PM
> Merged patches 1 and 2 to 10.3 with revision 632274.

I think this merge lead to a javadoc error:

  [javadoc] java\client\org\apache\derby\client\ClientDataSourceFactory.java:48: warning - Tag @see: reference not found: ClientDataSource

Does 628654 need to be merged back, as well?

Repository Revision Date User Message
ASF #635567 Mon Mar 10 14:38:06 UTC 2008 kristwaa DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40 fails.
Merged revision 628654 (DERBY-2559-3b-documentation.diff) from trunk and fixed a JavaDoc error caused by a previous patch applied as part of this issue.
Files Changed
MODIFY /db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java

Kristian Waagan added a comment - 10/Mar/08 02:43 PM
Thank you Army.
The revision you mention updates the documentation, but does not fix the JavaDoc error (didn't notice...). I didn't merge it right away because I got conflicts for 10.2, but it applies fine for 10.3.

Merged patch 3b to 10.3 with revision 635567, and also fixed the JavaDoc error in the same commit.

Resolving issue, reopen to merge the fixes back to 10.2.
Will close the issue in a few days.

Kristian Waagan made changes - 10/Mar/08 02:43 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]