Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 5cdd2c3

Browse files
committed
perform a check in method build to only allow for variable to be set once
1 parent 3ef7c66 commit 5cdd2c3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

topl-service/src/main/java/io/matthewnelson/topl_service/notification/ServiceNotification.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,14 @@ class ServiceNotification internal constructor(
339339
* [io.matthewnelson.topl_service.TorServiceController.Builder.build]
340340
* */
341341
internal fun build(context: Context) {
342-
Companion.serviceNotification = this.serviceNotification
343-
Companion.serviceNotification.setupNotificationChannel(context)
342+
// Only initialize it once. Reflection has issues here
343+
// as it's in a Companion object.
344+
try {
345+
Companion.serviceNotification.hashCode()
346+
} catch (e: UninitializedPropertyAccessException) {
347+
Companion.serviceNotification = this.serviceNotification
348+
Companion.serviceNotification.setupNotificationChannel(context)
349+
}
344350
}
345351

346352
}

0 commit comments

Comments
 (0)