[ http://issues.apache.org/jira/browse/DERBY-683?page=all ]
Deepa Remesh updated DERBY-683:
-------------------------------
Attachment: derby-683-for-review.diff
clob.java
ascii.txt
The patch for this seems to be a small change but I am having trouble adding a
test for this. I have been trying for some time to write a test for verifying
that ascii encoding gets used when writing with OutputStream returned by
Clob.setAsciiStream. I do not know how to add a test which can run with the
test harness because the test will need to set the property "file.encoding". I
have been able to verify my changes using a java program which uses a test in
jdbcapi/lobStreams.java. I am attaching the repro program and my patch (not
ready for commit) to this JIRA.
To run the repro,
1. Start network server on port 2222.
2. Using Sun JDK1.5, run: java -Dfile.encoding=UTF-16 clob
Output without my patch:
S t a r t t e s t C l o b W r i t e 3 P a r a m
F A I L - - w r o n g c l o b l e n g t h ; o r i g i n a l : 9 4
c l o b l e n g t
h : 4 7
t e s t C l o b W r i t e 3 P a r a m f i n i s h e d
Output with my patch:
S t a r t t e s t C l o b W r i t e 3 P a r a m
C o m p a r i n g f i l e a n d c l o b
T e s t 3 - P A S S - C l o b a n d f i l e c o n t e n t s m
a t c h
t e s t C l o b W r i t e 3 P a r a m f i n i s h e d
The output of the repro is not in a very good format as you can see above but
this is the only charset I could find to repro this problem on my Windows
machine. I have a few questions and I'd appreciate if someone can answer them.
1. Does my test cover the problem described in the JIRA?
2. Is there some other charset I can use instead of UTF-16? I need a charset
which will have different encoding for any ascii character than the ASCII
encoding? I am using a Windows machine. To add to test harness, we will need a
charset which is available on all platforms.
3. How can I run this repro as a test inside the test harness? Test harness
seems to treat file.encoding property differently and I see RunTest using it to
set "derby.ui.codeset". In my repro, I tried using
"System.setProperty("file.encoding", "UTF-16");" but that did not work. Only
command-line "-Dfile.encoding" works.
4. Is there some other way to test this? Maybe there is another way to test
this and then rest of my questions are invalid.
I'd appreciate help in this. Thanks.
> Use correct encoding for ClobOutputStream on client
> ---------------------------------------------------
>
> Key: DERBY-683
> URL: http://issues.apache.org/jira/browse/DERBY-683
> Project: Derby
> Type: Bug
> Components: Network Client
> Versions: 10.1.1.1, 10.1.1.0
> Environment: all
> Reporter: Sunitha Kambhampati
> Assignee: Deepa Remesh
> Fix For: 10.2.0.0
> Attachments: ascii.txt, clob.java, derby-683-for-review.diff
>
> In client, there is code in ClobOutputStream which uses this api - new
> String(byte[]). Per the java api
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#String(byte[])
> ,this will construct a string by decoding the array of bytes using the
> platform's default character set.
> org.apache.derby.client.am.ClobOutputStream is used for Clob.setAsciiStream
> and the write methods use the String(byte[]) which is incorrect because it
> will use the default platform encoding. Per the jdbcapi , this should use
> ascii encoding.
> In areas related to Clobs, also check for other places where String(byte[])
> is used,as it may not be the desired behavior.
> Dan pointed this problem here :
> http://issues.apache.org/jira/browse/DERBY-463?page=comments#action_12356742
--
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