Avoid Java double brace initialization
TL;DR
Avoid doing this:
new HashMap<String, String>() {{
put("key", value);
}};
Leak Trace
I was recently looking at the following leak trace from LeakCanary:
┬───
│ GC Root: Global variable in native code
│
├─ com.bugsnag.android.AnrPlugin instan...
blog.p-y.wtf4 min read
Svyatoslav Starkov
To avoid leaks one can wrap double brace initialization into a static function. Not pretty, but should work.