Skip to content

Commit

Permalink
Merge pull request #325 from prudrabhat/fix_timedelays
Browse files Browse the repository at this point in the history
Fix delay values in config extension
  • Loading branch information
prudrabhat committed Jan 12, 2023
2 parents c40c223 + 52d347c commit 418b1c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class ConfigurationExtension : Extension {
"config.isinternalevent"
internal const val DATASTORE_KEY = "AdobeMobile_ConfigState"
internal const val RULES_CONFIG_URL = "rules.url"
internal const val CONFIG_DOWNLOAD_RETRY_ATTEMPT_DELAY_MS = 5L
internal const val CONFIG_DOWNLOAD_RETRY_ATTEMPT_DELAY_MS = 5000L
internal const val CONFIGURATION_RESPONSE_IDENTITY_ALL_IDENTIFIERS = "config.allIdentifiers"
internal const val EVENT_STATE_OWNER = "stateowner"
internal const val GLOBAL_CONFIG_PRIVACY = "global.privacy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import java.util.Date
internal class ConfigurationStateManager {
companion object {
private const val LOG_TAG = "ConfigurationStateManager"
private const val CONFIGURATION_TTL = 15L
private const val CONFIGURATION_TTL_MS = 15000L
private const val BUILD_ENVIRONMENT = "build.environment"
private const val ENVIRONMENT_PREFIX_DELIMITER = "__"
private const val CONFIGURATION_URL_BASE = "https://assets.adobedtm.com/%s.json"
Expand Down Expand Up @@ -456,7 +456,7 @@ internal class ConfigurationStateManager {
*/
internal fun hasConfigExpired(appId: String): Boolean {
val latestDownloadDate: Date? = configDownloadMap[appId]
return latestDownloadDate == null || Date(latestDownloadDate.time + CONFIGURATION_TTL) < Date()
return latestDownloadDate == null || Date(latestDownloadDate.time + CONFIGURATION_TTL_MS) < Date()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class ConfigurationExtensionTest {
val completionCallbackCaptor: KArgumentCaptor<(Map<String, Any?>?) -> Unit> =
argumentCaptor()

// Should invoke update on state manager 2 times for retry and 3 time for success
// Should invoke update on state manager 2 times for retry and 3rd time for success
verify(mockConfigStateManager, times(3)).updateConfigWithAppId(
appIdCaptor.capture(),
completionCallbackCaptor.capture()
Expand All @@ -526,14 +526,14 @@ class ConfigurationExtensionTest {
// Verify first retry scheduling
verify(mockExecutorService).schedule(
Mockito.any(Runnable::class.java),
eq(5L),
eq(5000L),
eq(TimeUnit.SECONDS)
)

// Verify second retry scheduling
verify(mockExecutorService).schedule(
Mockito.any(Runnable::class.java),
eq(10L),
eq(10000L),
eq(TimeUnit.SECONDS)
)

Expand Down

0 comments on commit 418b1c9

Please sign in to comment.