You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/06/01 12:07:25 UTC

[GitHub] [servicecomb-java-chassis] SenixCoder opened a new issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

SenixCoder opened a new issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400


   异常堆栈如下
   ```
   java.lang.NullPointerException: 
   	at org.apache.servicecomb.foundation.vertx.http.DownloadUtils.prepareDownloadHeader(DownloadUtils.java:45) 
   	at org.apache.servicecomb.foundation.vertx.http.StandardHttpServletResponseEx.sendPart(StandardHttpServletResponseEx.java:107) 
   	at org.apache.servicecomb.common.rest.filter.inner.ServerRestArgsFilter.beforeSendResponseAsync(ServerRestArgsFilter.java:78) 
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.safeInvoke(HttpServerFilterBeforeSendResponseExecutor.java:52) 
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.doRun(HttpServerFilterBeforeSendResponseExecutor.java:82) 
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.run(HttpServerFilterBeforeSendResponseExecutor.java:44) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.executeHttpServerFilters(AbstractRestInvocation.java:283) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.sendResponse(AbstractRestInvocation.java:277) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.sendResponseQuietly(AbstractRestInvocation.java:262) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.lambda$doInvoke$2(AbstractRestInvocation.java:245) 
   	at com.huawei.mateinfo.sdk.service.handler.ProviderMetricsHandler.lambda$onResponse$0(ProviderMetricsHandler.java:52) 
   	at org.apache.servicecomb.tracing.zipkin.ZipkinTracingHandler.lambda$onResponse$0(ZipkinTracingHandler.java:74) 
   	at org.apache.servicecomb.core.handler.impl.ProducerOperationHandler.syncInvoke(ProducerOperationHandler.java:108) 
   	at org.apache.servicecomb.core.handler.impl.ProducerOperationHandler.invoke(ProducerOperationHandler.java:60) 
   	at org.apache.servicecomb.core.handler.impl.ProducerOperationHandler.handle(ProducerOperationHandler.java:51) 
   	at org.apache.servicecomb.core.Invocation.next(Invocation.java:307) 
   	at org.apache.servicecomb.tracing.zipkin.ZipkinTracingHandler.handle(ZipkinTracingHandler.java:52) 
   	at org.apache.servicecomb.tracing.zipkin.ZipkinProviderTracingHandler.handle(ZipkinProviderTracingHandler.java:24) 
   	at org.apache.servicecomb.core.Invocation.next(Invocation.java:307) 
   	at com.huawei.mateinfo.sdk.service.handler.ProviderMetricsHandler.handle(ProviderMetricsHandler.java:41) 
   	at org.apache.servicecomb.core.Invocation.next(Invocation.java:307) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.doInvoke(AbstractRestInvocation.java:245) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.invoke(AbstractRestInvocation.java:219) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.runOnExecutor(AbstractRestInvocation.java:203) 
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.lambda$scheduleInvocation$0(AbstractRestInvocation.java:162) 
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_292]
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_292]
   	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]
   ```
   
   报错代码为
   ```
       if (responseEx.getHeader(HttpHeaders.CONTENT_TYPE.toString()) == null) {
         responseEx.setHeader(HttpHeaders.CONTENT_TYPE.toString(), part.getContentType());
       }
   
   ```
   此处没有对part进行判空;或者应当变为其他处理
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] SenixCoder commented on issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
SenixCoder commented on issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400#issuecomment-854311552


   ``` 
      public Part exportItemsByProjectAndModule(String projectName, String moduleName, ExportConfig exportConfig) {
           List<DataPackBo> dpList = dataPackService.getByProjectNameAndModuleName(projectName, moduleName);
           if (CollectionUtils.isEmpty(dpList)) {
               return null;
           }
   
           File zipFile = dataPackService.export(dpList, projectName);
           return new FilePart(null, zipFile).setDeleteAfterFinished(true).setSubmittedFileName(zipFile.getName());
       }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400#issuecomment-913492899


   fixed in https://github.com/apache/servicecomb-java-chassis/pull/2527 , try 2.5.1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 closed issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
liubao68 closed issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] SenixCoder commented on issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
SenixCoder commented on issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400#issuecomment-854311552


   ``` 
      public Part exportItemsByProjectAndModule(String projectName, String moduleName, ExportConfig exportConfig) {
           List<DataPackBo> dpList = dataPackService.getByProjectNameAndModuleName(projectName, moduleName);
           if (CollectionUtils.isEmpty(dpList)) {
               return null;
           }
   
           File zipFile = dataPackService.export(dpList, projectName);
           return new FilePart(null, zipFile).setDeleteAfterFinished(true).setSubmittedFileName(zipFile.getName());
       }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400#issuecomment-854278245


   你能提供一个使用例子,演示出现part为空的场景吗?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2400: 服务提供方提供文件下载功能,当Part返回null时,会抛出空指针异常

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2400:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2400#issuecomment-854278245


   你能提供一个使用例子,演示出现part为空的场景吗?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org