You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to our research, there are misuses about the following AsyncTask class: de.geeksfactory.opacclient.frontend.LibraryListActivity.LoadLibrariesTask
The problems are:
LoadLibrariesTask is an inner class of LibraryListActivity, which means it holds strong reference the Activity, which can lead to memory leak when the Activity is destroyed and the AsyncTask did not finish;
The instance of LoadLibrariesTask are not cancelled before the Activity is destroyed, which can lead to the wrong invocation of onPostExecute() if the Activity is destroyed
The doInBackground() did not check the status of AsyncTask.
I think we can make following changes to fix the misuse problems:
LoadLibrariesTask should be a static inner class.
loadLibrariesTask, the instance of LibraryListActivity should invoke cancel() in the onDestroy() method of LibraryListActivity if it is not null
In the loop of doInBackground() method, check whether AsyncTask is cancelled via isCancelled(). If current AsyncTask is cancelled, jump out of the loop.
These are my suggestions above, thank you.
The text was updated successfully, but these errors were encountered:
According to our research, there are misuses about the following AsyncTask class:
de.geeksfactory.opacclient.frontend.LibraryListActivity.LoadLibrariesTask
The problems are:
LoadLibrariesTask
is an inner class ofLibraryListActivity
, which means it holds strong reference the Activity, which can lead to memory leak when the Activity is destroyed and the AsyncTask did not finish;LoadLibrariesTask
are not cancelled before the Activity is destroyed, which can lead to the wrong invocation ofonPostExecute()
if the Activity is destroyeddoInBackground()
did not check the status of AsyncTask.I think we can make following changes to fix the misuse problems:
LoadLibrariesTask
should be a static inner class.loadLibrariesTask
, the instance ofLibraryListActivity
should invokecancel()
in theonDestroy()
method ofLibraryListActivity
if it is not nulldoInBackground()
method, check whether AsyncTask is cancelled viaisCancelled()
. If current AsyncTask is cancelled, jump out of the loop.These are my suggestions above, thank you.
The text was updated successfully, but these errors were encountered: