summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2013-08-15 08:59:03 +0300
committerVaadin Code Review <review@vaadin.com>2013-08-15 10:49:25 +0000
commit36413cb556cee7a7024a552e3772a2369d8f0294 (patch)
tree0b603d5f0904413a683d8ec0fb2664e542ee9e4b /server/src/com/vaadin/ui
parentf72be69c60432bb94251cd7a73ad167062f9c6a8 (diff)
downloadvaadin-framework-36413cb556cee7a7024a552e3772a2369d8f0294.tar.gz
vaadin-framework-36413cb556cee7a7024a552e3772a2369d8f0294.zip
Make sure that no fileIds are replayed to the client (#12330)
Due to how ProxyReceivers are constructed and serialized, we don't want to resend the ProxyReceivers for files that already are in the queue. Either we needed to change the way ProxyReceivers behave, or just make sure that they aren't resent. I chose the double-check method. Change-Id: I7c4e866ba4287afd3e80329be3640335d4ff00af
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/DragAndDropWrapper.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java
index 6c6aa3c3f4..5d6825c868 100644
--- a/server/src/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java
@@ -17,10 +17,12 @@ package com.vaadin.ui;
import java.io.OutputStream;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import com.vaadin.event.Transferable;
import com.vaadin.event.TransferableImpl;
@@ -183,6 +185,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
private final Map<String, Object> html5DataFlavors = new LinkedHashMap<String, Object>();
private DragStartMode dragStartMode = DragStartMode.NONE;
+ private Set<String> sentIds = new HashSet<String>();
+
/**
* Wraps given component in a {@link DragAndDropWrapper}.
*
@@ -229,10 +233,24 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
ProxyReceiver proxyReceiver = entry.getValue();
Html5File html5File = proxyReceiver.file;
if (html5File.getStreamVariable() != null) {
- target.addVariable(this, "rec-" + id, new ProxyReceiver(id,
- html5File));
- // these are cleaned from receivers once the upload has
- // started
+ if (!sentIds.contains(id)) {
+ target.addVariable(this, "rec-" + id,
+ new ProxyReceiver(id, html5File));
+
+ /*
+ * if a new batch is requested to be uploaded before the
+ * last one is done, any remaining ids will be replayed.
+ * We want to avoid a new ProxyReceiver to be made since
+ * it'll get a new URL, so we need to keep extra track
+ * on what has been sent.
+ *
+ * See #12330.
+ */
+ sentIds.add(id);
+
+ // these are cleaned from receivers once the upload has
+ // started
+ }
} else {
// instructs the client side not to send the file
target.addVariable(this, "rec-" + id, (String) null);
@@ -317,6 +335,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
}
// no need tell to the client about this receiver on next paint
receivers.remove(id);
+ sentIds.remove(id);
// let the terminal GC the streamvariable and not to accept other
// file uploads to this variable
event.disposeStreamVariable();