views:

27

answers:

0

I have a very basic upload action in my controller. It looks something like the action below. It works great. The only problem I'm seeing is when a user cancels an upload (or hits stop on their browser). I am able to recover correctly, but not before seeing an uncaught exception in my logs. The exception is listed below. Any help or feedback on how to correctly catch the uncaught exception here would be appreciated. Seems like it's happening somewhere between the client and the controller action since the exception is being displayed but none of the log messages in the action are showing up.

def upload = {
    def f = null
    try {
        f = request.getFile('assetFile')
        if(!f || f.empty) {
            log.warn "File is empty"
            render(view:'upload')
            return
        }
    } catch (Exception e) {
        log.warn "Caught exception:", e
        render(view:'upload')
        return
    }
}

Exception is:

 2010-08-06 15:33:22,826 ERROR [TP-Processor8] filter.UrlMappingsFilter - Error when matching URL mapping [/(*)/(*)?/(*)?]:Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
    org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
            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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
            at org.jsecurity.web.servlet.JSecurityFilter.doFilterInternal(JSecurityFilter.java:384)
            at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:183)
            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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
            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.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
            at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
            at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
            at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
            at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
            at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
            at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
            ... 25 more
    Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
            at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:983)
            at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:887)
            at java.io.InputStream.read(InputStream.java:85)
            at org.apache.commons.fileupload.util.Streams.copy(Streams.java:94)
            at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64)
            at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
            ... 26 more