tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob GB <rob_gar_...@hotmail.com>
Subject RE: Tomcat download stream gets broken
Date Thu, 19 May 2011 16:09:20 GMT

Hi,I sent it from gmail in the right format some minutes ago, you should had already received
it.Here it goes again. Thanks.

    public void service(HttpServletRequest request, HttpServletResponse response) throws
IOException {        byte buf[] = new byte[1024 * 4];        try {           
File file = new File(realFilename);            int size = (int) file.length();   
        BufferedInputStream realFile = new BufferedInputStream(new FileInputStream(file)); 
          OutputStream out = response.getOutputStream();            response.setContentLength(size); 
          while (true) {                int count = realFile.read(buf);   
            if (count == -1) {                    break;           
    }                out.write(buf, 0, count);            }         
  out.flush();        } catch (FileNotFoundException e) {            logger.error("Stream
download failed, file not found: " + realFilename, e);            response.sendError(404); 
      } catch (Exception e) {            logger.error("DownloadException:", e); 
      }    }
However once in a while I get an error that prevents files from being downloaded:

DownloadException:  java.net.SocketException: Broken pipe        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366) 
      at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)       
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)        at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392) 
      at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)     
  at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89) 
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) 
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) 
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) 
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) 
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) 
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) 
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) 
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) 
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)   
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) 
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) 
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:113) 
      at java.lang.Thread.run(Thread.java:619)Caused by: java.net.SocketException: Broken
pipe        at java.net.SocketOutputStream.socketWrite0(Native Method)        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) 
      at java.net.SocketOutputStream.write(SocketOutputStream.java:136)        at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:750) 
      at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)       
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)        at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:773) 
      at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118) 
      at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:583) 
      at org.apache.coyote.Response.doWrite(Response.java:560)        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361) 
      ... 23 more



> Date: Thu, 19 May 2011 18:03:39 +0200
> From: aw@ice-sa.com
> To: users@tomcat.apache.org
> Subject: Re: Tomcat download stream gets broken
> 
> Rob GB wrote:
> >> No-one is going to read all that unformatted code. Try again.> > p>

> > ok, trying again, it looks formatted in hotmail editor:
> 
> Get a better email program, cause it ain't formatted here.
> Are you trying to send this "as html" by any chance ? If yes, then try "as plain text"
if 
> your email program has such an option.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message