Skip to content Skip to sidebar Skip to footer

Parseobject Mergerest Raise Concurrentmodificationexception

I'm using Parse.com Android SDK(ver 1.5.1). I don't know why occur ConcurrentModificationException. Parse.com is very good. But It is big problem. I can't modify Parse.com SDK. So

Solution 1:

A general wild guess is that there may be some issue with the way you are calling the parse/android/sdk and the way that the parse sdk uses concurrency underneath their implementation of AsnyncTask.

One way is to figure out how your code and their Asnyc implementation are combining to throw that Concurrency exception.

Another way is to take on the task of owning the queues and the posting of runnables yourself in an implementation of parse.RestAPI via your own executor Service. Its alot more work but you totally control the objects that deliver requests to parse over https.

Solution 2:

I had something that looks like this while debugging my app. I found out that the ParseInstallation object gets corrupted. Once that happens there is absolutely nothing you can do.

Using the ParseCloud rest api does not help, since you still need the ParseInstallation anyway.

This is a pretty serious bug, since you cannot do much about it, at least by using the oficial parse API.

However the ParseInstallation object has several methods which can help us clean up the installation objects and solve this mess. You will have to use reflection to call them (a bit dirty if you ask me, but parse.com did not leave me any other choice).

But the essence of the fix/workaround is here (a bit ugly atm, but on purpose, since the solution is by definition ugly):

try {
            currentInstallation = ParseInstallation.getCurrentInstallation();
        } catch (Exception e) {
            try {
                Method[] methods = ParseInstallation.class.getDeclaredMethods();
                for (Method method : methods) {
                    String mName = method.getName();
                    if ("clearCurrentInstallationFromMemory".equals(mName)) {
                        // for static methods we can use null as instance of class
                        method.setAccessible(true);
                        method.invoke(null);
                    }
                    if ("clearCurrentInstallationFromDisk".equals(mName)) {
                        // for static methods we can use null as instance of class
                        method.setAccessible(true);
                        method.invoke(null, this);
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

Solution 3:

There is nothing really inherently bad to the way I am using parse.com at the moment. It is a very simple implementation.

I even was able to reproduce it with the examples they provide.

For my apps this problem is not kind of an issue. However, I keep on being able to reproduce this when I kill the app when the app is starting up. This means that if in your code your app crashes on start, there is a chance that your parse installation goes to some limbo state.

Because it then crashes whenever I try to get the ParseInstallation object.

Once that happens no matter what I do, the application won't start. The parse API will internally throw a ConcurrentModificationException, even if I remove all the logic of the app.

Post a Comment for "Parseobject Mergerest Raise Concurrentmodificationexception"