Skip to content
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

Port db package to Kotlin #532

Merged
merged 6 commits into from
Mar 22, 2024
Merged

Port db package to Kotlin #532

merged 6 commits into from
Mar 22, 2024

Conversation

vasct
Copy link
Contributor

@vasct vasct commented Jan 10, 2024

Port all classes in db package to Kotlin with some minor improvements
Never close of the db connections once opened - up for consideration
Multi-threaded synchronization of the db usage is not modified

@@ -47,8 +47,10 @@ dependencies {

// Unit testing dependencies
testImplementation(project(":test_shared"))
testImplementation(libs.test.robolectric)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests couldn't build on my setup without adding this dependency

@@ -19,7 +19,7 @@ import org.json.JSONObject
/**
* This class is a utils class, mainly used to handle migration when encryption fails or encryption level is changed
*/
object CryptUtils {
internal object CryptUtils {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made internal because I changed the DBAdapter to be internal instead of RestrictTo(Library) annotation and this class exposed DBAdapter. I think it should also probably be internal so I changed it as well.

private var dbAdapter: DBAdapter? = null

@WorkerThread
@Synchronized
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made synchronized to avoid double initialization of DBAdapter per DBManager. Could also be implemented with double-checked locking.
Can we also rename the method to something like getDBAdapter(Context), because currently it is used at many places with the semantics of "get" instead of "load"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the annotation ensure that syncromisation is done or is it a marker so the implementer handles it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The annotation is used to mark the JVM generated method as synchronized (the same as having the synchronized keyword on a java method).

vasct added 4 commits January 24, 2024 12:34
Update tests of DBManager and DBAdapter
Rename QueueCursor to QueueData
Port BaseDatabaseManager to Kotlin
Change usage of ArgumentCaptor with DBAdapter to use mockito-kotlin
@vasct vasct changed the base branch from client_side_inapps to develop January 24, 2024 10:37
@vasct vasct changed the title [DRAFT] Port db package to Kotlin Port db package to Kotlin Jan 24, 2024
@CTLalit CTLalit merged commit 7dd0603 into develop Mar 22, 2024
4 checks passed
@CTLalit CTLalit deleted the db-kotlin branch March 22, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants