{"record":{"id":"8a09a913407b6ff0","repo":"didi/DoKit","slug":"picasso-instance-already-shut-down-cannot-submit","errorCode":null,"errorMessage":"Picasso instance already shut down. Cannot submit new requests.","messagePattern":"Picasso instance already shut down\\. Cannot submit new requests\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java","lineNumber":73,"sourceCode":"    private static final AtomicInteger nextId = new AtomicInteger();\n\n    private final DokitPicasso picasso;\n    private final Request.Builder data;\n\n    private boolean noFade;\n    private boolean deferred;\n    private boolean setPlaceholder = true;\n    private int placeholderResId;\n    private int errorResId;\n    private int memoryPolicy;\n    private int networkPolicy;\n    private Drawable placeholderDrawable;\n    private Drawable errorDrawable;\n    private Object tag;\n\n    RequestCreator(DokitPicasso picasso, Uri uri, int resourceId) {\n        if (picasso.shutdown) {\n            throw new IllegalStateException(\n                    \"Picasso instance already shut down. Cannot submit new requests.\");\n        }\n        this.picasso = picasso;\n        this.data = new Request.Builder(uri, resourceId, picasso.defaultBitmapConfig);\n    }\n\n    RequestCreator() {\n        this.picasso = null;\n        this.data = new Request.Builder(null, 0, null);\n    }\n\n    /**\n     * Explicitly opt-out to having a placeholder set when calling {@code into}.\n     * <p>\n     * By default, Picasso will either set a supplied placeholder or clear the target\n     * {@link ImageView} in order to ensure behavior in situations where views are recycled. This\n     * method will prevent that behavior and retain any already set image.\n     */","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/RequestCreator.java#L55-L91","documentation":"Thrown by the RequestCreator constructor when the DokitPicasso instance it is asked to build requests for has been shut down. Picasso.shutdown() releases its cache, dispatcher, and workers; the instance is terminal, and every new request (load(...)) is rejected with IllegalStateException.","triggerScenarios":"Calling picasso.load(...) (or new RequestCreator(picasso, ...)) after picasso.shutdown() ran on that same instance.","commonSituations":"Keeping the Picasso instance in a static/singleton field that outlives shutdown triggered by DoKit teardown, low-memory handling, or app-module reload; background threads racing a shutdown; tests that shut down between cases but reuse the instance.","solutions":["Do not reuse a Picasso instance after calling shutdown(); re-obtain the instance from its provider/factory for new requests.","Remove or defer the shutdown() call if the instance must keep serving requests.","Cancel in-flight work and drain threads before shutdown so late submissions cannot occur."],"exampleFix":"// before\nstatic DokitPicasso PICASSO = DokitPicasso.get(context);\nvoid onTeardown() { PICASSO.shutdown(); }\nvoid later() { PICASSO.load(url).into(view); } // throws\n\n// after\nvoid onTeardown() { PICASSO.shutdown(); PICASSO = null; }\nvoid later() { if (PICASSO == null) PICASSO = DokitPicasso.get(context); PICASSO.load(url).into(view); }","handlingStrategy":"validation","validationCode":"if (picasso.shutdown) {\n  picasso = DokitPicasso.get(context); // or your provider's fresh instance\n}\npicasso.load(url).into(view);","typeGuard":null,"tryCatchPattern":"try {\n  picasso.load(url).into(view);\n} catch (IllegalStateException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"shut down\")) {\n    picasso = DokitPicasso.get(context); // re-obtain and retry once\n    picasso.load(url).into(view);\n  } else { throw e; }\n}","preventionTips":["Null out references to a Picasso instance when you shut it down.","Never call shutdown() from low-memory handlers while requests may still be created.","Route all loads through one accessor that re-creates the instance after shutdown."],"tags":["android","picasso","lifecycle","singleton","shutdown"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}