Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004270 [Resin] minor always 10-25-10 02:21 01-11-11 18:14
Reporter kajh View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.15 Product Version 3.0.26
  Product Build
Summary 0004270: IllegalStateException content-length exception
Description We are using resin 3.0.26 and get a java.lang.IllegalStateException: https://myhost.com/download.html: [^] tried to write 9000 bytes with content-length 3878 (At char=60) when sending a textfile to the user. I have checked the size of the textfile and it is 3878.

See full stacktrace under "Additional Information".

This might be related to http://bugs.caucho.com/view.php?id=1067 [^]

I see the issue in a Spring 3.0.4.

We use the following code for sending the file to the user:

    protected void downloadFile(final HttpServletResponse response, final String content, final String filename,
            final String encoding) throws IOException {
        String[] supportedEncodings = new String[] { "utf-8", "iso-8859-1" };
        Arrays.sort(supportedEncodings);
        if (encoding == null || Arrays.binarySearch(supportedEncodings, encoding) < 0) {
            throw new IllegalArgumentException("Illegal encoding: " + encoding);
        }
        ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes(encoding));
        int contentLengh = content.getBytes(encoding).length;
        String mimetype = "application/force-download";
        response.setBufferSize(contentLengh);
        response.setContentType(mimetype);
        response.setHeader("content-disposition", "attachment; filename=\"" + filename + "\"");
        response.setContentLength(contentLengh);

        FileCopyUtils.copy(bis, response.getOutputStream());
        bis.close();
        response.getOutputStream().flush();
        response.getOutputStream().close();
    }

Steps To Reproduce
Additional Information [2010-10-25 10:24:07.373] org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client.
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
[2010-10-25 10:24:07.373] at javax.servlet.http.HttpServlet.service(HttpServlet.java:115)
[2010-10-25 10:24:07.373] at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
[2010-10-25 10:24:07.373] at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
[2010-10-25 10:24:07.373] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
[2010-10-25 10:24:07.373] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[2010-10-25 10:24:07.373] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
[2010-10-25 10:24:07.373] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
[2010-10-25 10:24:07.373] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
[2010-10-25 10:24:07.373] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
[2010-10-25 10:24:07.373] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
[2010-10-25 10:24:07.373] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
[2010-10-25 10:24:07.373] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
[2010-10-25 10:24:07.373] at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:207)
[2010-10-25 10:24:07.373] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173)
[2010-10-25 10:24:07.373] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
[2010-10-25 10:24:07.373] at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:420)
[2010-10-25 10:24:07.373] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:514)
[2010-10-25 10:24:07.373] at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520)
[2010-10-25 10:24:07.373] at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
[2010-10-25 10:24:07.373] at java.lang.Thread.run(Thread.java:619)
[2010-10-25 10:24:07.373] Caused by: java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client.
[2010-10-25 10:24:07.373] at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:565)
[2010-10-25 10:24:07.373] at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:110)
[2010-10-25 10:24:07.373] at org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.sendRedirect(SaveContextOnUpdateOrErrorResponseWrapper.java:74)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.view.RedirectView.sendRedirect(RedirectView.java:389)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.view.RedirectView.renderMergedOutputModel(RedirectView.java:226)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1031)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:815)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
[2010-10-25 10:24:07.373] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
[2010-10-25 10:24:07.373] ... 39 more
[2010-10-25 10:24:07.406] java.lang.IllegalStateException: https://myhost.com/download.html: [^] tried to write 9000 bytes with content-length 3878 (At char=60).
[2010-10-25 10:24:07.406] at com.caucho.server.connection.ResponseStream.lengthException(ResponseStream.java:548)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.ResponseStream.setBufferOffset(ResponseStream.java:359)
[2010-10-25 10:24:07.406] at com.caucho.vfs.i18n.UTF8Writer.write(UTF8Writer.java:155)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.ToByteResponseStream.flushCharBuffer(ToByteResponseStream.java:469)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.ResponseStream.finish(ResponseStream.java:659)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.ResponseStream.close(ResponseStream.java:800)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.AbstractHttpResponse.finish(AbstractHttpResponse.java:1986)
[2010-10-25 10:24:07.406] at com.caucho.server.connection.AbstractHttpResponse.close(AbstractHttpResponse.java:265)
[2010-10-25 10:24:07.406] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:190)
[2010-10-25 10:24:07.406] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
[2010-10-25 10:24:07.406] at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:420)
[2010-10-25 10:24:07.406] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:514)
[2010-10-25 10:24:07.406] at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520)
[2010-10-25 10:24:07.406] at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
[2010-10-25 10:24:07.406] at java.lang.Thread.run(Thread.java:619)
Attached Files

- Relationships

- Notes
(0004800)
kajh
10-25-10 02:26

Obs, I was a bit too fast when checking fixversion for http://bugs.caucho.com/view.php?id=1067 [^] which is resin 3.1.2. Sorry for the duplicate!
 
(0004916)
ferg
01-11-11 18:14

server/02ee
 

- Issue History
Date Modified Username Field Change
10-25-10 02:21 kajh New Issue
10-25-10 02:23 kajh Issue Monitored: kajh
10-25-10 02:26 kajh Note Added: 0004800
01-11-11 18:14 ferg Note Added: 0004916
01-11-11 18:14 ferg Assigned To  => ferg
01-11-11 18:14 ferg Status new => closed
01-11-11 18:14 ferg Resolution open => fixed
01-11-11 18:14 ferg Fixed in Version  => 4.0.15


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
32 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker