[ http://issues.apache.org/jira/browse/DERBY-1298?page=all ]

Deepa Remesh updated DERBY-1298:
--------------------------------

    Attachment: ClientTracing.java

This repro uses the example for ClientDataSource tracing in 
http://db.apache.org/derby/papers/DerbyClientSpec.html#-N101A8

To run this repro, start network server, run the command "java ClientTracing". 
The directory used for tracing "myTraceDir" has to be created before running 
the command. This gives the following NPE:

java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:393)
        at java.util.Properties.setProperty(Properties.java:102)
        at 
org.apache.derby.client.am.LogWriter.getProperties(LogWriter.java:1251)
        at 
org.apache.derby.client.am.LogWriter.traceConnectsEntry(LogWriter.java:1069)
        at 
org.apache.derby.client.am.LogWriter.traceConnectEntry(LogWriter.java:998)
        at 
org.apache.derby.client.am.Connection.initConnection(Connection.java:169)
        at org.apache.derby.client.am.Connection.<init>(Connection.java:160)
        at 
org.apache.derby.client.net.NetConnection.<init>(NetConnection.java:225)
        at 
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(ClientJDBCObject
FactoryImpl.java:212)
        at 
org.apache.derby.jdbc.ClientDataSource.getConnection(ClientDataSource.java:185)
        at 
ClientTracing.sampleConnectUsingSimpleDataSource(ClientTracing.java:44)
        at ClientTracing.main(ClientTracing.java:10)

The reason for this is LogWriter.getProperties method tries to set all 
propeties of ClientDataSource and this can give NPE if the value for any 
property is null. The solution seems to be just to add a check before setting 
the property:
if(value != null)
                        properties.setProperty(propertyKey, value);

> Tracing client data source gives NPE if all data source properties are not set
> ------------------------------------------------------------------------------
>
>          Key: DERBY-1298
>          URL: http://issues.apache.org/jira/browse/DERBY-1298
>      Project: Derby
>         Type: Bug

>   Components: Network Client
>     Versions: 10.2.0.0, 10.1.3.0
>     Reporter: Deepa Remesh
>     Priority: Minor
>  Attachments: ClientTracing.java
>
> I found this when trying to capture client traces for another issue. If all 
> the properties are set to some value, tracing works without problems. I will 
> upload a repro with more details. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to