OpenTelemetryRumBuilder - Use lateinit vars instead of nullable/lazy.#1771
Open
breedx-splk wants to merge 1 commit into
Open
OpenTelemetryRumBuilder - Use lateinit vars instead of nullable/lazy.#1771breedx-splk wants to merge 1 commit into
breedx-splk wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1771 +/- ##
==========================================
- Coverage 62.97% 62.80% -0.18%
==========================================
Files 157 157
Lines 3446 3441 -5
Branches 352 350 -2
==========================================
- Hits 2170 2161 -9
- Misses 1179 1181 +2
- Partials 97 99 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| val cacheStorage: Lazy<CacheStorage> = lazy { cacheStorageOverride ?: CacheStorageImpl(context) } | ||
| val periodicTaskScheduler: Lazy<PeriodicTaskScheduler> = | ||
| lazy { periodicTaskSchedulerOverride ?: PeriodicTaskSchedulerImpl() } | ||
| cacheStorage = if (::cacheStorage.isInitialized) cacheStorage else CacheStorageImpl(context) |
Contributor
There was a problem hiding this comment.
In my opinion, the usage of ::lateinitvar.isInitialized is a clear hint that said var must be nullable. Unless we're certain that those lateinit vars shall be set before they're referenced anywhere in the code, we should keep them nullable; otherwise, we'll be introducing a risk of getting a runtime exception, which defeats the purpose of lateinit var. Nullable vars are safer to use for these kinds of scenarios.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to this comment, which was part of #1767.