[ 
http://issues.apache.org/jira/browse/DERBY-900?page=comments#action_12376759 ] 

Sunitha Kambhampati commented on DERBY-900:
-------------------------------------------

The non portable String.getBytes() is used in parseSQLDCGRP as explained 
earlier.  This method is called by parseSQLDCROW which is called by 
parseSQLDIAGCI.

Client flow is as follows:
parseSQLDIAGCI -> parseSQLDCROW ->parseSQLDCGRP


But the server currently does not send SQLDIAGCI.  The only method that calls 
writeSQLDIAGCI is in writeSQLDIAGGRP (which is currently commented out code). 
writeSQLDIAGGRP is called by writeSQLCAXGRP.

In DRDARConnThread.writeSQLDIAGGRP we only write null data and the callto 
writeSQLDIAGCI is commented out. 

I tried to see if I could uncomment this code in writeSQLDIAGGRP  so I can get 
a repro, but then it seems like the other methods like writeSQLDIAGSTT also 
will need to be implemented correctly. The writeSQLDIAGSTT method just returns 
a null data for now.  

In short, the encoding changes made in parseSQLDCGRP in client is not currently 
being used.

The p2 changes are fairly straightforward if you dont include the cleanup 
changes.
In parseSQLDCGRP ,
sqldcState is read, and then sent across to NetSqlca constructor using 
getBytes(). The encoding to be used is UTF8 since that is what the server sends.

String sqldcState = readFastString(5, 
netAgent_.targetTypdef_.getCcsidSbcEncoding()); // SQLSTATE 
// note netAgent_.targetTypdef_.getCcsidSbcEncoding() is UTF8.

If you feel comfortable with just change to remove the getBytes() to use UTF8 
encoding without the cleanup, then I can submit a patch with just that change. 

If you have any ideas or suggestions to repro this, please let me know.  
Thanks. 

> Remove use of String(byte[]) and String(byte[], int, int) constructors in 
> network client leading to non-portable behaviour
> --------------------------------------------------------------------------------------------------------------------------
>
>          Key: DERBY-900
>          URL: http://issues.apache.org/jira/browse/DERBY-900
>      Project: Derby
>         Type: Bug

>   Components: Network Client
>     Reporter: Daniel John Debrunner
>     Assignee: Sunitha Kambhampati
>      Fix For: 10.2.0.0
>  Attachments: Derby900.p2.diff.txt, TestEnc.java, derby900.diff.p1.txt, 
> derby900.p2.stat.txt, derby900.stat.p1.txt, derby900.test.diff.txt, 
> derby900.test.stat.txt, for_10.1_derby900.diff.p1.txt, 
> for_10.1_derby900.stat.p1.txt
>
> These constructors use the Java default platform encoding to convert the 
> bytes to a String, this typically leads to bugs on platforms with different 
> encodings.
> Replace with code using fixed conversion, or alternative mechanisms. 
> If the call is required its use should be commented as to why it is required.
> org.apache.derby.client.am.ClobOutputStream - some existing bug?
> org.apache.derby.client.am.DateTime - see DERBY-877
> org.apache.derby.client.am.sqlca
> I generated this list using the Java search in eclipse for references to the 
> constructors
> String(byte[])
> String(byte[],int,int)

-- 
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