Handle malformed URI exceptions without breaking JMeter thread#51
Merged
Conversation
Prevent the exception like URI is not absolute due to the resolution of a malformed URI to be reported all the way up to Jmeter causing thread to be stopped. Platforms like Blazemeter often stop test execution due to errors like this.
Wrap exception as sample result error instead of breaking JMeter thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the robustness of the video streaming HTTP client and sampler by ensuring that invalid or unresolved URIs are handled gracefully. Instead of throwing uncaught exceptions that could disrupt test execution and clutter logs, the code now records failed sample results for invalid URIs, making error handling more consistent and measurable. The changes also introduce new unit tests to verify this behavior.
Error handling improvements:
VideoStreamingHttpClientnow checks if a URI is null or not absolute indownloadUri. If so, it returns a failedHTTPSampleResultusing the newbuildInvalidUriResultmethod, instead of throwing an uncaughtIllegalArgumentException. This ensures that URI errors are reported as failed samples, not as raw stack traces. [1] [2]VideoStreamingSamplernow catchesIllegalArgumentExceptionwhen the master URL is not a valid URI reference, logs a warning, and records a failed sample result, instead of aborting with an exception.Testing and validation:
VideoStreamingHttpClientTestwith tests to verify that invalid, relative, or null URIs result in failed sample results, not exceptions.HlsSamplerTestto ensure that an unresolved dynamic master URL variable (with illegal URI characters) is recorded as a failed master sample, not as an exception.