ratacolita opened a new pull request, #6448:
URL: https://github.com/apache/jmeter/pull/6448

   ## Description
   Fixes a bug in `JSONPostProcessor` where default values containing trailing 
empty strings (e.g., `"val1;;val3;"` intended as `["val1", "", "val3", ""]`) 
were not parsed correctly due to the behavior of `String.split(separator)`.
   
   The fix utilizes the `String.split(separator, -1)` overload, which preserves 
trailing empty strings, ensuring that default values are split into the 
expected array elements.
   
   
![image](https://github.com/user-attachments/assets/81a99bd1-30c0-41bb-971f-b78bbe5e0cd3)
   
   ## Motivation and Context
   The `String.split(String regex)` method used to parse the `defaultValues` 
string discards trailing empty strings resulting from the split. This means 
that if a user configures default values ending with the separator (e.g., 
`a;b;;` with ';' as separator) to indicate empty defaults at the end, these 
empty values are lost during parsing. This leads to an incorrect number of 
default values being available compared to the number of reference names or 
JSON path expressions, potentially causing `IndexOutOfBoundsException` or 
incorrect variable assignments later in the `process` method.
   
   This change corrects the parsing logic to accurately reflect the user's 
intended default values, including trailing empty ones.
   
   ## How Has This Been Tested?
   *Manual testing is recommended with various `defaultValues` inputs, focusing 
on cases with trailing separators:*
     * `"a;b;c"` (no trailing)
     * `"a;b;"` (one trailing empty)
     * `";;c"` (leading empty)
     * `";;"` (only empty)
     * `""` (single empty string)
     * `"a"` (single non-empty string)
   
   *Verify that the resulting `defaultValues` array has the expected size and 
content in each case.*
   *Confirm that the processor correctly assigns default values when JSON path 
expressions yield no results, especially matching the behavior with the newly 
parsed trailing empty defaults.*
   
   ## Screenshots (if appropriate):
   
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   - ~~New feature (non-breaking change which adds functionality)~~
   - ~~Breaking change (fix or feature that would cause existing functionality 
to not work as expected)~~
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to