Skip to content

Fix for DebugAssertException detection during testing + VIntUtils length assertions - #1400

Merged
NightOwl888 merged 2 commits into
apache:masterfrom
NightOwl888:fix/vintutils-debugassert
Jul 4, 2026
Merged

NightOwl888 merged 2 commits into
apache:masterfrom
NightOwl888:fix/vintutils-debugassert

Conversation

@NightOwl888

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Fix for DebugAssertException detection during testing + VIntUtils length assertions

Description

While reviewing #1373, I discovered that the length checking was incorrectly requiring the length to be at least the max length allowed. I fixed it on the #1373 branch and then decided it was better off as its own PR, but when I cherry picked onto master, I discovered that #1360 already had a fix, but #1373 hadn't been rebased against master. Still, this provides more robust checking to ensure that the length is at least as long as it should be to hold the value. This is entirely implemented in Debug builds and is entirely removed from the compile in Release builds.

This also revealed that the DebugAssertException had changed in Microsoft.NET.Test.Sdk 16.6.0 when testing, which replaces the CLR DebugAssertException type. As such, our exception handling was not treating Debug.Assert() exceptions correctly according to how Java does. This updates the LuceneTestFrameworkInitializer to correctly set that exception type so Debug.Assert() exceptions are caught when Lucene swallows them and ignored when Lucene ignores them.

This also adds a TestDebugAssertExceptionTypeString() test to detect if the Microsoft.NET.Test.Sdk can no longer be found at its current location to help catch any changes to it in the future. However, do note that this test only works in Debug builds.

…tion type from the Microsoft.NET.Test.Sdk that has been added there since 16.6.0 so catch blocks don't swallow it.
… VInt lengths, not requiring maximum lengths, which are in fact allowed for sources that don't change position on read.
@NightOwl888
NightOwl888 merged commit 736554e into apache:master Jul 4, 2026
211 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:bug-fix Contains a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants