adamsaghy commented on code in PR #4554:
URL: https://github.com/apache/fineract/pull/4554#discussion_r2063615475


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java:
##########
@@ -53,7 +53,15 @@ public static Integer getNumberOfRows(Sheet sheet, int 
primaryColumn) {
         Integer noOfEntries = 0;
         // getLastRowNum and getPhysicalNumberOfRows showing false values
         // sometimes
-        while (sheet.getRow(noOfEntries + 1) != null && 
sheet.getRow(noOfEntries + 1).getCell(primaryColumn) != null) {
+        while (true) {
+            Row row = sheet.getRow(noOfEntries + 1);
+            if (row == null) {
+                break;
+            }
+            Cell cell = row.getCell(primaryColumn);
+            if (cell == null || cell.getCellType() == CellType.BLANK) {
+                break;
+            }

Review Comment:
   something like this:
   ```
   int maxRows = sheet.getLastRowNum(); // Or set a hard limit, e.g., 10_000
   
   while (noOfEntries < maxRows) {
       Row row = sheet.getRow(noOfEntries + 1);
       if (row == null) {
           break;
       }
       Cell cell = row.getCell(primaryColumn);
       if (cell == null || cell.getCellType() == CellType.BLANK) {
           break;
       }
       noOfEntries++;
   }
   ```
   
   This a little bit better as it never an endless loop



##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java:
##########
@@ -53,7 +53,15 @@ public static Integer getNumberOfRows(Sheet sheet, int 
primaryColumn) {
         Integer noOfEntries = 0;
         // getLastRowNum and getPhysicalNumberOfRows showing false values
         // sometimes
-        while (sheet.getRow(noOfEntries + 1) != null && 
sheet.getRow(noOfEntries + 1).getCell(primaryColumn) != null) {
+        while (true) {
+            Row row = sheet.getRow(noOfEntries + 1);
+            if (row == null) {
+                break;
+            }
+            Cell cell = row.getCell(primaryColumn);
+            if (cell == null || cell.getCellType() == CellType.BLANK) {
+                break;
+            }

Review Comment:
   something like this:
   ```
   int maxRows = sheet.getLastRowNum();
   
   while (noOfEntries < maxRows) {
       Row row = sheet.getRow(noOfEntries + 1);
       if (row == null) {
           break;
       }
       Cell cell = row.getCell(primaryColumn);
       if (cell == null || cell.getCellType() == CellType.BLANK) {
           break;
       }
       noOfEntries++;
   }
   ```
   
   This a little bit better as it never an endless loop



-- 
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