{"record":{"id":"efe960d2934d100f","repo":"beemdevelopment/Aegis","slug":"openinputstream-returned-null-efe960","errorCode":null,"errorMessage":"openInputStream returned null","messagePattern":"openInputStream returned null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/ui/tasks/ImportIconPackTask.java","lineNumber":36,"sourceCode":"    private final ImportIconPackTask.Callback _cb;\n\n    public ImportIconPackTask(Context context, ImportIconPackTask.Callback cb) {\n        super(context, context.getString(R.string.importing_icon_pack));\n        _cb = cb;\n    }\n\n    @Override\n    protected ImportIconPackTask.Result doInBackground(ImportIconPackTask.Params... params) {\n        Context context = getDialog().getContext();\n        ImportIconPackTask.Params param = params[0];\n\n        File tempFile = null;\n        try {\n            tempFile = File.createTempFile(\"icon-pack-\", \"\", context.getCacheDir());\n            try (InputStream inStream = context.getContentResolver().openInputStream(param.getUri());\n                 FileOutputStream outStream = new FileOutputStream(tempFile)) {\n                if (inStream == null) {\n                    throw new IOException(\"openInputStream returned null\");\n                }\n                IOUtils.copy(inStream, outStream);\n            }\n\n            IconPack pack = param.getManager().importPack(tempFile);\n            return new Result(pack, null);\n        } catch (IOException | IconPackException e) {\n            e.printStackTrace();\n            return new ImportIconPackTask.Result(null, e);\n        } finally {\n            if (tempFile != null) {\n                tempFile.delete();\n            }\n        }\n    }\n\n    @Override\n    protected void onPostExecute(ImportIconPackTask.Result result) {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/ui/tasks/ImportIconPackTask.java#L18-L54","documentation":"ImportIconPackTask.doInBackground throws IllegalStateException when ContentResolver.openInputStream on the selected icon-pack URI returns null, i.e. the provider cannot open the resource (uninstalled/deleted file or lost permission). The icon-pack import aborts before extracting to the temporary file.","triggerScenarios":"Thrown at app/src/main/java/com/beemdevelopment/aegis/ui/tasks/ImportIconPackTask.java:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Null-check the InputStream from ContentResolver.openInputStream(uri) and return an error Result naming the icon-pack Uri","Handle SecurityException and FileNotFoundException from openInputStream and report which icon pack failed to import","Ensure the picked Uri has persisted read permission before background import begins","Clean up the temp file in a finally block when the stream is null so no orphaned cache files remain"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}