当通过FormData上传文件时,为什么我会从jetty.util.BlockingCallback.block中随机获取NPE?

时间:2016-03-02 16:30:48

标签: java jersey jetty

首先,我的设置有点独特。我在AWS Elastic Beanstalk上使用Docker,它在客户端和服务器之间添加了NGINX代理。即使这样,问题也不是一直可重复的,我在本地看到它只是在Eclipse中运行。

这是一个想法:

我的Jersey端点设置如下:

@POST
@Consumes("multipart/form-data")
@Path("file")
public Response uploadMultipartFile(
        @FormDataParam("file") InputStream uploadedInputStream,
        @FormDataParam("file") FormDataContentDisposition fileDetail) {
// Do something with uploadedInputStream here
}

即使使用相同的输入文件,我有时也会收到以下错误:

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.io.IOException
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:421) ~[test.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386) ~[test.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335) ~[test.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:222) ~[test.jar:na]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:717) ~[test.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1644) ~[test.jar:na]
    at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:224) ~[test.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1615) ~[test.jar:na]
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) ~[test.jar:na]
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ~[test.jar:na]
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ~[test.jar:na]
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[test.jar:na]
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) ~[test.jar:na]
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) ~[test.jar:na]
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) ~[test.jar:na]
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) ~[test.jar:na]
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) ~[test.jar:na]
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) ~[test.jar:na]
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) ~[test.jar:na]
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[test.jar:na]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) ~[test.jar:na]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) ~[test.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1615) ~[test.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) [test.jar:na]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:219) [test.jar:na]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110) [test.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479) [test.jar:na]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) [test.jar:na]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044) [test.jar:na]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [test.jar:na]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [test.jar:na]
    at org.eclipse.jetty.server.Server.handle(Server.java:459) [test.jar:na]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281) [test.jar:na]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232) [test.jar:na]
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) [test.jar:na]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [test.jar:na]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [test.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72-internal]
Caused by: org.glassfish.jersey.server.ContainerException: java.io.IOException
    at org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:256) ~[test.jar:na]
    at org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:238) ~[test.jar:na]
    at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:483) ~[test.jar:na]
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:313) ~[test.jar:na]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) ~[test.jar:na]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) ~[test.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[test.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[test.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) ~[test.jar:na]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) ~[test.jar:na]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:288) ~[test.jar:na]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1110) ~[test.jar:na]
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:401) ~[test.jar:na]
    ... 37 common frames omitted
Caused by: java.io.IOException: null
    at org.eclipse.jetty.util.BlockingCallback.block(BlockingCallback.java:86) ~[test.jar:na]
    at org.eclipse.jetty.server.HttpInputOverHTTP.blockForContent(HttpInputOverHTTP.java:62) ~[test.jar:na]
    at org.eclipse.jetty.server.HttpInput$1.waitForContent(HttpInput.java:392) ~[test.jar:na]
    at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:161) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.EntityInputStream.read(EntityInputStream.java:101) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream.read(ReaderInterceptorExecutor.java:302) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEParser.fillBuf(MIMEParser.java:440) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEParser.readBody(MIMEParser.java:216) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEParser.access$600(MIMEParser.java:68) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:165) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:132) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEMessage.makeProgress(MIMEMessage.java:198) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEMessage.parseAll(MIMEMessage.java:181) ~[test.jar:na]
    at org.jvnet.mimepull.MIMEMessage.getAttachments(MIMEMessage.java:106) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readMultiPart(MultiPartReaderClientSide.java:230) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide.readMultiPart(MultiPartReaderServerSide.java:91) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:182) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:93) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:260) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:236) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) ~[test.jar:na]
    at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:74) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853) ~[test.jar:na]
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:785) ~[test.jar:na]
    at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:233) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.FormDataParamValueFactoryProvider$ValueFactory.getEntity(FormDataParamValueFactoryProvider.java:132) ~[test.jar:na]
    at org.glassfish.jersey.media.multipart.internal.FormDataParamValueFactoryProvider$FormDataParamValueFactory.provide(FormDataParamValueFactoryProvider.java:282) ~[test.jar:na]
    at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81) ~[test.jar:na]
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:125) ~[test.jar:na]
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:158) ~[test.jar:na]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:101) ~[test.jar:na]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) ~[test.jar:na]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) ~[test.jar:na]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) ~[test.jar:na]
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:305) ~[test.jar:na]
    ... 46 common frames omitted

我可以重启服务器并运行一段时间,然后再次启动错误。有什么途径可以探究这里发生了什么?

0 个答案:

没有答案