TeamAmaze / TeamAmaze/AmazeFileManager

How to solve leakages?

Open
#896 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Discussion
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

What I am proposing is (A contains or is a Context instance):

public Name extends AsyncTask<Params, Progress, Result> {
    private WeakContext<A> a;

    public Name(A a) {
        this.a = new WeakReference<>(a);
    }
    
    protected Result doInBackground(Params... params) {
        final A a = this.a.get();
        if(a == null) return;
        //do stuff with a.
    }

    protected void onPostExecute(Result result) {
        final A a = this.a.get();
        if(a == null) return;
        //do stuff
    }
}

This would be a general template for all AsyncTasks (not a Java generalization).
What are your thoughts? (maybe cancel() in case of a being null?).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by reviewing the six-comment thread and locating the AsyncTask implementations affected by the proposed WeakReference template. A clear outcome would define whether this is needed and how null contexts and cancellation should be handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.