summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorElmot <elmot@vaadin.com>2018-07-20 13:27:32 +0300
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-07-30 16:45:46 +0300
commit4b1fc2e1fbbd5ab63cc6f5077bb4afe19834992e (patch)
tree03e53c3c63a5573bba2c315b5d91ad87fb08bcdc /documentation
parent4c1ae5ea1ac78df9a3bda9fe0ee5e8a53edd1db2 (diff)
downloadvaadin-framework-4b1fc2e1fbbd5ab63cc6f5077bb4afe19834992e.tar.gz
vaadin-framework-4b1fc2e1fbbd5ab63cc6f5077bb4afe19834992e.zip
Document how to handle cancelled file downloads.
Fixes #9014 (cherry picked from commit 65d2baf)
Diffstat (limited to 'documentation')
-rw-r--r--documentation/articles/LettingTheUserDownloadAFile.asciidoc29
1 files changed, 27 insertions, 2 deletions
diff --git a/documentation/articles/LettingTheUserDownloadAFile.asciidoc b/documentation/articles/LettingTheUserDownloadAFile.asciidoc
index 4b595fc6de..209ef27c38 100644
--- a/documentation/articles/LettingTheUserDownloadAFile.asciidoc
+++ b/documentation/articles/LettingTheUserDownloadAFile.asciidoc
@@ -62,8 +62,7 @@ along with the file to ensure the browser doesn't try to open the file
even if it's is a file type that the browser knows how to deal with.
[[lazily-determine-the-content-and-the-name-of-the-file-being-server]]
-Lazily determine the content and the name of the file being server
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+==== Lazily determine the content and the name of the file being server
One can lazily determine the content of the file using a
`StreamResource`. Yet the name of the file that is going to be
@@ -110,3 +109,29 @@ public class OnDemandFileDownloader extends FileDownloader {
}
}
....
+
+[[lazily-determine-the-content-and-the-name-of-the-file-being-server]]
+==== Cancelled downloads
+
+Since downloadable files may be quite big, and the download process may take time, the user might decide to
+cancel the download process. It this case `IOException` may be thrown by the web server. In this case the exception
+does not mean that something went wrong with the application, but it the. To prevent those exceptions to be logged, you can catch
+and ignore it as here:
+
+```java
+public class IgnoreCancelDownloader extends FileDownloader {
+
+ ...
+
+ @Override
+ public boolean handleConnectorRequest(final VaadinRequest request, final VaadinResponse response, final String path) {
+ try {
+ return super.handleConnectorRequest(request, response, path);
+ } catch (final IOException ignored) {
+ return true;
+ }
+ }
+}
+
+```
+Note that the exception is a sublclass of `IOException`, but the particular class depends of the web container.