summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhe Sun <31067185+ZheSun88@users.noreply.github.com>2019-06-24 11:10:49 +0300
committerTatu Lund <tatu@vaadin.com>2019-06-24 11:10:49 +0300
commitbc576f48aa4fd51114cba4426e7ab95e633ac719 (patch)
tree48ee3ed5e55def65d5e7c890010acc9a1605d531
parent0db7fd52e14ea4de1b3d5b9fdab356b3ba016f15 (diff)
downloadvaadin-framework-bc576f48aa4fd51114cba4426e7ab95e633ac719.tar.gz
vaadin-framework-bc576f48aa4fd51114cba4426e7ab95e633ac719.zip
Limit previous solution for non-push mode UI (#11629)
* add test case * Limit the workaround for non-push mode Fixes #11616
-rw-r--r--server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/upload/InterruptUploadWithPush.java18
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadWithPushTest.java4
3 files changed, 30 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
index addf032a83..dbb394cea2 100644
--- a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
@@ -16,8 +16,6 @@
package com.vaadin.server.communication;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -42,6 +40,8 @@ import com.vaadin.shared.ApplicationConstants;
import com.vaadin.ui.UI;
import com.vaadin.ui.Upload.FailedEvent;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Handles a file upload request submitted via an Upload component.
*
@@ -617,7 +617,12 @@ public class FileUploadHandler implements RequestHandler {
} finally {
session.unlock();
}
- return true;
+ boolean pushEnabled = UI.getCurrent().getPushConfiguration()
+ .getPushMode().isEnabled();
+ if (!pushEnabled) {
+ return true;
+ }
+
// Note, we are not throwing interrupted exception forward as it is
// not a terminal level error like all other exception.
} catch (final Exception e) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/InterruptUploadWithPush.java b/uitest/src/main/java/com/vaadin/tests/components/upload/InterruptUploadWithPush.java
new file mode 100644
index 0000000000..a16c0d97ee
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/upload/InterruptUploadWithPush.java
@@ -0,0 +1,18 @@
+package com.vaadin.tests.components.upload;
+
+import com.vaadin.annotations.Push;
+
+@Push
+public class InterruptUploadWithPush extends InterruptUpload {
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11616;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Interrupting an upload with @Push shouldn't prevent uploading that same file immediately afterwards.";
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadWithPushTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadWithPushTest.java
new file mode 100644
index 0000000000..2924cc1e1f
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadWithPushTest.java
@@ -0,0 +1,4 @@
+package com.vaadin.tests.components.upload;
+
+public class InterruptUploadWithPushTest extends InterruptUploadTest {
+}