-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: moved db operations to background thread/executor and fixed leaking objects #237
Conversation
} | ||
}; | ||
Future future = executor.submit(runnable); | ||
// Need to perform db operations on a separate thread to support strict mode. | ||
Future<?> future = Executors.newSingleThreadExecutor().submit(runnable); | ||
try { | ||
// todo: shall we add some timeout here ? | ||
future.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are not utilising the Future reponse, we might use "executor.execute()"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we are not using the future's response but we do need to await until the runnable finishes its execution, hence i went with using submit and getting future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using executor.execute() now
@@ -466,11 +455,12 @@ private void deleteStatusColumn(SQLiteDatabase database) { | |||
|
|||
private boolean checkIfStatusColumnExists(SQLiteDatabase database) { | |||
String checkIfStatusExistsSqlString = "PRAGMA table_info(events)"; | |||
Cursor allRows = null; | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do try with resources for closeables. That's recommended approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can do that, will change it accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed it
core/src/main/java/com/rudderstack/android/sdk/core/DBPersistentManager.java
Outdated
Show resolved
Hide resolved
…ized blocks, catching exceptions at place of generation, using try with resources for auto-closeables
Kudos, SonarCloud Quality Gate passed!
|
Fixes
Type of change
Checklist: