ArrayIndexOutOfBoundsException in dataStore.getFeatureReader() when GetFeature 
response contains long UTF-8 strings
-------------------------------------------------------------------------------------------------------------------

                 Key: GEOT-2911
                 URL: http://jira.codehaus.org/browse/GEOT-2911
             Project: GeoTools
          Issue Type: Bug
          Components: data wfs
    Affects Versions: 2.6.0
         Environment: win32, 1.6.0_13
            Reporter: Dmitry Rykovanov


ArrayIndexOutOfBoundsException in dataStore.getFeatureReader() when GetFeature 
response contains long UTF-8 text nodes. The reason is 
org.xmlpull.mxp1.MXParser.fastHash( char ch[], int off, int len ) returns 
negative value on long (length > 16) UTF-8 (with code > 255) string.

When MXParser used instead of MXParserCachingStrings this error doesn't occur, 
but probably it will occur when response will contain elements with same long 
UTF-8 names.

{quote}
    protected static final int fastHash( char ch[], int off, int len ) {
        if(len == 0) return 0;
        //assert len >0
        int hash = ch[off]; // hash at beginnig
        //try {
        hash = (hash << 7) + ch[ off +  len - 1 ]; // hash at the end
        //} catch(ArrayIndexOutOfBoundsException aie) {
        //    aie.printStackTrace(); //should never happen ...
        //    throw new RuntimeException("this is violation of pre-condition");
        //}
        if(len > 16) hash = (hash << 7) + ch[ off + (len / 4)];  // 1/4 from 
beginning
        if(len > 8)  hash = (hash << 7) + ch[ off + (len / 2)];  // 1/2 of 
string size ...
        // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 
bit value
        // so max result == 29 bits so it is quite just below 31 bits for long 
(2^32) ...
        //assert hash >= 0;
        return  hash;
    }
{quote}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to