我正在从jboss 6迁移到jboss 8.2。之前它没有任何异常,但现在当我尝试下载文件时,我得到了以下异常
Caused by: org.xnio.channels.FixedLengthUnderflowException: 8088 bytes remaining
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.terminateWrites(AbstractFixedLengthStreamSinkConduit.java:255) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.xnio.conduits.Conduits.writeFinalBasic(Conduits.java:134)
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.writeFinal(AbstractFixedLengthStreamSinkConduit.java:175) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.xnio.conduits.ConduitStreamSinkChannel.writeFinal(ConduitStreamSinkChannel.java:104)
at io.undertow.channels.DetachableStreamSinkChannel.writeFinal(DetachableStreamSinkChannel.java:194) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.HttpServerExchange$WriteDispatchChannel.writeFinal(HttpServerExchange.java:1829) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:565) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:600) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletOutputStreamImpl.updateWritten(ServletOutputStreamImpl.java:364) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:223) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at java.io.BufferedOutputStream.flushBuffer(Unknown Source) [rt.jar:1.7.0_71]
at java.io.BufferedOutputStream.write(Unknown Source) [rt.jar:1.7.0_71]
代码段
ContentType = "application/octet-stream";
BufInput = new BufferedInputStream(new FileInputStream(File), 5000);
Response.reset();
Response.setIntHeader("Expires", 0);
Response.setContentType(contentType);
Response.setHeader("Content-Disposition", header);
Response.setIntHeader("Content-length", (int) File.length());
Response.setContentLength((int)File.length());
OutStream = new BufferedOutputStream(Response.getOutputStream(), 5000);
int Byte;
while ((Byte = BufInput.read()) != -1)
OutStream.write(Byte);
OutStream.flush();
OutStream.close();
BufInput.close();
答案 0 :(得分:0)
这已在8.2.1和9.0.x中修复
所以解决方案是升级。