FSchumacher commented on code in PR #6694:
URL: https://github.com/apache/jmeter/pull/6694#discussion_r3111692371


##########
src/functions/src/main/java/org/apache/jmeter/functions/FileRowColContainer.java:
##########
@@ -119,13 +120,18 @@ public String getColumn(int row, int col) throws 
IndexOutOfBoundsException {
      *
      */
     public int nextRow() {
-        int row = nextRow;
-        nextRow++;
-        if (nextRow >= fileData.size()) {// 0-based
-            nextRow = 0;
+        int size = fileData.size();
+        if (size <= 0) {
+            throw new IllegalStateException("CSV file has no data rows");
+        }
+        while (true) {
+            int current = nextRow.get();
+            int next = (current + 1) % size;

Review Comment:
   floorMod should work well within the range of long. But when our long wraps 
around, the calculation will be wrong. 
   
   It might be clearer, when we use a short instead of a long.
   There we have `(x % 255) % FILE_SIZE` as our current value. Further assume 
that FILE_SIZE is 200.
   Then for x == 254 we get 54 and for x == 255 we get 0 (wrap around of short).
   
   The same will happen (really unlikely, as a long can get quite big) with an 
int or a long. (That might will happen with a long after 286.967.718 years, 
when we read about 1000 rows a second (for that complete period) :) ) (and that 
will be one wrong range, that we skip, in the above short example 55..255)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to