Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-583

Empty xml element in imported file cause NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 5.10.0
    • 5.8.1
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Import attached file into a Keikai page

      Current Result

      io.keikai.importer.ImportException: Fail to import stylesheet from book repro.xlsx
      	at io.keikai.importer.XlsxImporter.imports(XlsxImporter.java:273)
      	at io.keikai.range.impl.imexp.ExcelImportAdapter.imports(ExcelImportAdapter.java:48)
      	at io.keikai.api.impl.ImporterImpl.imports(ImporterImpl.java:58)
      	at io.keikai.api.impl.ImporterImpl.imports(ImporterImpl.java:90)
      	at io.keikai.api.impl.ImporterImpl.imports(ImporterImpl.java:77)
      	at io.keikai.app.repository.impl.SimpleRepository.load(SimpleRepository.java:62)
      	at io.keikaiex.app.impl.BookManagerEx.readBook(BookManagerEx.java:62)
      	at io.keikai.app.ui.dlg.OpenManageBookCtrl.loadBook(OpenManageBookCtrl.java:202)
      	at io.keikai.app.ui.dlg.OpenManageBookCtrl.onOpen(OpenManageBookCtrl.java:100)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.zkoss.zk.ui.select.Selectors$ComposerEventListener.onEvent(Selectors.java:687)
      	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3184)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3154)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3096)
      	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
      	at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:353)
      	at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:377)
      	at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractComponent.java:3629)
      	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3184)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3154)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3096)
      	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1890)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1662)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1329)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:487)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:495)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:326)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      Caused by: java.lang.NullPointerException
      	at io.keikai.importer.XlsxExtractor$XlsxPatternExtractor.getFgColor(XlsxExtractor.java:770)
      	at io.keikai.importer.XlsxImporter.importFills(XlsxImporter.java:603)
      	at io.keikai.importer.XlsxImporter.importStyleSheet(XlsxImporter.java:533)
      	at io.keikai.importer.XlsxImporter.imports(XlsxImporter.java:194)
      	... 47 more
      

      Expected Result

       Import file, no exception

      Debug Information

      This likely caused by a non-standard export (file origin currently not identified, attached sample manually modified to trigger the issue)

      Even though this is not a keikai issue, keikai should be hardened if possible to not trust that the imported xml will automatically be well-formed, and skip empty elements if any. 

       

      Caused by unexpected empty <fill> element in style.xml

      <fills count="7"><fill><patternFill /></fill>...

      expected:

      <fills count="7"><fill><patternFill patternType="none"/></fill>...

      Workaround

       Open in Excel, save file (Excel will automatically save in a valid format)

            jumperchen jumperchen
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: