DM-578 - Fix NPE in excel reports

This commit is contained in:
Andrei Isvoran 2023-11-17 10:31:04 +02:00
parent 1b6afaa184
commit e7cc1809c8

View File

@ -42,6 +42,12 @@ public class ScmReportService {
var firstRow = sheet.getRow(0);
int firstRowIndex = 1;
while (firstRow == null) {
firstRow = sheet.getRow(firstRowIndex);
firstRowIndex++;
}
int fileColumnIndex = 0;
int textColumnIndex = firstRow.getLastCellNum() - 1;
int valueIndexColumn = firstRow.getLastCellNum() - 2;
@ -55,6 +61,8 @@ public class ScmReportService {
Map<String, Integer> componentIndexMap = new HashMap<>();
Row finalFirstRow = firstRow;
componentLog.getComponentLogEntries().forEach(componentLogEntry -> {
if (componentLogEntry.getComponentValues().isEmpty()) {
@ -71,7 +79,7 @@ public class ScmReportService {
CellUtil.setVerticalAlignment(fileNameCell, VerticalAlignment.TOP);
// Component, file attributes and index cell
addOtherCells(sheet, excelModel, rowIndex, componentIndexMap, componentLogEntry, row, fileModel, firstRow, componentColumnIndex, textColumnIndex, valueIndexColumn);
addOtherCells(sheet, excelModel, rowIndex, componentIndexMap, componentLogEntry, row, fileModel, finalFirstRow, componentColumnIndex, textColumnIndex, valueIndexColumn);
});