We are running a Quarkus application with Docker, and the base image is an UBI8 (`FROM docker-redhat.sopdock/ubi8/openjdk-21-runtime:1.18`). We are currently using `org.apache.poi:poi-ooxml:5.2.3` with `SXSSFSheet`s. We are *not* using `sheet.trackAllColumnsForAutoSizing()` because that requires Fonts to be installed, which we don't have inside our Docker image. However, after updating to 5.2.5, we get the error `Fontconfig head is null, check your fonts or fonts configuration` regardless. I believe this might have been caused by [this change](https://github.com/apache/poi/commit/43551babf1cf628aa184a2f9445412815781dc9e) in 5.2.4: ```diff diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java index 44caba42178..d454fc10829 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java @@ -63,8 +63,8 @@ protected SXSSFSheet(SXSSFWorkbook workbook, XSSFSheet xSheet, int randomAccessW setRandomAccessWindowSize(randomAccessWindowSize); try { _autoSizeColumnTracker = new AutoSizeColumnTracker(this); - } catch (Throwable t) { - LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", t); + } catch (UnsatisfiedLinkError | InternalError e) { + LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", e); } } @@ -96,8 +96,8 @@ public SXSSFSheet(SXSSFWorkbook workbook, XSSFSheet xSheet) throws IOException { setRandomAccessWindowSize(_workbook.getRandomAccessWindowSize()); try { _autoSizeColumnTracker = new AutoSizeColumnTracker(this); - } catch (Throwable t) { - LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", t); + } catch (UnsatisfiedLinkError | InternalError e) { + LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", e); } } diff --git a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java index d55e3634d52..130169999c4 100644 --- a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java +++ b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java @@ -300,12 +300,12 @@ public static int getDefaultCharWidth(final Workbook wb) { try { TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext); return (int) layout.getAdvance(); - } catch (Throwable t) { + } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError e) { if (ignoreMissingFontSystem) { return DEFAULT_CHAR_WIDTH; } - throw t; + throw e; } } ``` Where previously all Throwables were caught, and now only `UnsatisfiedLinkError | NoClassDefFoundError | InternalError` do. The "Fontconfig head is null"-error is a RuntimeException: `throw new RuntimeException(fontconfigErrorMessage);`
the code has changed in trunk see https://github.com/apache/poi/commits/08436ddf7fd8039118ff073b8dac02b4b5e67774/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java I keep trying to loosen the check so that it works for everyone but then my changes keep being adjusted - so that I don't know if the latest code just reverts back to the broken behaviour. You can get snapshot jars to test with - from https://ci-builds.apache.org/job/POI/job/POI-DSL-1.8/lastSuccessfulBuild/artifact/
As this is a RuntimeException, I think this case is unrelated to the recent changes around "isFatal", but was broken when we switched from catching Throwable via r1907443 and none of the changes afterwards affected handling of RuntimeException any more.
https://github.com/apache/poi/commit/209e8fc6599803c7cfe061f7755d6e19d9c14201 effectively undoes my change. With 209e8fc6599803c7cfe061f7755d6e19d9c14201, RuntimeExceptions will again be thrown instead of the default char width being returned.
Please take another close look, https://github.com/apache/poi/commit/209e8fc6599803c7cfe061f7755d6e19d9c14201 just includes a few more types of exception without "reverting" the previous changes. The "and" condition was switched, but this does not change the result of the condition. I did some more tests locally and I think the latest version on master is actually working as expected now. It handles RuntimeException as well via the "!isFatal" check. Felix, can you test with a recent nightly build and report if this makes it work again for you.
I reread the if and it looks like it should be ok. So POI 5.2.6 should get us back to the POI 5.2.3 behaviour,
Nice! See r1916297 for a some new unit tests which try to verify the different cases via mocking of exceptions in the low-level font-system so we get coverage of this tricky bit of code. So as far as we see it will be fixed in the next release, please reopen if your local tests still show a problem.
I can confirm that with 5.2.6-SNAPSHOT it works again, just as it did with 5.2.3, thanks!