{"record":{"id":"0f2047bec6ea1cf4","repo":"nostra13/Android-Universal-Image-Loader","slug":"deque-full","errorCode":null,"errorMessage":"Deque full","messagePattern":"Deque full","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"library/src/main/java/com/nostra13/universalimageloader/core/assist/deque/LinkedBlockingDeque.java","lineNumber":185,"sourceCode":"     * Creates a {@code LinkedBlockingDeque} with a capacity of\n     * {@link Integer#MAX_VALUE}, initially containing the elements of\n     * the given collection, added in traversal order of the\n     * collection's iterator.\n     *\n     * @param c the collection of elements to initially contain\n     * @throws NullPointerException if the specified collection or any\n     *                              of its elements are null\n     */\n    public LinkedBlockingDeque(Collection<? extends E> c) {\n        this(Integer.MAX_VALUE);\n        final ReentrantLock lock = this.lock;\n        lock.lock(); // Never contended, but necessary for visibility\n        try {\n            for (E e : c) {\n                if (e == null)\n                    throw new NullPointerException();\n                if (!linkLast(new Node<E>(e)))\n                    throw new IllegalStateException(\"Deque full\");\n            }\n        } finally {\n            lock.unlock();\n        }\n    }\n\n\n    // Basic linking and unlinking operations, called only while holding lock\n\n    /**\n     * Links node as first element, or returns false if full.\n     */\n    private boolean linkFirst(Node<E> node) {\n        // assert lock.isHeldByCurrentThread();\n        if (count >= capacity)\n            return false;\n        Node<E> f = first;\n        node.next = f;","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/nostra13/Android-Universal-Image-Loader/blob/ba33ec64d0daaa881d35852460e78c58d086bc18/library/src/main/java/com/nostra13/universalimageloader/core/assist/deque/LinkedBlockingDeque.java#L167-L203","documentation":"The collection constructor of this backported LinkedBlockingDeque throws IllegalStateException(\"Deque full\") while copying elements if linkLast() fails, i.e. the number of source elements exceeds the deque's capacity (initialized here to Integer.MAX_VALUE). This class is an Android-compatible copy of java.util.concurrent.LinkedBlockingDeque used internally by UIL's task queues; in practice the default capacity makes this unreachable unless a bounded capacity was set.","triggerScenarios":"new LinkedBlockingDeque<>(hugeCollection) with a capacity set via this(Integer.MAX_VALUE) is effectively unbounded; reachable only if the class is instantiated with a small capacity elsewhere and then filled from a larger collection. Library users hit it only if they directly instantiate this backport with a bound.","commonSituations":"Custom code instantiating the backported deque with an explicit capacity and copy-constructing from a bigger collection; migration code converting queues during configuration changes.","solutions":["Size the capacity to at least the collection size: new LinkedBlockingDeque<>(Math.max(capacity, c.size()))","Or use the unbounded default constructor before adding elements","Prefer java.util.concurrent.LinkedBlockingDeque on API 9+ instead of this backport"],"exampleFix":"// before\nLinkedBlockingDeque<Runnable> q =\n        new LinkedBlockingDeque<Runnable>(16);\nq = new LinkedBlockingDeque<Runnable>(q); // growing later may exceed 16 -> Deque full\n\n// after\nLinkedBlockingDeque<Runnable> q =\n        new LinkedBlockingDeque<Runnable>(Math.max(16, source.size()));","handlingStrategy":"validation","validationCode":"int cap = Math.max(desiredCapacity, sourceCollection.size());\nLinkedBlockingDeque<Runnable> q = new LinkedBlockingDeque<Runnable>(cap);\nfor (Runnable r : sourceCollection) q.addLast(r);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer java.util.concurrent.LinkedBlockingDeque on API 9+ instead of this backport","Never copy-construct into a smaller fixed capacity","Size capacity from the actual workload bound, not a magic number"],"tags":["deque","concurrency","capacity","internal-api"],"backgroundTag":null,"analyzedSha":"ba33ec64d0daaa881d35852460e78c58d086bc18","analyzedAt":"2026-08-14T15:41:15.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}