beemdevelopment/Aegis · error · IOException

openInputStream returned null

Error message

openInputStream returned null

What it means

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.

Solutions

  1. Null-check the InputStream from ContentResolver.openInputStream(uri) and return an error Result naming the icon-pack Uri
  2. Handle SecurityException and FileNotFoundException from openInputStream and report which icon pack failed to import
  3. Ensure the picked Uri has persisted read permission before background import begins
  4. Clean up the temp file in a finally block when the stream is null so no orphaned cache files remain
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/src/main/java/com/beemdevelopment/aegis/ui/tasks/ImportIconPackTask.java:36 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of beemdevelopment/Aegis@d6f4e5925a (2026-09-08). Data as JSON: /api/errors/efe960d2934d100f. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/com/beemdevelopment/aegis/ui/tasks/ImportIconPackTask.java:36

    private final ImportIconPackTask.Callback _cb;

    public ImportIconPackTask(Context context, ImportIconPackTask.Callback cb) {
        super(context, context.getString(R.string.importing_icon_pack));
        _cb = cb;
    }

    @Override
    protected ImportIconPackTask.Result doInBackground(ImportIconPackTask.Params... params) {
        Context context = getDialog().getContext();
        ImportIconPackTask.Params param = params[0];

        File tempFile = null;
        try {
            tempFile = File.createTempFile("icon-pack-", "", context.getCacheDir());
            try (InputStream inStream = context.getContentResolver().openInputStream(param.getUri());
                 FileOutputStream outStream = new FileOutputStream(tempFile)) {
                if (inStream == null) {
                    throw new IOException("openInputStream returned null");
                }
                IOUtils.copy(inStream, outStream);
            }

            IconPack pack = param.getManager().importPack(tempFile);
            return new Result(pack, null);
        } catch (IOException | IconPackException e) {
            e.printStackTrace();
            return new ImportIconPackTask.Result(null, e);
        } finally {
            if (tempFile != null) {
                tempFile.delete();
            }
        }
    }

    @Override
    protected void onPostExecute(ImportIconPackTask.Result result) {

View on GitHub (pinned to d6f4e5925a)