异常代码
java
@OverRide
public void downLoadsubPackageDaily(ActivityReportSubPackageDailyDto activityReportSubPackageDailyDto, HttpServletResponse response, String userPin, String accountId) throws IOException, ParseException, IllegalAccessException {
List activityReportDailySubPackageVos = fetchActivityReportDailySubPackageData(activityReportSubPackageDailyDto, userPin, accountId);
List activityReportDailyVos = fetchActivityReportDailyData(activityReportSubPackageDailyDto, userPin, accountId);
// 设置表格文件名
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("活动明细-" + DateUtil.format(new Date(), "yyyy-MM-dd") + ".xlsx", "UTF-8"));
OutputStream out = response.getOutputStream();
// 导出到excel
ExcelWriter excelWriter = null;
try {
excelWriter = EasyExcel.write(out).build();
WriteSheet writeSheet0 = EasyExcel.writerSheet(0, "按天明细数据" + DateUtil.format(new Date(), "yyyy-MM-dd")).head(ActivityReportDailyVo.class).build();
WriteSheet writeSheet1 = EasyExcel.writerSheet(1, "按人群包明细数据" + DateUtil.format(new Date(), "yyyy-MM-dd")).head(ActivityReportDailySubPackageVo.class).build();
excelWriter.write(activityReportDailyVos, writeSheet0);
excelWriter.write(activityReportDailySubPackageVos, writeSheet1);
} finally {
if (excelWriter != null) {
excelWriter.finish();
}
}
}
其中131行是这句代码excelWriter.finish();
异常提示
2023-10-07 15:39:12.867 WARN [nio-1601-exec-7] [c4900ca26eb0497e9975bf15227b7448] c.j.d.u.a.AspectRound [ ] : com.alibaba.excel.exception.ExcelGenerateException: Can not close IO.
at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:378)
at com.alibaba.excel.write.ExcelBuilderImpl.finish(ExcelBuilderImpl.java:95)
at com.alibaba.excel.ExcelWriter.finish(ExcelWriter.java:329)
at com.jd.eem.right.service.right.report.impl.ActivityReportServiceImpl.downLoadsubPackageDaily(ActivityReportServiceImpl.java:131)
at com.jd.eem.right.service.right.report.impl.ActivityReportServiceImpl$$FastClassBySpringCGLIB$$a95ace39.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:100)
at com.jd.dassist.ump.aop.AspectRound.around(AspectRound.java:69)
at sun.reflect.GeneratedMethodAccessor125.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
问题描述
以下两个方法fetchActivityReportDailySubPackageData();fetchActivityReportDailyData();可以正常获取数据,通过日志可以看到,其中这个activityReportDailySubPackageVos有7W+条的数据,本地运行没有这么大的数据量,可以正常运行。线上具体的报错如上,目前的easyexcel版本为2.2.6,我搜索的都是说切换版本可以解决问题?
3条答案
按热度按时间ssm49v7z1#
ioekq8ef2#
有大佬解决吗,我也遇到这个坑了,几天了没办法
bihw5rsg3#
前端请求超时了,再写入数据就会有问题,提高下获取数据的速度或者异步做导出功能
Caused by: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356)
at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:825)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:310)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:263)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:157)
at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:356)
... 127 more
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:65)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:469)
at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134)
at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)
at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157)
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1279)
at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:670)
at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:450)
at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:388)
at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:623)
at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:121)
at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:225)
at org.apache.coyote.Response.doWrite(Response.java:541)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:351)