{"record":{"id":"4622aa28a37ee3a3","repo":"airbnb/epoxy","slug":"a-pool-was-already-found","errorCode":null,"errorMessage":"A pool was already found","messagePattern":"A pool was already found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"epoxy-adapter/src/main/java/com/airbnb/epoxy/ActivityRecyclerPool.kt","lineNumber":38,"sourceCode":"     * only needs to hold pools for active activities.\n     */\n    private val pools = ArrayList<PoolReference>(5)\n\n    @JvmOverloads\n    fun getPool(\n        context: Context,\n        poolFactory: () -> RecyclerView.RecycledViewPool\n    ): PoolReference {\n\n        val iterator = pools.iterator()\n        var poolToUse: PoolReference? = null\n\n        while (iterator.hasNext()) {\n            val poolReference = iterator.next()\n            when {\n                poolReference.context === context -> {\n                    if (poolToUse != null) {\n                        throw IllegalStateException(\"A pool was already found\")\n                    }\n                    poolToUse = poolReference\n                    // finish iterating to remove any old contexts\n                }\n                poolReference.context.isActivityDestroyed() -> {\n                    // A pool from a different activity that was destroyed.\n                    // Clear the pool references to allow the activity to be GC'd\n                    poolReference.viewPool.clear()\n                    iterator.remove()\n                }\n            }\n        }\n\n        if (poolToUse == null) {\n            poolToUse = PoolReference(context, poolFactory(), this)\n            context.lifecycle()?.addObserver(poolToUse)\n            pools.add(poolToUse)\n        }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/airbnb/epoxy/blob/e45bd3a61fe3a1f130e184f5b8dcf172ab99025a/epoxy-adapter/src/main/java/com/airbnb/epoxy/ActivityRecyclerPool.kt#L20-L56","documentation":"ActivityRecyclerPool caches one RecyclerView.RecycledViewPool per Activity context. When retrieving a pool for a context, if a second pool reference for the same context is encountered during iteration, its internal invariant is broken and this IllegalStateException is thrown.","triggerScenarios":"getPool(context) finding two pool references whose context === the requested context during iteration — i.e., a pool was registered twice for the same Activity.","commonSituations":"Re-registering or leaking pool registrations for the same Activity; unusual Activity recreation patterns causing duplicate entries in the internal map.","solutions":["Ensure the pool is registered at most once per Activity context (guard your registration code)","Update epoxy-adapter — this indicates corrupted internal state in the pool registry","As a workaround, construct the pool yourself and pass it to EpoxyRecyclerView instead of relying on ActivityRecyclerPool"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { pool = ActivityRecyclerPool.getPool(activity) } catch (e: IllegalStateException) { pool = RecyclerView.RecycledViewPool() }","preventionTips":["Register a pool once per Activity","Update epoxy-adapter to get registry fixes","Provide your own RecycledViewPool to avoid the shared registry"],"tags":["android","epoxy","recycledviewpool","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e45bd3a61fe3a1f130e184f5b8dcf172ab99025a","analyzedAt":"2026-09-13T03:24:16.052Z","contentChangedAt":"2026-09-13T03:24:16.052Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}