com.esotericsoftware.kryo.KryoException: java.lang.IndexOutOfBoundsException #29
Comments
Did you solved this problem ? |
Hi @tieubao |
hi @nhachicha , my code is tight coupling so I can't provide it to you. But we apply the architecture described in this article which use a mutual class to query data from Snappy DB (we call it DataCenter) then use EventBus to post back the query results. And this problem happens when UI layer (fragments & activities) and other background threads (upload via network, get notification from server ... then save results to snappy) query at the same time. public static DB getDB(Context context) throws SnappydbException {
if (snappyDB == null || snappyDB.isOpen() == false) {
snappyDB = DBFactory.open(context, CJayConstant.DB_NAME);
}
return snappyDB;
} // Multiple functions have called this line of code at the same time.
// I think it cause the problem.
...
Session session = db.getObject(key, Session.class);
... Note: I only close the database after the app is terminated. It opens all the time. |
Did you solve this?I have the same problem. |
@colymore I get Kryo instance from SnappyDB, then I use it to register all models. This may make things work. |
Can You show me a little example of take kyro instance from snapy?thank u. |
|
Thank u so much. |
11-08 22:37:05.412 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ com.esotericsoftware.kryo.KryoException: java.lang.IndexOutOfBoundsException: Invalid index 104, size is 11 11-08 22:37:05.412 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ Serialization trace: 11-08 22:37:05.412 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ auditItems (com.cloudjay.cjay.model.Session) 11-08 22:37:05.412 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) 11-08 22:37:05.412 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:528) 11-08 22:37:05.422 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:657) 11-08 22:37:05.422 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.snappydb.internal.DBImpl.getObject(DBImpl.java:276) 11-08 22:37:05.422 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.cloudjay.cjay.DataCenter.uploadImportSession(DataCenter.java:1110) 11-08 22:37:05.432 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.cloudjay.cjay.task.job.UploadSessionJob.onRun(UploadSessionJob.java:141) 11-08 22:37:05.432 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.path.android.jobqueue.BaseJob.safeRun(BaseJob.java:109) 11-08 22:37:05.432 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.path.android.jobqueue.JobHolder.safeRun(JobHolder.java:60) 11-08 22:37:05.432 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.path.android.jobqueue.executor.JobConsumerExecutor$JobConsumer.run(JobConsumerExecutor.java:209) 11-08 22:37:05.442 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at java.lang.Thread.run(Thread.java:856) 11-08 22:37:05.472 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ Caused by: java.lang.IndexOutOfBoundsException: Invalid index 104, size is 11 11-08 22:37:05.472 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 11-08 22:37:05.482 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at java.util.ArrayList.get(ArrayList.java:304) 11-08 22:37:05.482 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.util.MapReferenceResolver.getReadObject(MapReferenceResolver.java:42) 11-08 22:37:05.482 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.Kryo.readReferenceOrNull(Kryo.java:805) 11-08 22:37:05.492 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:677) 11-08 22:37:05.492 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:106) 11-08 22:37:05.492 22269-22925/com.cloudjay.cjay.dev W/System.err﹕ ... 9 more
Sorry for pasting a lot of text but I just want to provide you full stack trace.
I face this problem when I try to call
getObject()
from multi-thread. Then it throw this Exception and say that:The text was updated successfully, but these errors were encountered: