JayRock Intermittent Missing Values

199 Views Asked by At

I am having a problem with JayRock where I am intermittently receiving Missing Value errors.

I cannot recreate the error but it is happening in production around 100-150 times a day (out of tens of thousands of requests).

After investigation it has been discovered that on the requests which fail there is no [RequestBody] element in the HTTP Request.

Normally it would look like this:

[urlfield]

[RequestBody] {"id":1,"method":"getAllAirports","params":[]}

[cookies]

But in cases where it hasn't worked the request contains:

[urlfield]

[cookies]

I am using the default JayRock proxy, and by using the ?test page the requests are always working.

Has anybody come across this before? Or have any ideas?

Many thanks,

Iain

UPDATE: Looking at the data it seems exclusively an error in IE, with errors in IE7, 8, 9 and 10. Although 8 has by far the most errors, even though it's traffic is comparable to 9 and less than 10.

1

There are 1 best solutions below

1
On

Seems like a parsing problem from Jayrock http://jayrock.googlecode.com/hg/src/Jayrock.Json/Json/JsonTextReader.cs

private JsonToken Parse()
    {
        char ch = NextClean();

        //
        // String
        //

        if (ch == '"' || ch == '\'')
        {
            return Yield(JsonToken.String(NextString(ch)));
        }

        //
        // Object
        //

        if (ch == '{')
        {
            _reader.Back();
            return ParseObject();
        }

        //
        // Array
        //

        if (ch == '[')
        {
            _reader.Back();
            return ParseArray();
        }

        //
        // Handle unquoted text. This could be the values true, false, or
        // null, or it can be a number. An implementation (such as this one)
        // is allowed to also accept non-standard forms.
        //
        // Accumulate characters until we reach the end of the text or a
        // formatting character.
        // 

        StringBuilder sb = new StringBuilder();
        char b = ch;

        while (ch >= ' ' && ",:]}/\\\"[{;=#".IndexOf(ch) < 0) 
        {
            sb.Append(ch);
            ch = _reader.Next();
        }

        _reader.Back();

        string s = sb.ToString().Trim();

        if (s.Length == 0)
            throw SyntaxError("Missing value.");


        //
        // Boolean
        //

        if (s == JsonBoolean.TrueText || s == JsonBoolean.FalseText)
            return Yield(JsonToken.Boolean(s == JsonBoolean.TrueText));

        //
        // Null
        //

        if (s == JsonNull.Text)
            return Yield(JsonToken.Null());

        //
        // Number
        //
        // Try converting it. We support the 0- and 0x- conventions. 
        // If a number cannot be produced, then the value will just
        // be a string. Note that the 0-, 0x-, plus, and implied 
        // string conventions are non-standard, but a JSON text parser 
        // is free to accept non-JSON text forms as long as it accepts 
        // all correct JSON text forms.
        //

        if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+')
        {
            if (b == '0' && s.Length > 1 && s.IndexOfAny(_numNonDigitChars) < 0)
            {
                if (s.Length > 2 && (s[1] == 'x' || s[1] == 'X'))
                {
                    string parsed = TryParseHex(s);
                    if (!ReferenceEquals(parsed, s))
                        return Yield(JsonToken.Number(parsed));
                }
                else
                {
                    string parsed = TryParseOctal(s);
                    if (!ReferenceEquals(parsed, s))
                        return Yield(JsonToken.Number(parsed));
                }
            }
            else
            {
                if (!JsonNumber.IsValid(s))
                    throw SyntaxError(string.Format("The text '{0}' has the incorrect syntax for a number.", s));

                return Yield(JsonToken.Number(s));
            }
        }

        //
        // Treat as String in all other cases, e.g. when unquoted.
        //

        return Yield(JsonToken.String(s));
    }