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

ConcurrentModificationException in Sentry.currentBreadcrumbs #110

Closed
fab1an opened this issue Dec 14, 2016 · 6 comments
Closed

ConcurrentModificationException in Sentry.currentBreadcrumbs #110

fab1an opened this issue Dec 14, 2016 · 6 comments

Comments

@fab1an
Copy link

fab1an commented Dec 14, 2016

I'm getting this error now and then:

java.util.ConcurrentModificationException: null
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at java.lang.reflect.Method.invoke(Method.java)
    at android.app.ActivityThread.main(ActivityThread.java:5593)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Handler.handleCallback(Handler.java:739)
    at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
    at mypackage.RequestAdapter$enqueue$1.onResponse(NetworkManager.kt:166)
    at mypackage.SentryLog.captureFailedRetrofitResponse(SentryLog.kt:99)
    at com.joshdholtz.sentry.Sentry.captureEvent(Sentry.java:310)
    at com.joshdholtz.sentry.Sentry.currentBreadcrumbs(Sentry.java:735)
    at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)

captureFailedRetrofitResponse looks just like this:

Sentry.captureEvent(SentryEventBuilder()
    .setMessage(message)
    .setExtra(mapOf(
         "errorBody" to "string"
    )))
@marcomorain
Copy link
Collaborator

Hi @fab1an - Sorry about the crash. I'll take a look into this today.

marcomorain added a commit that referenced this issue Dec 15, 2016
marcomorain added a commit that referenced this issue Dec 15, 2016
@fab1an
Copy link
Author

fab1an commented Dec 16, 2016

Great thank you. Maybe you can leverage a BlockingQueue for this.

Or better just sychronized the access with a ReadWriteLock.

@fab1an
Copy link
Author

fab1an commented Dec 19, 2016

Do you need help on this?

@marcomorain
Copy link
Collaborator

Yes please @fab1an - can you take a look at the approach in #111 please? What do you think?

@fab1an
Copy link
Author

fab1an commented Dec 22, 2016

@marcomorain I think the BlockingQueue was the wrong idea.

It's probably easiest to use a ReadWriteLock: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html

private final ReentrantReadWriteLock breadcrumbLock = ReentrantReadWriteLock()

When reading the list wrap it like this:

try {
   breadcrumbLock.readLock().lock()

   ...use or copy the list ...

} finally {
   breadcrumbLock.readLock().unlock()
}

When writing:

try {
   breadcrumbLock.writeLock().lock()

   ...modify the list...

} finally {
   breadcrumbLock.writeLock().unlock()
}

marcomorain added a commit that referenced this issue Jan 23, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
@marcomorain
Copy link
Collaborator

Hi @fab1an - I have not had much time to look into this over the holidays.

Can you take a look at PR #111 please? I had not used ReadWriteLocks before, thanks for showing me that pattern.

marcomorain added a commit that referenced this issue Jan 23, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
marcomorain added a commit that referenced this issue Jan 23, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
marcomorain added a commit that referenced this issue Jan 23, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
marcomorain added a commit that referenced this issue Jan 23, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
marcomorain added a commit that referenced this issue Jan 24, 2017
Addresses #110

Add a ReadWriteLock to protect access to the breadcrumbs array
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