Page 1 of 1

java.lang.ArrayIndexOutOfBoundsException

Posted: Tue Oct 15, 2013 8:41 am
by DuncanSoftware
Greetings!

We are using wurfl 1.5 on tomcat 7.0 with java 1.6.0_18. We've noticed that we're periodically getting this exception: java.lang.ArrayIndexOutOfBoundsException

Here is the stack/trace:

Code: Select all

net.sourceforge.wurfl.core.request.ACAutomaton.contains(ACAutomaton.java:124)
net.sourceforge.wurfl.core.request.ACAutomaton.contains(ACAutomaton.java:113)
net.sourceforge.wurfl.core.request.DefaultWURFLRequest._internalIsSmartTvBrowser(DefaultWURFLRequest.java:293)
net.sourceforge.wurfl.core.request.DefaultWURFLRequest._internalIsDesktopBrowserHeavyDutyAnalysis(DefaultWURFLRequest.java:249)
net.sourceforge.wurfl.core.DefaultWURFLService.getDeviceForRequest(DefaultWURFLService.java:177)
root cause: [java.lang.ArrayIndexOutOfBoundsException] nullnet.sourceforge.wurfl.core.request.ACAutomaton.contains(ACAutomaton.java:124)
net.sourceforge.wurfl.core.request.ACAutomaton.contains(ACAutomaton.java:113)
net.sourceforge.wurfl.core.request.DefaultWURFLRequest._internalIsSmartTvBrowser(DefaultWURFLRequest.java:293)
net.sourceforge.wurfl.core.request.DefaultWURFLRequest._internalIsDesktopBrowserHeavyDutyAnalysis(DefaultWURFLRequest.java:249)
net.sourceforge.wurfl.core.DefaultWURFLService.getDeviceForRequest(DefaultWURFLService.java:177)
We've seen this exception for at least these user agents:

Code: Select all

Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0
Mozilla/5.0 (iPad; CPU OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537.53
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
If I'm understanding the ACAutomation class correctly, it looks like the only way this exception can occur is if the failNodes array contains an int value that puts the currState variable out of bounds...

Code: Select all

currState = failNodes[currState];    //line 132
...so that the next iteration of the loop fails on this line...

Code: Select all

currState = childrenMoves[currState][j];     //124
Does the failNodes array contain indexes to the default devices in the wurfl xml? Does the xml have an error where a device does not have a fallback? These are just my guesses, but you guys are the experts. Please let me know if I can provide additional information.

Thanks,
The Ben

Re: java.lang.ArrayIndexOutOfBoundsException

Posted: Tue Oct 15, 2013 11:05 am
by fulvio.crivellaro
Greetings.

Unfortunately, I am not able to reproduce the issue, since none of the UAs you posted caused any crash in my testing environment (Tomcat 7.0.26).
May I ask you some more details about your configuration?
First of all, if you are using any patch file, can you please send me the files? (see my email below)
Moreover, where is the wurfl-1.5.jar file placed? Is it deployed together with your application (.war?) file, or is it shared in a library folder?

Feel free to contact me in my personal email: fulvio *DOT crivellaro *AT scientiamobile *DOT com

Thanks,
Fulvio

Re: java.lang.ArrayIndexOutOfBoundsException

Posted: Wed Oct 16, 2013 12:47 pm
by sm_support2
Thank you for your help in identifying the issue, Ben.

Version 1.5.0.1 of the Java API fixes the problem and it can be downloaded from the usual place.

Thanks