@@ -63,25 +63,23 @@ func TestReuseWriteRequestV2(t *testing.T) {
6363 tsSlice = append (tsSlice , PreallocTimeseriesV2 {TimeSeriesV2 : TimeseriesV2FromPool ()})
6464 req .Timeseries = tsSlice
6565
66+ symbolsBackingArray := req .Symbols [:cap (req .Symbols )]
67+ require .Equal (t , "__name__" , symbolsBackingArray [1 ])
68+ require .Equal (t , "test" , symbolsBackingArray [2 ])
69+
6670 // Put the request back into the pool
6771 ReuseWriteRequestV2 (req )
6872
69- // Retrieve it from the pool again
70- reused := PreallocWriteRequestV2FromPool ()
73+ for i , s := range symbolsBackingArray [:3 ] {
74+ assert .Equalf (t , "" , s , "symbol at index %d not cleared" , i )
75+ }
7176
7277 // Source is reset to default
73- assert .Equal (t , API , reused .Source )
78+ assert .Equal (t , API , req .Source )
7479 // The symbol length is properly reset to 0.
75- assert .Len (t , reused .Symbols , 0 )
80+ assert .Len (t , req .Symbols , 0 )
7681 // Timeseries slice is nil
77- assert .Nil (t , reused .Timeseries )
78-
79- // The underlying array's string pointers are cleared to "" to prevent memory leak.
80- if cap (reused .Symbols ) > 0 {
81- underlyingArray := reused .Symbols [:cap (reused .Symbols )]
82- assert .Equal (t , "" , underlyingArray [0 ])
83- assert .Equal (t , "" , underlyingArray [1 ])
84- }
82+ assert .Nil (t , req .Timeseries )
8583}
8684
8785func BenchmarkMarshallWriteRequestV2 (b * testing.B ) {
0 commit comments