react-native-ble-manager
react-native-ble-manager copied to clipboard
`java.util.ConcurrentModificationException` in `Peripheral.asWritableMap` on Android 14
Describe the bug
There is an concurrent usage issue with the Peripheral.asWritableMap on Android 14.
To Reproduce
Haven't been able to reproduce yet.
Expected behavior
To to throw such exception.
Smartphone (please complete the following information):
- Device: -
- OS: Android 14
Additional context
Stacktrace
Exception java.util.ConcurrentModificationException:
at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1029)
at java.util.ArrayList$Itr.next (ArrayList.java:982)
at android.bluetooth.BluetoothGatt.getServices (BluetoothGatt.java:1437)
at it.innove.Peripheral.asWritableMap (Peripheral.java:223)
at it.innove.Peripheral.lambda$onServicesDiscovered$2 (Peripheral.java:298)
at it.innove.Peripheral.$r8$lambda$68IZVZOPb-h7ZTf0nnf3p8RiFZ4
at it.innove.Peripheral$$ExternalSyntheticLambda17.run
at android.os.Handler.handleCallback (Handler.java:958)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
There is some good explanation about this exception here: https://stackoverflow.com/a/55141359
I'm not sure if using the for (it : iterator) syntax would help here.
Describe the bug
There is an concurrent usage issue with the
Peripheral.asWritableMapon Android 14.To Reproduce
Haven't been able to reproduce yet.
Expected behavior
To to throw such exception.
Smartphone (please complete the following information):
- Device: -
- OS: Android 14
Additional context
Stacktrace
Exception java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1029) at java.util.ArrayList$Itr.next (ArrayList.java:982) at android.bluetooth.BluetoothGatt.getServices (BluetoothGatt.java:1437) at it.innove.Peripheral.asWritableMap (Peripheral.java:223) at it.innove.Peripheral.lambda$onServicesDiscovered$2 (Peripheral.java:298) at it.innove.Peripheral.$r8$lambda$68IZVZOPb-h7ZTf0nnf3p8RiFZ4 at it.innove.Peripheral$$ExternalSyntheticLambda17.run at android.os.Handler.handleCallback (Handler.java:958) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:230) at android.os.Looper.loop (Looper.java:319) at android.app.ActivityThread.main (ActivityThread.java:8919) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)There is some good explanation about this exception here: https://stackoverflow.com/a/55141359
I'm not sure if using the
for (it : iterator)syntax would help here.
Sorry for the late response. Thank you for providing the stack trace for it. Addressed this issue on pr #1264 with a quick fix.