We are using WildFly as application server and as it happens the web server (Undertow) will throw an IOException if an uploaded file is bigger than the maximum allowed filesize in WildFly/Undertow preferencecs. We could naturally set some arbitrarily large value for the maximum file size (and handle file size restrictions in our Vaadin code), but it would seem better that we could some how handle the exception.
So, is there some way we can handle the exception with Upload component? It seems that the exception thrown by Undertow is not even getting catched by the DefaultErrorHandler in Vaadin.
Stack trace of the error (occurs after the upload button has been pressed):
SEVERE [com.vaadin.server.DefaultErrorHandler]
(default task-28) : java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:161) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:219) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:207) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2083) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.xnio.channels.Channels.readBlocking(Channels.java:294)
at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:170) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:146) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:133) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:124) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at com.vaadin.server.communication.FileUploadHandler.readLine(FileUploadHandler.java:302) [vaadin-server-7.7.6.jar:7.7.6]
at com.vaadin.server.communication.FileUploadHandler.doHandleSimpleMultipartFileUpload(FileUploadHandler.java:364) [vaadin-server-7.7.6.jar:7.7.6]
at com.vaadin.server.communication.FileUploadHandler.handleRequest(FileUploadHandler.java:288) [vaadin-server-7.7.6.jar:7.7.6
....