Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: Fix panic caused by retryAssert() #996

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

Gleiphir2769
Copy link
Contributor

Motivation

retryAssert() will cause panic when assert failed.

For example.

func TestRetryAssert(t *testing.T) {
	retryAssert(t, 5, 200, func() {}, func(t assert.TestingT) bool {
		return assert.Equal(t, 1, 12)
	})
}

Result.

=== RUN   TestRetryAssert
--- FAIL: TestRetryAssert (0.20s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x1047ffe40]

This is because when assert failed, t.Errorf() will be invoked. However, retryAssert passed a nil value.

Modifications

  • Fix retryAssert() to avoid panic()

Verifying this change

  • Make sure that the change passes the CI checks.

@shibd shibd merged commit 6c3ee77 into apache:master Mar 22, 2023
@RobertIndie RobertIndie added this to the v0.10.0 milestone Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants