Bug 51787

Summary: First row is duplicated in the XWPFTable constructor
Product: POI Reporter: Cedomir Igaly <cedomir.igaly>
Component: XWPFAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: major    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Cedomir Igaly 2011-09-08 13:40:25 UTC
In the case when row (or rows) is already present in tableRows, the folowing code in the constructor will anyway add it for the second time:

XWPFTableRow tabRow = (getRow(i) == null) ? createRow() : getRow(i);
tableRows.add(tabRow);

I've fixed that problem by replacing the code above with:

XWPFTableRow tabRow = getRow(i);
if (tabRow == null) {
	tabRow = createRow();
	tableRows.add(tabRow);
}

and it is working for me. However, I can not guarantee that I did not misssed something important.
Comment 1 Nick Burch 2011-09-09 15:13:31 UTC
Any chance you could write a short junit unit test to go with this? We can then use it to verify the fix, and ensure it doesn't get broken again in future
Comment 2 Dominik Stadler 2016-06-12 17:17:44 UTC
I could not find this in the code any more, it seems to have been fixed at some point, however I do not even find the code this way if I look at historical versions of XWPFTable, so not sure which version the suggested patch did target here...