splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 383 forks source link

(With Fix) IndexOutOfBounds exception when searching a token #324

Closed alexcustos closed 5 years ago

alexcustos commented 7 years ago

I have got this exception recently. It looks like it's a result of a race condition. Please look at this commit for the fix: https://github.com/alexcustos/TokenAutoComplete/commit/9844fb4ab733e9e002fc980b288d6928069c64e9 Sorry, but I can't send it as a pool request.

java.lang.IndexOutOfBoundsException: at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java) at com.tokenautocomplete.CharacterTokenizer.findTokenStart (CharacterTokenizer.java) at com.tokenautocomplete.TokenCompleteTextView.allowDuplicates$1385ff (TokenCompleteTextView.java) or .getCorrectedTokenBeginning (TokenCompleteTextView.java) or .deleteSelectedObject (TokenCompleteTextView.java) or .addObject (TokenCompleteTextView.java) or .access$300 (TokenCompleteTextView.java) at com.tokenautocomplete.TokenCompleteTextView.enoughToFilter (TokenCompleteTextView.java)

mgod commented 7 years ago

Thanks! I'll probably make a slightly different change to the same effect (it looks like the issue is changes in the getText() object between calls?). For this and #317, do you mind if I just do these in my own changes in the code or do you want me to make sure you get author credit on them? I have a few concerns about some of the changes in #317, but most of them are obvious improvements that I want better commit separation for.

alexcustos commented 7 years ago

it looks like the issue is changes in the getText() object between calls

I think so too. Maybe the synchronization is the best solution here, but I had tried hard to get this exception on my own. I found it practically impossible, so I just decreased the consequences.

do you mind if I just do these in my own changes in the code

I'm fine with it. Please feel free to use my code in any way you like.

mgod commented 5 years ago

I think this should be resolved now in version 3.0.0.