PDA

View Full Version : Index Out Of Range Error


bmorreal
1st November 2007, 07:40 PM
Can anyone see why I would get the following error:

java.lang.ArrayIndexOutOfBoundException: 1
at com.wallstreetwise.app.jspell.domain.JSpellIndex.e nglishChecks(JSpellIndex.java:1021)
at com.wallstreetwise.app.jspell.domain.JSpellIndex.s earch(JSpellIndex.java:777)
at com.wallstreetwise.app.jspell.domain.JSpellDiction aryLocal.checkWord(JSpellDictionaryLocal.java:217)
at com.wallstreetwise.app.jspell.domain.JSpellParser. getError(JSpellParser.java:243)
at com.harris.atep.utils.spellcheck.AlumniTodaySpellC heck.getSpellandVulgarInfo(AlumniTodaySpellCheck.j ava:108)
at com.harris.atep.service.scheduler.AlumniTodaySpell Job.executeInternal(AlumniTodaySpellJob.java:89)
at org.springframework.scheduling.quartz.QuartzJobBea n.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:2 02)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:529)



The error originates on a call to parser.getError() as marked bellow:
<snip>
parser = new JSpellParser( jdLocal );

for (Map.Entry<String, String> fieldMap : stringMap.entrySet()) { // iterate over the 4 fields
spellErrorCount = 0;
vulgarErrorCount = 0;
suggestions = null;

String fieldValue = fieldMap.getValue();

if (null != fieldValue) {
parser.setTextString( fieldValue );

try {
JSpellErrorInfo error = parser.getError();

while ( error != null ) {

// logger.info( "error toTokenizedString= " + error.toTokenizedString());

// logger.info( "error length= " + error.getSuggestions().length);

suggestions = error.getSuggestions(); // should only be one as defined by props file

if ( (suggestions.length > 0) && (suggestions[0] != null) ) {

if ( !suggestions[0].startsWith( "*")) {
spellErrorCount++;

} else if ( suggestions[0].startsWith( "*")) {
vulgarErrorCount++;

} else {
spellErrorCount++;
}

} else {
spellErrorCount++; // why was error != null anyway?
}

error = parser.getError(); // <-- error occurs here get next error in fieldValue
suggestions = null;
}
<snip>

Any ideas? I am using JDK 1.5.0_11 and JRE 1.5

staff
5th November 2007, 09:01 AM
Brian, I see that you solved this ticket in the help desk. Just so others may benefit from your findings I am posting your reply:

"Forget this ticket. The problem is that error.getSuggestions() can
return 'NULL' (no suggested replacement) but still have a length greater
than 0."

Thanks for the help."

bmorreal
5th November 2007, 09:44 PM
I believe you are confusing two different help request tickets. Yes what you have posted, what I have found to be true, addresses the issue of ticket WZL-415893, whereas the error.getSuggestions() call can return a size of either 1 or 0 if the JSpell suggestion is NULL. Although I think that JSpell should be consistent in it's return from that call, I have handled the situation in my code.

The issue posted here is current, and concerns ticket RFA-811408, which is the problem of every once in a few hundred records or so I receive an 'arrayIndexOutOfBounds' error when I call the parse.getError() as shown.

The latest information I have from your support desk seems to imply that it may be failing due to a data encoding error. What specific ISO encodings does JSpell require/prefer or other wise support? My data is stored in an Oracle 10g database and uses the ISO-8859-1 as it encoding default.

Attached to the ticket was the java error stacktrace, my code and the actual data that was being processed that caused the parse.getError() problem. I have other examples of data where this problem will occur with and will send it to you as part of my response to the ticket RFA-811408.

staff
6th November 2007, 04:48 PM
sounds good. Will check it in the helpdesk.

bmorreal
14th November 2007, 03:20 PM
Any luck with this issue?

bmorreal
16th November 2007, 12:34 PM
In my efforts to assist you in determining the cause of your problem, I have created a zip file which contains the code and data which will consistently re-create this issue. I have sent this file via ticket RFA-811408. NOTE: The zip file to analyze for this posting/problem is too large to be attached to this forum post. Please check your help desk for the attachment under ticket number RFA-811408.

Unzip this file and follow the instructions given in the RFA-811408.txt file to reproduce problem.

As I have stated in previous emails, this is a production show stopper for us and your prompt attention is truly required. I have spent significant effort in order to provide you with this information to assist in your problem analysis and correction. If you have any questions please contact me @ xxxxxxxx (contained in help desk ticket) for any clarifications. Otherwise I will be waiting for your response / fix for this problem.

staff
19th December 2007, 12:46 AM
As determined by our technician, make sure to set the max number of suggestions to a value greater than 1, otherwise you'll encounter errors if the logic falls into our compound word detection routine. We are working on a more permanent fix which prevents setting the number of suggestions to less than two.