|
Attaching a patch 'derby-683.diff'.
The write methods in ClobOutputStream were using default encoding when constructing a String from bytes. ClobOutputStream is the output stream returned by call to Clob.setAsciiStream. This is meant to be a stream to which ascii encoded characters can be written. So the writes to this stream should not be using default encoding. This patch changes the write methods to use String constructors with ascii encoding. Currently, I have a repro to test this. I am working on adding a test to the harness. This requires some changes to the test harness and I would like to submit this as a separate patch. To test this using the repro, run the following command on Windows with Sun JDK1.5: java -Dfile.encoding=UTF-16 -Doutput.encoding=Cp1252 clob With this patch, I have run derbyall on Windows with Sun JDK 1.4.2. No failures. It would be good if someone can look at this patch and commit the code changes if they are okay. I will submit the harness changes and a test in a separate patch. Thanks Deepa, the patch looks good. I think the harness problem is a hard one, especially for useprocess=false. Post what you have and I am sure folks will help out. We all want you done with this and back on DERBY-210 #:)
I am attaching a patch 'derby-683_tests.diff' which adds testing for this issue. The patch changes the harness to enable running tests/suites using an encoding different from the default system encoding.
------------------------------------ Background: ------------------------------------ To test For this, I first tried using 'jvmflags' property in the test harness. Harness uses this property to launch the jvm process to run tests. So it is possible to do this only when useprocess=true. I could run the test by specifying "jvmflags=-Dfile.encoding=UTF-16" in <test>_app.properties file. However, the test output gets written using UTF-16 encoding and it appears in strange format. To read the output, harness needs to know what encoding the test jvm used. For this, it has to parse the jvmflags, look for "-Dfile.encoding=", get and store the encoding specified, launch the jvm using the encoding, and later use that encoding to read the test output. Since jvmflags property is used by harness for other purposes, I added a new property 'derbyTesting.encoding' to the harness. Harness will read this property to get the encoding and internally change jvmflags before launching the jvm to run tests. As mentioned before, all this is possible only when useprocess=true. I don't think my changes cover all the things that harness needs to support to run tests with different encodings. So I am trying to list what we can/cannot do with these changes: * Can specify the encoding in <test>_app.properties file and run an individual test (not as part of a suite). If the encoding property is specified for a test, it gets used only if the test is run individually using RunTest. When the test gets run as part of a suite, useprocess is set to false in RunTest and no new jvm gets launched for the test. So the encoding property won't get used. * Can specify the encoding in <suite>.properties file and run the whole suite of tests using that encoding. In this case, a new jvm is launched for RunTest class and all tests are run with the encoding specified. * Cannot successfully run sql tests if the encoding property is specified. The sql files will get read using the specified encoding and may not be meaningful. If the sql files always get read using fixed encoding, this will not be a problem. I think this change is planned in * Can run tests/suites using encoding property and look for possible areas for cleanup. Once the patch is reviewed and if it is okay, I will update the testing readme file with this information. ------------------------------------ Changes: ------------------------------------ This patch does the following: * Adds a new property 'derbyTesting.encoding' to the test harness. This property can be specified as a suite in <suite>.properties file or as test property in <test>_app.properties file. If this property is set at suite level, it overrides the property set in the tests inside that suite. For this, I made changes to RunSuite.java, RunList.java and RunTest.java to read the property at each level only if it is not set at the higher level. * The patch uses the value specified in 'derbyTesting.encoding=<enc_value>' for two things: 1. To append to the jvmflags property used to start the child jvm process. Following is appended: -Dfile.encoding=<enc_value>. Currently, I have hard-coded the prefix "-Dfile.encoding=" in the code. In case any new jvm uses a different property name, the prefix can be specified for each jvm in the corresponding jvm class and this can be retrieved and used. 2. To read the test output: - when using RunTest, ProcessStreamResult class is used to read the output of the jvm process and write to the output file. The patch changes this class to use InputStreamReader which is created using <enc_value> encoding. The OutputStreamWriter which writes to .out file is created using system default encoding. This needs to use the default encoding because the harness will compare the .out file to master using <default_enc>. - when using RunSuite, HandleResult class is used to read the test output. The patch changes this class to use InputStreamReader which is created using <enc_value> encoding. * Creates a new suite encodingTests with jdbcapi/lobStreams.java in .runall file. I created a new suite because I cannot specify the encoding property in a test and run it as part of a suite. * Adds derbyTesting.encoding=UTF-16 to encodingTests.properties file. Adds excludes for all jvms except Sun jdk1.5. * Adds the encodingTests suite to derbynetclientmats With this patch, I ran derbyall with Sun JDK1.4.2 on Windows XP. No failures. With Sun JDK1.5, I ran the new suite encodingTests and verified that the specified encoding is getting used to run the test. Please review this patch. Thanks I looked at the deltas and it looks reasonable to me.
I ran the suite on windows 2000 with - jdk15 on windows 2000 - which was fine - - jdk14 - which was skipped, and failed when I commented that out - ibm15 - which should've skipped, but seemed to work, except for plopping 'process exception: null" to the console: ----------------------- ....lse^derbyTesting.encoding=UTF-16^runwithjdk13=false^runwithibm15=false^runwithjdk12=false^hostName=localhost^runwithibm13=false -Dsuitename=encodingTests:encodingTests -Dtopsuitename=encodingTests org.apache.derbyTesting.functionTests.harness.RunTest jdbcapi/lobStreams.java Process exception: null Generated report: encodingTests_report.txt ------------------------ It doesn't look like this patch is to blame for the non-skipping of ibm15, I'll have a look at that. But I am wondering about why you tried to have that skipped, was that because of that Process exception? Thanks Myrna for looking at the patch.
When I ran the repro clob.java with UTF-16 encoding using ibm15, I got NoClassDefFoundError, same as what I get for jdk14. That is the reason I skipped the suite for ibm15. I had not tried running the suite with ibm15 and did not know the skipping was not working. Thanks for finding that. Well, retried after ant clobber, and this time, the skipping worked, I must've had a half-baked environment.
Do I need to wait to commit this patch for the ibm15 skip to be fixed?
The ibm15 skip was a non-issue. However, I've found that possibly the encoding setting may not get reset with subsequent tests.
What I found is this: when commenting out the 'runwithjdk14=false' property, and running derbyall(not when running derbynetclientmats) with insane jars under DOS all subsequent derbynetclientmats tests fail with error like this in the diff: *** Start: CompatibilityTest jdk1.4.2_03 DerbyNetClient derbynetclientmats:derbynetclientmats 2006-02-07 11:48:42 *** 0 add > þÿ j a v a . l a n g . N o C l a s s D e f F o u n d E r r o r : org.apache.derbyTesting.functionTests.tests.junitTests.derbyNet.CompatibilityTesÿý > Exception in thread "main" Test Failed. *** So, there's something not entirely ok in this patch. One solution would be to put the encodingTests as the last suite in derbynetclientmats.properties, but that still leaves an unpleasant feeling. I suggest we do not commit the test work at this time, and I will look into it in line with Harness changes are also needed to run tests using different encoding. Please see http://issues.apache.org/jira/browse/DERBY-683
The patch 'derby-683_tests.diff' solves this problem partially but has following problem found by Myrna http://issues.apache.org/jira/browse/DERBY-683#action_12365038. Committed as svn revision 374469 to the trunk. Verified changes by running the attached repro.
Hi Myrna, I can't get this patch (derby-683_021006.diff) to apply cleanly due to changes in RunTest. Could you merge your changes and post an updated patch?
Attaching an updated patch for the test harness. (
This is close to what was created before. Compared to deepa's original, it - skips any test run with derbyTesting.encoding if the jvm is not jdk15 - does not set file.encoding in the RunSuite & thus will get set & unset for every test where it applies - includes a brief mention of the property in the java/testing/READEM.htm I also took advantage of touching up the README.htm to mention with the remote server functionality that derby.jar needs to be available (although not in the classpath), and to list the junit tests as a valid test type. Committed
Thanks Myrna and Andrew for working on this test patch.
I was updating my workspace to see if my test for Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.properties (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall Andrew, can you please check this? Thanks. Yes, I must have applied the patch twice and patch didn't catch that the new files had already been 'patched'. Good catch, thanks Deepa!
Reopening to port this fix to 10.1 branch
To merge this fix, I have also ported the fix for
svn merge -r 374468:374469 https://svn.apache.org/repos/asf/db/derby/code/trunk With the patch for Committed to 10.1 with revision 407391.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.