Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException in SimpleArrayMap while registering type converter #188

Open
kunjan-a opened this issue Nov 23, 2016 · 3 comments

Comments

@kunjan-a
Copy link

kunjan-a commented Nov 23, 2016

While using LoganSquare (v1.3.7) for parsing json strings into java Pojos, some times I get a crash while registering type converter.
Corresponding stack trace is:
Caused by java.lang.ArrayIndexOutOfBoundsException: src.length=8 srcPos=0 dst.length=8 dstPos=2 length=8 at java.lang.System.arraycopy(System.java) at com.bluelinelabs.logansquare.util.SimpleArrayMap.put(SimpleArrayMap.java:400) at com.bluelinelabs.logansquare.LoganSquare.registerTypeConverter(LoganSquare.java:350)

Is this issue known or has it been fixed already?

Please do let me know if I can provide some other information.

@ericleong
Copy link

As far as I can tell, the implementation of SimpleArrayMap.java in LoganSquare is the same as the implementation in the support library, except LoganSquare has:

  • the debug statements removed
  • a simpler equals() implementation that doesn't check for SimpleArrayMap
  • a different lock object (SimpleArrayMap.class instead of ArrayMap.class)

The binarySearch() method is in a different place but the implementation looks identical. It may really be a bug in SimpleArrayMap - here's a crash caused by the same bug in the Android support library. But since it happens intermittently I'm inclined to think it's a race condition.

@nateridderman
Copy link

I'm also seeing this issue in my app intermittently.

@nateridderman
Copy link

I believe the issue is that LoganSquare.registerTypeConverter() is not thread safe. My app was calling it in multiple places, possibly at the same time from different threads. I noticed that they are stored in TYPE_CONVERTER which is a static final field. Seems bad. I'll try to follow up once my app is fixed to see if the crash reports disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants