Bug 65291 - XWPFRun method getStyle() throws an ArrayOutOfBoundsException
Summary: XWPFRun method getStyle() throws an ArrayOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 5.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-06 18:24 UTC by Mark Glass
Modified: 2021-05-20 10:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Glass 2021-05-06 18:24:25 UTC
The problem is in the 'public String getStyle()' method. The line 'CTString style = pr.getRStyleArray(0)' produces the exception. It would be better to test with 
if (pr.getRStyleArray().length == 0) {
   return "";
}

CTString style = pr.getRStyleArray(0);
if (style == null ) {
   return "";
} else {
   return style;
}

I'm assuming that pr.getRStyleArray(0) can return null.
Comment 1 Sayi 2021-05-07 02:03:18 UTC
Thanks Mark Glass, this has fixed via r1889259 a few days ago, should be included in the upcoming Apache POI 5.0.1.