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

TaskUtils and InterruptedException #553

Closed
danepowell opened this issue Dec 4, 2016 · 4 comments
Closed

TaskUtils and InterruptedException #553

danepowell opened this issue Dec 4, 2016 · 4 comments

Comments

@danepowell
Copy link

danepowell commented Dec 4, 2016

I have an Android app that periodically crashes when I call save() on a ParseObject. Here is the top of the stack trace:

java.lang.RuntimeException: java.lang.InterruptedException
at com.parse.ParseTaskUtils.wait(ParseTaskUtils.java:47)
at com.parse.ParseObject.save(ParseObject.java:1395)

I have no clue what would be throwing this InterruptedException. It's possible that this isn't Parse's fault, but I've never seen this exception anywhere else and I'm not sure how to proceed with debugging this. Can anyone point me in the right direction?

@danepowell
Copy link
Author

Now I'm seeing this when calling other functions as well, such as ParseCloud.callFunction:

java.lang.RuntimeException: java.lang.InterruptedException
at com.parse.ParseTaskUtils.wait(ParseTaskUtils.java:47)
at com.parse.ParseCloud.callFunction(ParseCloud.java:83)

Does anyone have any idea how to at least start to troubleshoot this?

@danepowell
Copy link
Author

At least in the first case, this actually appears to not be a problem with Parse. I was updating Parse objects in an Android Sync Adapter, which apparently can be interrupted if the sync is cancelled. The solution was to override the Sync Adapter onSyncCanceled method to prevent the thread from being killed.

@matthewkrueger
Copy link

Hey @danepowell. I'm seeing this same crash and I have the same situation as you (Parse inside an Android Sync Adapter).

I've @OverRide'd onSyncCanceled, but I've no clue what to put inside that method - can you give me any tips for what onSyncCanceled needs to do? Also, have you seen this issue since you made your original post?

Thanks!

@danepowell
Copy link
Author

@matthewkrueger you can put anything (or nothing) inside of onSyncCanceled. This is what I have:

@Override
public void onSyncCanceled() {
    Log.d(LOG_TAG, "Sync was cancelled.");
}

Depending on how complex or long-running your sync process is, you might want to actually do something in response to a call to onSyncCanceled, such as, I don't know, cancel the sync 😄 (i.e., set a flag that logic in onPerformSync periodically checks and uses to abort the sync gracefully)

I haven't seen this error since implementing this method.

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

2 participants