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