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
    • 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)

      Similar case

      A different failed case for the same root cause.

      io.keikai.importer.ImportException: Fail to import sheet view in sheet Ratios from book financial_highlights_source_2205.xlsx
      at io.keikai.importer.XlsxImporter.imports(XlsxImporter.java:273)
      at io.keikai.range.impl.imexp.ExcelImportAdapter.imports(ExcelImportAdapter.java:48)
      at io.keikai.range.impl.imexp.AbstractImporter.imports(AbstractImporter.java:57)
      at io.keikai.ui.Spreadsheet.getSBook(Spreadsheet.java:720)
      at io.keikai.ui.Spreadsheet.getSelectedSSheet(Spreadsheet.java:900)
      at io.keikai.ui.Spreadsheet.doInvalidate(Spreadsheet.java:2709)
      at io.keikai.ui.Spreadsheet.invalidate(Spreadsheet.java:2566)
      at io.keikai.ui.Spreadsheet.setSrc(Spreadsheet.java:949)
      at sun.reflect.GeneratedMethodAccessor2171.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.zkoss.lang.reflect.Fields.set(Fields.java:153)
      at org.zkoss.lang.reflect.Fields.setByCompound(Fields.java:79)
      at io.keikai.jsp.ui.SpreadsheetTag.evaluateDynaAttribute(SpreadsheetTag.java:173)
      at io.keikai.jsp.ui.SpreadsheetTag.evaluateDynaAttributes(SpreadsheetTag.java:158)
      at io.keikai.jsp.ui.SpreadsheetTag.initComponent(SpreadsheetTag.java:120)
      at io.keikai.jsp.ui.SpreadsheetTag$1.service(SpreadsheetTag.java:77)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:522)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:373)
      at org.zkoss.zkplus.embed.Renders.render(Renders.java:130)
      at org.zkoss.zkplus.embed.Renders.render(Renders.java:88)
      at io.keikai.jsp.ui.SpreadsheetTag.doTag(SpreadsheetTag.java:74)
      at jsp_servlet.los._customer._financials.excel_display._jspService(_excel_display.java:138)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:295)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:353)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
      at com.integrosys.sml.ui.common.xss.XSSFilter.doFilter(XSSFilter.java:83)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3797)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3763)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344)
      at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
      at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2451)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2299)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2277)
      at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1720)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1680)
      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
      at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
      at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
      at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
      at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
      at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:655)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)
      Caused By: java.lang.NullPointerException
      at io.keikai.importer.XlsxExtractor$XlsxSheetPropertiesExtractor.getTabColor(XlsxExtractor.java:2363)
      at io.keikai.importer.XlsxImporter.importSheet(XlsxImporter.java:3021)
      at io.keikai.importer.XlsxImporter.lambda$importSheets$8(XlsxImporter.java:2957)
      at java.util.ArrayList.forEach(ArrayList.java:1259)
      at io.keikai.importer.XlsxImporter.importSheets(XlsxImporter.java:2956)
      at io.keikai.importer.XlsxImporter.imports(XlsxImporter.java:212)
      at io.keikai.range.impl.imexp.ExcelImportAdapter.imports(ExcelImportAdapter.java:48)
      at io.keikai.range.impl.imexp.AbstractImporter.imports(AbstractImporter.java:57)
      at io.keikai.ui.Spreadsheet.getSBook(Spreadsheet.java:720)

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

              Created:
              Updated:
              Resolved: