aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-02-19 09:46:18 +0000
committerArtur Signell <artur.signell@itmill.com>2010-02-19 09:46:18 +0000
commit02c8f54ea97f812bac899e565a98f29a83bf2977 (patch)
tree180108b853be1d7ce6cc78274908ec8eaee4502f
parentb1a0c7b4032931cab3d53ca6389ae27624c8d76f (diff)
downloadvaadin-framework-02c8f54ea97f812bac899e565a98f29a83bf2977.tar.gz
vaadin-framework-02c8f54ea97f812bac899e565a98f29a83bf2977.zip
Fix for #3860 - FileResource.getStream should not consume FileNotFoundException
svn changeset:11395/svn branch:6.3
-rw-r--r--src/com/vaadin/terminal/FileResource.java12
-rw-r--r--tests/src/com/vaadin/tests/resources/NonExistingFileResource.java48
2 files changed, 59 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/FileResource.java b/src/com/vaadin/terminal/FileResource.java
index 46f1a6c028..7a9feae674 100644
--- a/src/com/vaadin/terminal/FileResource.java
+++ b/src/com/vaadin/terminal/FileResource.java
@@ -10,6 +10,7 @@ import java.io.FileNotFoundException;
import com.vaadin.Application;
import com.vaadin.service.FileTypeResolver;
+import com.vaadin.terminal.Terminal.ErrorEvent;
/**
* <code>FileResources</code> are files or directories on local filesystem. The
@@ -67,7 +68,16 @@ public class FileResource implements ApplicationResource {
ds.setCacheTime(cacheTime);
return ds;
} catch (final FileNotFoundException e) {
- // No logging for non-existing files at this level.
+ // Log the exception using the application error handler
+ getApplication().getErrorHandler().terminalError(new ErrorEvent() {
+
+ @Override
+ public Throwable getThrowable() {
+ return e;
+ }
+
+ });
+
return null;
}
}
diff --git a/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java b/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java
new file mode 100644
index 0000000000..b894756603
--- /dev/null
+++ b/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.resources;
+import java.io.File;
+
+import com.vaadin.terminal.FileResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class NonExistingFileResource extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button existing = createButton("WEB-INF/web.xml");
+ Button nonExisting = createButton("WEB-INF/web2.xml");
+ addComponent(existing);
+ addComponent(nonExisting);
+
+ }
+
+ private Button createButton(final String filename) {
+ Button b = new Button("Download " + filename);
+ b.addListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ FileResource res = new FileResource(new File(getContext()
+ .getBaseDirectory()
+ + "/" + filename), NonExistingFileResource.this);
+ getMainWindow().open(res);
+
+ }
+ });
+ return b;
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}