ExcelFileWriter的空指针问题
Closed this issue · 1 comments
AGEIPort版本:0.0.9
问题:执行非MultiSheetExportProcessorTest以外的测试用例都会失败,原因NPE
错误堆栈:
17:35:41.685 [AGEI-MainWorker-t-2] DEBUG com.alibaba.excel.context.WriteContextImpl - Initialization 'WriteContextImpl' complete 2023-01-11 17:35:41.687 [AGEI-MainWorker-t-2] ERROR c.a.a.p.c.t.exporter.worker.ExportMainTaskWorker - StandaloneExportMainTaskWorker#doReduce failed, main:20230111173540-65bdcde1 java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "meta" is null at com.alibaba.ageiport.processor.core.file.excel.ExcelFileWriter.write(ExcelFileWriter.java:85) at com.alibaba.ageiport.processor.core.task.exporter.worker.ExportMainTaskWorker.doReduce(ExportMainTaskWorker.java:194) at com.alibaba.ageiport.processor.core.spi.task.factory.MainTaskWorker.run(MainTaskWorker.java:34) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at com.alibaba.ageiport.common.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:95) at com.alibaba.ageiport.common.concurrent.InterruptibleTask.run(InterruptibleTask.java:50) at com.alibaba.ageiport.common.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) 2023-01-11 17:35:41.688 [AGEI-MainWorker-t-2] INFO c.a.a.test.processor.core.TestMainTaskCallback - ---beforeError:20230111173540-65bdcde1 2023-01-11 17:35:41.690 [AGEI-MainWorker-t-2] INFO c.a.a.p.core.spi.task.monitor.TaskStageEvent - main:20230111173540-65bdcde1, stage:执行失败, cost:-ms 2023-01-11 17:35:41.690 [AGEI-MainWorker-t-2] INFO c.a.a.test.processor.core.TestMainTaskCallback - ---afterError:20230111173540-65bdcde1 2023-01-11 17:35:41.690 [AGEI-eb-local-t-2] INFO c.a.a.p.core.task.monitor.TaskProgressServiceImpl - update progress, main:20230111173540-65bdcde1, stage:执行失败 17:35:41.910 [AGEI-MainWorker-t-2] DEBUG com.alibaba.excel.context.WriteContextImpl - Finished write. 17:35:41.937 [main] INFO com.alibaba.ageiport.test.processor.core.TestHelper - getTaskProgress, percent:1.0, stageName:主任务执行失败
空指针原因:ExcelFileWriter执行write函数时未对meta进行判空或者初始化。只有需要多sheet页导出时,在实现ExportProcessor的group方法时才会设置meta数据,其余场景未设置meta的ExportProcessor在执行时都会由此问题。
修改建议:判空然后初始化meta
已修复此问题,版本:0.1.2