Fix: store rowCount per-file to prevent cross-file index corruption#32
Open
amitgour1996 wants to merge 1 commit intorollno748:masterfrom
Open
Fix: store rowCount per-file to prevent cross-file index corruption#32amitgour1996 wants to merge 1 commit intorollno748:masterfrom
amitgour1996 wants to merge 1 commit intorollno748:masterfrom
Conversation
The static field 'rowCount' in FileServerExtended was shared across all CSV files. When a Thread Group contained multiple ExtendedCsvDataSetConfig elements with different row counts, whichever called calculateRowCount() last would overwrite the global value. readRandom() and readUnique() then used this incorrect global value, generating line indices beyond the actual file size, causing NoSuchElementException from Optional.get() in readIndexed(). Fix: store rowCount per-FileEntry and add getRowCount(alias) to look up the correct count. The global static is retained for backward compatibility but deprecated.
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.
Fixes #31
Problem
rowCountis aprivate static int— one global value shared across all CSV files. When a Thread Group has multiple CSVs with different row counts,calculateRowCount()overwrites it each time.readRandom()andreadUnique()then use the wrong count, generating indices past EOF, which blows up inreadIndexed()withNoSuchElementException.Changes
All in
FileServerExtended.java:int rowCountfield to theFileEntryinner class so each file tracks its own countcalculateRowCount()now stores the count infileEntry.rowCount(still updates the global for backward compat)getRowCount(String alias)— looks up the per-file count fromFileEntry, falls back to globalreadRandom()andreadUnique()now callgetRowCount(alias)instead of using the static directlyTested
Before fix: ~49% of iterations crash with
NoSuchElementExceptionwhen two CSVs have different row counts.After fix: 0 crashes across multiple runs with 98 threads, all ExtendedCsvDataSetConfig elements enabled.