Commit 649872e3 authored by MozLando's avatar MozLando
Browse files

Merge #4722



4722: 1587405: Allow recording the empty string list r=mdboom a=mdboom



Co-authored-by: default avatarMichael Droettboom <mdboom@gmail.com>
parents 5ca68d23 594be627
......@@ -122,6 +122,10 @@ object ErrorRecording {
sendInPings = metricData.sendInPings
)
return errorMetric.testGetValue(usePingName)
if (!errorMetric.testHasValue(usePingName)) {
return 0
} else {
return errorMetric.testGetValue(usePingName)
}
}
}
......@@ -133,17 +133,6 @@ internal open class StringListsStorageEngineImplementation(
it.take(MAX_STRING_LENGTH)
}
// Record an error when attempting to record a zero-length list and return.
if (stringList.count() == 0) {
recordError(
metricData,
ErrorType.InvalidValue,
"Attempt to set() an empty string list to ${metricData.identifier}",
logger
)
return
}
if (stringList.count() > MAX_LIST_LENGTH_VALUE) {
recordError(
metricData,
......
......@@ -203,7 +203,7 @@ class StringListsStorageEngineTest {
}
@Test
fun `set() records an error and returns when passed an empty list`() {
fun `set() doesn't record an error when passed an empty list`() {
val metric = StringListMetricType(
disabled = false,
category = "telemetry",
......@@ -214,14 +214,10 @@ class StringListsStorageEngineTest {
StringListsStorageEngine.set(metricData = metric, value = listOf())
// If nothing was stored, then the snapshot should be null
val snapshot = StringListsStorageEngine.getSnapshot(
storeName = "store1",
clearStore = false)
assertNull("Empty list must not be stored", snapshot)
assertEquals(listOf<String>(), metric.testGetValue())
// Verify the error was recorded
assertEquals(1, testGetNumRecordedErrors(metric, ErrorType.InvalidValue))
// Verify the error was not recorded
assertEquals(0, testGetNumRecordedErrors(metric, ErrorType.InvalidValue))
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment