Bug 62908 - CellFormatPart getColor warnings are logged and the method does not return a color
Summary: CellFormatPart getColor warnings are logged and the method does not return a ...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 4.0.0-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-13 12:30 UTC by christophk
Modified: 2018-12-21 07:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description christophk 2018-11-13 12:30:48 UTC
When using apache tika which uses apache POI 4.0.0, I stumbled over the follow logged warnings:

Nov 13, 2018 1:22:16 PM org.apache.poi.ss.format.CellFormatPart getColor
WARNUNG: Unknown color: "Green"
Nov 13, 2018 1:22:21 PM org.apache.poi.ss.format.CellFormatPart getColor
WARNUNG: Unknown color: "Red"
Nov 13, 2018 1:22:21 PM org.apache.poi.ss.format.CellFormatPart getColor
WARNUNG: Unknown color: "Yellow"
Nov 13, 2018 1:22:21 PM org.apache.poi.ss.format.CellFormatPart getColor
WARNUNG: Unknown color: "Blue"

Digging deeper, I found that the issue is caused by the fact that the static CellFormatPart.NAMED_COLORS-map is empty. It looks like its initialization code does not work (any more).

See this line in the class:
https://github.com/apache/poi/blob/3885cb0839541211981dc65bc2891d9bac4aa6bb/src/java/org/apache/poi/ss/format/CellFormatPart.java#L66

The name that is returned here is always HSSFColor. (There is no class extending this class other than CustomColor). As the following condition checks whether this name is in ALLCAPS, its body is never executed.

I guess this code used to work on something like enums that has been changed in the mean time.
Comment 1 Nick Burch 2018-11-13 14:48:42 UTC
Hopefully one of our enum change experts can be along soon to help!

In the mean time, do you have a short code snippet that triggers the problem, which we can turn into a junit unit test? That'll help us check it's fixed, and prevent future accidental breakages too!
Comment 2 PJ Fanning 2018-11-13 16:10:45 UTC
https://svn.apache.org/viewvc?view=revision&revision=1846520 might help. The main colours (that appear in the warning message) are now added to the map.

The relevant CellFormatPart code hasn't changed in years. Possibly, the IndexedHash map returned a different set of HSSFColors instances in the past.
Comment 3 christophk 2018-11-16 07:50:08 UTC
Thank you very much for the quick fix!

Unfortunately, I do not have a short code snippet to demonstrate the problem (apart from the one that PJ Fanning has already used in his unit test), as all functions that exhibit the problem are private. I only found the problem when I used POI to parse an excel file that uses conditional formatting, and the only way the problem shows itself is the logged warning.
Comment 4 Dominik Stadler 2018-12-21 07:50:00 UTC
Seems to be fixed and no more information is likely to be provided, a simple unit test is available to verify, thus resolving this now.