Skip to content

Android, fix crash. Avoid concurrent execute update cursor in Sqlite #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 5, 2025

Conversation

fpanizza
Copy link
Contributor

Problem

Crash en app de Novartis con Sqlite en proc getpages2

https://issues.genexus.dev/viewissue.aspx?204648

Solution

Use ReentrantLock to avoid concurrent execute cursor in SqLite database in Android when autocommit is on (NoIntegrity).
This avoid crash that occurs with postExecute commands, like :

2025-05-20 09:44:45.657 6142-6536 AndroidRuntime com.novartis.pharma.drarthur.ext E FATAL EXCEPTION: pool-2-thread-2
Process: com.novartis.pharma.drarthur.ext, PID: 6142
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.database.CursorWindow.getNumRows()' on a null object reference
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:154)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:140)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:232)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:271)
at org.sqldroid.SQLDroidResultSet.first(SQLDroidResultSet.java:113)
at org.sqldroid.SQLDroidConnection.changedRowsCount(SQLDroidConnection.java:520)
at org.sqldroid.SQLDroidPreparedStatement.execute(SQLDroidPreparedStatement.java:221)
at org.sqldroid.SQLDroidPreparedStatement.executeUpdate(SQLDroidPreparedStatement.java:251)
at com.genexus.db.driver.GXPreparedStatement.executeUpdate(GXPreparedStatement.java:308)
at com.genexus.db.UpdateCursor.postExecute(UpdateCursor.java:41)
at com.genexus.db.DataStoreProvider.execute(DataStoreProvider.java:262)
at com.genexus.db.DataStoreProvider.execute(DataStoreProvider.java:169)
at com.novartis.gtm.getpages2.S111(getpages2.java:191)
at com.novartis.gtm.getpages2.privateExecute(getpages2.java:125)
at com.novartis.gtm.getpages2.execute_int(getpages2.java:117)
at com.novartis.gtm.getpages2.execute(getpages2.java:97)
at com.novartis.gtm.getpages2.execute(getpages2.java:42)
at com.genexus.android.core.layers.LocalProcedure.execute(LocalProcedure.java:78)
at com.genexus.android.core.actions.CallGxObjectAction.runGxObject(CallGxObjectAction.java:123)
at com.genexus.android.core.actions.CallGxObjectAction.Do(CallGxObjectAction.java:82)
at com.genexus.android.core.actions.CompositeAction.Do(CompositeAction.java:173)
at com.genexus.android.core.actions.ActionExecution$2.doInBackground(ActionExecution.java:368)
at com.genexus.android.core.actions.ActionExecution$2.doInBackground(ActionExecution.java:360)
at com.genexus.android.core.utils.TaskRunner.lambda$executeOnExecutor$2(TaskRunner.java:23)
at com.genexus.android.core.utils.TaskRunner$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)

…se in Android when autocommit is on (NoIntegrity).
@genexusbot
Copy link
Collaborator

Cherry pick to beta success

1 similar comment
@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@fpanizza fpanizza added testing required This issue has not been tested yet by Product Team and removed work in progress labels May 31, 2025
@fpanizza fpanizza requested a review from jotapeg June 3, 2025 12:41
@fpanizza
Copy link
Contributor Author

fpanizza commented Jun 3, 2025

@jotapeg necesito el review de este PR para bajar a Stable para el proyecto novartis
gracias

Copy link
Contributor

@jotapeg jotapeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apruebo para no bloquear, pero si se pueden responder esas dudas, mejor. Gracias

@fpanizza fpanizza removed the testing required This issue has not been tested yet by Product Team label Jun 5, 2025
@fpanizza fpanizza merged commit 7df77fc into master Jun 5, 2025
10 checks passed
@fpanizza fpanizza deleted the fix/AndroidAutoCommitExecuteCursor branch June 5, 2025 13:33
@fpanizza fpanizza changed the title Android, fix crash. Avoid concurrent execute cursor in Sqlite Android, fix crash. Avoid concurrent execute update cursor in Sqlite Jun 5, 2025
@fpanizza fpanizza added the tested Issue has been tested by Product Team label Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot closed tested Issue has been tested by Product Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants