Crash: ConcurrentModificationException in DataHandler.getPojo from HistorySearcher

Open
#2,836 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, java
Domain
mobile-dev

Research direction

The crash trace points to DataHandler.getPojo (DataHandler.java around line 969), called from getHistory (line 363) and run by HistorySearcher.doInBackground (line 82). Read how DataHandler.providers is iterated and where providers.put and providers.remove are called from settings and bind/unbind code. Done means the background iteration can no longer race with main-thread mutation, for example by iterating a snapshot or using a concurrent collection, and the crash no longer reproduces.

Written by the indexing model from the issue text.

Description

crash
Type Crash
Affected users (last 30 days) 1
Reports (last 30 days) 1
App versions 226
Android API levels 29
Sample device Redmi 9, API 29, v226

Play Console issue ID: 8ae271dbf97a4619a51f9add38d09027

java.util.ConcurrentModificationException
  at java.util.HashMap$HashIterator.nextNode (HashMap.java:1441)
  at java.util.HashMap$ValueIterator.next (HashMap.java:1470)
  at fr.neamar.kiss.DataHandler.getPojo (DataHandler.java:969)
  at fr.neamar.kiss.DataHandler.getHistory (DataHandler.java:363)
  at fr.neamar.kiss.searcher.HistorySearcher.doInBackground (HistorySearcher.java:82)

HistorySearcher iterates DataHandler.providers (a plain HashMap) on a background thread while the main thread adds or removes providers (providers.put / providers.remove when a provider is bound, unbound or toggled in settings). Unchanged on master.

Dominant language
Java
Stars
3.5k
Forks
664
Avg merge
21h 40m
Merged PRs (30d)
106

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Neamar/KISS

All issues in Neamar/KISS

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.