Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10228

XLSXWriter can fail on some JVMs if no fonts are available due to JVM/OS pacakging of fonts - causes errors in TestXLSXResponseWriter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • debian openjdk-9-jdk-headless b158

    Description

      I found this while trying to setup some automated testing against JDK9, but it can also affect users of java8/java7 depending on how their JDK/JRE is packaged.

      Some JVM packagers (in particular debian JVM "*-headless" packages) do not install any fonts along with the JDK/JRE, nor do these pacakges depend on any other packages providing fontconfig support for the JVM to pick up dynamically.

      This can cause problems when using
      XLSXWriter – notably in the form of errors that look like this...

         [junit4]    > Throwable #1: java.lang.InternalError: java.lang.reflect.InvocationTargetException
         [junit4]    > 	at __randomizedtesting.SeedInfo.seed([C8331E32DDBEC2E6:3E224C5FC7B09A3D]:0)
         [junit4]    > 	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
         [junit4]    > 	at java.base/java.security.AccessController.doPrivileged(Native Method)
         [junit4]    > 	at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
         [junit4]    > 	at java.desktop/java.awt.Font.getFont2D(Font.java:495)
         [junit4]    > 	at java.desktop/java.awt.Font.canDisplayUpTo(Font.java:2244)
         [junit4]    > 	at java.desktop/java.awt.font.TextLayout.singleFont(TextLayout.java:469)
         [junit4]    > 	at java.desktop/java.awt.font.TextLayout.<init>(TextLayout.java:530)
         [junit4]    > 	at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:254)
         [junit4]    > 	at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117)
         [junit4]    > 	at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:77)
         [junit4]    > 	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:653)
         [junit4]    > 	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:646)
         [junit4]    > 	at org.apache.solr.handler.extraction.XLSXWriter$SerialWriteWorkbook.<init>(XLSXResponseWriter.java:112)
         [junit4]    > 	at org.apache.solr.handler.extraction.XLSXWriter.<init>(XLSXResponseWriter.java:165)
         [junit4]    > 	at org.apache.solr.handler.extraction.XLSXResponseWriter.write(XLSXResponseWriter.java:66)
         [junit4]    > 	at org.apache.solr.handler.extraction.TestXLSXResponseWriter.getWSResultForQuery(TestXLSXResponseWriter.java:237)
         [junit4]    > 	at org.apache.solr.handler.extraction.TestXLSXResponseWriter.getWSResultForQuery(TestXLSXResponseWriter.java:232)
         [junit4]    > 	at org.apache.solr.handler.extraction.TestXLSXResponseWriter.testPseudoFields(TestXLSXResponseWriter.java:211)
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
         [junit4]    > 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         [junit4]    > 	at java.base/java.lang.reflect.Method.invoke(Method.java:547)
         [junit4]    > 	at java.base/java.lang.Thread.run(Thread.java:844)
         [junit4]    > Caused by: java.lang.reflect.InvocationTargetException
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
         [junit4]    > 	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
         [junit4]    > 	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:473)
         [junit4]    > 	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
         [junit4]    > 	... 55 more
         [junit4]    > Caused by: java.lang.NullPointerException
         [junit4]    > 	at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1288)
         [junit4]    > 	at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
         [junit4]    > 	at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
         [junit4]    > 	at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:765)
         [junit4]    > 	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:440)
         [junit4]    > 	at java.base/java.security.AccessController.doPrivileged(Native Method)
         [junit4]    > 	at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:385)
         [junit4]    > 	at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
         [junit4]    > 	at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
         [junit4]    > 	... 60 more
      

      The solution is to ensure your JVM has proper font support – most likely by ensuring the neccessarily font packages are installed (in the case of debian, installing the libfontconfig1 package should fix this problem.)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hossman Chris M. Hostetter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: