Skip to content

Commit

Permalink
assert: add comment that explains the MaxScanTokenSize handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunmahishi committed Mar 3, 2024
1 parent 7f5f3e3 commit f37ae55
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ func indentMessageLines(message string, longestLabelLen int) string {
outBuf := new(bytes.Buffer)

msgScanner := bufio.NewScanner(strings.NewReader(message))

// a buffer is set manually to store the tokenization of the message string
// so that we can re-use the same buffer for each line of the message without
// any additional allocations. We set the buffer length to 1 more than the
// length of the message to avoid exceeding the default MaxScanTokenSize
// while scanning lines. This CAN happen. Refer to issue #1525
msgScanner.Buffer([]byte{}, len(message)+1)

first := true
Expand Down

0 comments on commit f37ae55

Please sign in to comment.