https://bz.apache.org/bugzilla/show_bug.cgi?id=62130

            Bug ID: 62130
           Summary: XSSFRow can loose sync between CTRow and XSSFCell
                    references to CTCell instances
           Product: POI
           Version: 3.17-FINAL
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

The fix for bug #56170 fixed some use cases of this, but is overly aggressive
in looking for cases to do nothing.  Turns out there are too many ways the
CTRow object's collection of CTCell objects can become stale compared to the
XSSFCell collection held by XSSFRow.  Since the XSSF* values are the canonical
ones, we should, on document write, always update the CTRow object to match the
XSSFCell values.

This test case shows the problem, failing with 3.17 and 4.0 current trunk,
because the saved value came from a stale CTRow:

@Test
public void testMultipleEditWriteCycles() {
        final XSSFWorkbook wb1 = new XSSFWorkbook();
        final XSSFSheet sheet1 = wb1.createSheet("Sheet1");
        final XSSFRow srcRow = sheet1.createRow(0);
        srcRow.createCell(0).setCellValue("hello");
        srcRow.createCell(3).setCellValue("world");

        // discard result
        XSSFTestDataSamples.writeOutAndReadBack(wb1);
        srcRow.createCell(1).setCellValue("cruel");
        // discard result
        XSSFTestDataSamples.writeOutAndReadBack(wb1);

        srcRow.getCell(1).setCellValue((RichTextString) null);

        XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
        assertEquals("Cell not blank"
                    , CellType.BLANK
                    ,
wb3.getSheet("Sheet1").getRow(0).getCell(1).getCellType());
}

The solution is to remove the extra logic from XSSFRow.onDocumentWrite() and
always perform the update to CTRow at that point.  Otherwise, multiple
edit/write cycles to the workbook will result in saved copies that don't match
the logical structure of the original.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to