Hi,

FYI this should now be fixed in the trunk. The workaround is no longer
needed.

Regards,
Thomas


On Thu, Dec 5, 2013 at 8:22 AM, Thomas Mueller <[email protected]
> wrote:

> Hi,
>
> This is interesting. The "fix" looks strange (*not* using BufferedReader),
> and doesn't seem to solve the root cause. I think I know what the problem
> is now, it is the way CountingReaderInputStream works. Probably the same
> problem is in ValueLobDb.createTempClob. What we do there is partially
> read the string, and then convert that part to UTF-8. This doesn't produce
> the "correct" result. The same problem can be observed as follows. d0 is
> correct, but d2 is not:
>
>     public static void main(String... args) throws Exception {
>         String data = "012" + "\ud874\udcd9" + "345";
>         char[] d = data.toCharArray();
>         System.out.println("data.length = " + data.length());
>
>         byte[] b0 = new String(d, 0, 8).getBytes("UTF-8");
>         String d0 = new String(b0, "UTF-8");
>         if (!data.equals(d0)) {
>             System.out.println("data <> d0");
>             System.out.println("d0.length = " + d0.length());
>         }
>
>         byte[] b1 = new String(d, 0, 4).getBytes("UTF-8");
>         byte[] b2 = new String(d, 4, 4).getBytes("UTF-8");
>         byte[] b3 = new byte[b1.length + b2.length];
>         System.arraycopy(b1, 0, b3, 0, b1.length);
>         System.arraycopy(b2, 0, b3, b1.length, b2.length);
>         String d2 = new String(b3, "UTF-8");
>         if (!data.equals(d2)) {
>             System.out.println("data <> d2");
>             System.out.println("d2.length = " + d2.length());
>         }
>     }
>
> I think we need to use Charset / CharsetEncoder directly. Others also ran
> into this problem, see
> http://stackoverflow.com/questions/62241/how-to-convert-a-reader-to-inputstream-and-a-writer-to-outputstream
>
> Regards,
> Thomas
>
>
>
>
> On Wed, Dec 4, 2013 at 5:15 PM, Wickman <[email protected]> wrote:
>
>>
>> Den onsdagen den 4:e december 2013 kl. 14:56:48 UTC+1 skrev Noel Grandin:
>>
>>>
>>>
>>> On 2013-12-04 14:22, Wickman wrote:
>>> >
>>> > (I posted this before, but it didn't show up in the group?)
>>> >
>>> > Adding random strings to a CLOB column sometimes returns the wrong
>>> string. Here is working code example:
>>>
>>> Thanks for the test-case, this is now fixed in SVN.
>>>
>>> However, I'm not exactly sure why my fix works - it would seem to
>>> indicate that the Java BufferedReader class has some
>>> kind of boundary condition problem....
>>>
>>>
>> Excellent, thanks!
>>
>> It might be worth investigating separately why the problem happened.
>> Though I doubt this is a problem inside java.io.*, but one can never know :)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "H2 Database" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/h2-database.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to