Repository: square/leakcanary
Issue: kotlin.KotlinNullPointerException in Instrumentation test 

We are seeing a NPE while running the Instrumentation test to leaks.
Here's the stacktrace:
```
kotlin.KotlinNullPointerException
    at shark.internal.OpenJdkInstanceRefReaders$HASH_SET$create$1.read(OpenJdkInstanceRefReaders.kt:192)
    at shark.internal.OpenJdkInstanceRefReaders$HASH_SET$create$1.read(OpenJdkInstanceRefReaders.kt:184)
    at shark.internal.ChainingInstanceReferenceReader.expandVirtualRefs(ChainingInstanceReferenceReader.kt:31)
    at shark.internal.ChainingInstanceReferenceReader.read(ChainingInstanceReferenceReader.kt:19)
    at shark.internal.ChainingInstanceReferenceReader.read(ChainingInstanceReferenceReader.kt:13)
    at shark.internal.DelegatingObjectReferenceReader.read(DelegatingObjectReferenceReader.kt:17)
    at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:164)
    at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:135)
    at shark.HeapAnalyzer.findLeaks(HeapAnalyzer.kt:275)
    at shark.HeapAnalyzer.analyzeGraph(HeapAnalyzer.kt:253)
    at shark.HeapAnalyzer.analyze$shark(HeapAnalyzer.kt:217)
    at shark.HeapAnalyzer.analyze(HeapAnalyzer.kt:166)
    at leakcanary.internal.InstrumentationHeapAnalyzer.analyze(InstrumentationHeapAnalyzer.kt:49)
    at leakcanary.internal.RetryingHeapAnalyzer.analyze(RetryingHeapAnalyzer.kt:35)
    at leakcanary.InstrumentationLeakDetector.detectLeaks(InstrumentationLeakDetector.kt:137)
    at leakcanary.FailTestOnLeakRunListener.detectLeaks(FailTestOnLeakRunListener.kt:131)
    at leakcanary.FailTestOnLeakRunListener.testFinished(FailTestOnLeakRunListener.kt:114)
    at xxx
    at xxx
    at org.junit.runner.notification.SynchronizedRunListener.testFinished(SynchronizedRunListener.java:56)
    at org.junit.runner.notification.RunNotifier$7.notifyListener(RunNotifier.java:190)
    at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
    at org.junit.runner.notification.RunNotifier.fireTestFinished(RunNotifier.java:187)
    at org.junit.internal.runners.model.EachTestNotifier.fireTestFinished(EachTestNotifier.java:38)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:331)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
    at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395)
    at xxx
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1962)
Caused by: :
Caused by: kotlin.KotlinNullPointerException
```
### Version Information

* LeakCanary version: 2.8.1
* Android OS version: Running Android 7.0 (API 24)
* Gradle version: 7.3.3

Changed files:
shark/src/main/java/shark/internal/OpenJdkInstanceRefReaders.kt

diff --git a/shark/src/main/java/shark/internal/OpenJdkInstanceRefReaders.kt b/shark/src/main/java/shark/internal/OpenJdkInstanceRefReaders.kt
index f2af2501a..8eaccae65 100644
--- a/shark/src/main/java/shark/internal/OpenJdkInstanceRefReaders.kt
+++ b/shark/src/main/java/shark/internal/OpenJdkInstanceRefReaders.kt
@@ -188,8 +188,10 @@ internal enum class OpenJdkInstanceRefReaders : OptionalFactory {
         }
 
         override fun read(source: HeapInstance): Sequence<Reference> {
-          // "HashSet.map" is never null.
-          val map = source["java.util.HashSet", "map"]!!.valueAsInstance!!
+          // "HashSet.map" is never null when looking at the Android sources history, however
+          // we've had a crash report where it was null on API 24.
+          // https://github.com/square/leakcanary/issues/2342
+          val map = source["java.util.HashSet", "map"]!!.valueAsInstance ?: return emptySequence()
           return InternalSharedHashMapReferenceReader(
             className = "java.util.HashMap",
             tableFieldName = "table",