dev@fi.java.net

Re: Bugs in Decoder.java

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 02 Nov 2009 11:50:34 +0100

Hi Andrzej,

> The team I work for build the Encoder (C#) and Decoder (in C) and as
> a sanity test we decided to check that against
> the java fastinfoset implementation.
Great!

> We believe that we found a number of bugs in the Decoder
> implementation testing it with fastinfoset-test.fi (see attachment).
> Here is the list of things we found so far:
>
> ---------------------------------------------
> Decoder.java
>
> Wrong:
> ...
> private void decodeTableItems(StringArray array) throws
> FastInfosetException, IOException {
> for (int i = 0; i < decodeNumberOfItemsOfSequence(); i++) {
>
> array.add(decodeNonEmptyOctetStringOnSecondBitAsUtf8String());
> }
> }
> ...
> Correct: (See point C.2.5.2 in http://www.itu.int/rec/T-REC-X.891-200505-I)
>
> private void decodeTableItems(StringArray array) throws
> FastInfosetException, IOException {
> int noOfNamespaces = decodeNumberOfItemsOfSequence();
> for (int i = 0; i < noOfNamespaces; i++) {
> array.add(decodeNonEmptyOctetStringOnSecondBitAsUtf8String());
> }
> }
Please correct me, if I'm wrong, in C.2.5.2 I see "If the optional
component external-vocabulary of initial-vocabulary is present, then
the bit '0' (padding) is appended to the bit stream and the component
is encoded as described in C.22.".
Fix you propose is good, but as I understand it's about getting
noOfNamespaces just once. Not sure I understand direct relationship to
C.2.5.2.


> Wrong:
> ...
> private int decodeNumberOfItemsOfSequence() throws IOException {
> final int b = read();
> if (b < 128) {
> return b;
> } else {
> return ((b & 0x0F) << 16) | (read() << 8) | read();
> }
> }
> ...
> Correct -> (See point C.2.1 in http://www.itu.int/rec/T-REC-X.891-200505-I)
> ...
> private int decodeNumberOfItemsOfSequence() throws IOException {
> final int b = read();
> if (b < 128) {
> return b + 1;
> } else {
> return (((b & 0x0F) << 16) | (read() << 8) | read()) +
> 129;
> }
> }
Andrzej, can you pls. elaborate, which decoding alg. you refer?


> -------------------------------------------------
> We fixed those using the source code fastinfoset 1.2.7 source code
> and managed to progress with parsing of the namespace-names and
> local-names correctly and now we are stuck at element-name-surrogates.
> It looks like Decoder.decodeIntegerIndexOnSecondBit() implements C.
> 25.2 (from fastinfoset spec.) in the wrong way.
>
> I was wondering if there is anyone that could help us with fixing
> those issues or at least confirm that we interpret the specification
> (http://www.itu.int/rec/T-REC-X.891-200505-I) in the right way.
Can you pls. elaborate here?

Thank you.

WBR,
Alexey.

>
>
> Any help much appreciated.
> ~Andrzej
>
>
>
>
>
>
> <fastinfoset-
> test
> .fi
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_fi.dev.java.net
> For additional commands, e-mail: dev-help_at_fi.dev.java.net