Subject: [basex-talk] ArrayOutofBound exception on snapshot
From: Marco Lettere <[email-masked]>
To: BaseX <[email-masked]>
Date: Tue, 20 May 2014 15:18:55 +0200

Hello all,
we are investigating on the latest snapshot in order to check how our 
code cleans up itself when reducing the overhead of the "updating" code 
by using MIXED UPDATES.
We started experiencing the Index out of bound Exception on a particular 
insert of a complex XML document. I worked heavily on reducing the 
document to the smallest example that causes the exception getting to this:

<a b="1" c="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <b>
         <item x="1" w="2"/>
     </b>
     <n value="1" xsi:type="xs:string"/>
     <n value="2" xsi:type="xs:string"/>
</a>

Any change that reduces the XML causes the db:add to work.

When inserting directly with db:add it works.
When putting the same db:add in a restxq it still works.
When passing the XML as postbody and putting the $postbody parameter in 
the db:add the exception occurs.

declare  %rest:path("test1")
          %rest:POST("{$postbody}")
          %rest:consumes("application/xml")
function page:upd($postbody) {
          db:add("accountingrlus", document { $postbody } , 
"coll1/coll2/doc1.xml")
};

The error is not very explanatory since the -d output looks just like this:

MIXUPDATES: true
Improper use? Potential bug? Your feedback is welcome:
Contact: [email-masked]
Version: BaseX 8.0 beta 06146e9
Java: Oracle Corporation, 1.7.0_51
OS: Linux, i386
Stack Trace:
java.lang.ArrayIndexOutOfBoundsException
_ REQUEST _________________________________
[POST /test1]@8945989 org.eclipse.jetty.server.Request@888145
- DNT: 1
- Host: localhost:8984
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Content-Length: 200
- Content-Type: application/xml; charset=UTF-8
- Accept-Language: en-US,en;q=0.5
- Pragma: no-cache
- Connection: keep-alive
- User-Agent: Mozilla/5.0 (X11; Linux i686; rv:28.0) Gecko/20100101 
Firefox/28.0
- Cache-Control: no-cache
- Accept-Encoding: gzip, deflate
_ RESPONSE ________________________________
HTTP/1.1 500 Unexpected error: Improper use? Potential bug? Your 
feedback is welcome:
Contact: [email-masked]
Version: BaseX 8.0 beta 06146e9
Java: Oracle Corporation, 1.7.0_51
OS: Linux, i386
Stack Trace:
java.lang.ArrayIndexOutOfBoundsException
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1860

Thanks for the support,
Marco.