diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-06 19:18:28 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-06-07 07:19:42 +0000 |
commit | d6fca7820739508387ae6db33af3a4a4fb5a846e (patch) | |
tree | a95ea3ab47ceaa28812e250f48e3cf0f0a27d637 /client | |
parent | a5ec937fb8a91a55d754f8f2048416a5dd10b931 (diff) | |
download | vaadin-framework-d6fca7820739508387ae6db33af3a4a4fb5a846e.tar.gz vaadin-framework-d6fca7820739508387ae6db33af3a4a4fb5a846e.zip |
Fix race condition in upload with push (#10214)
If the upload finishes before the poll timer is fired on the client side then the client will poll forever with the wrong id
Change-Id: I11cad8e978a8499a4fddb9e8bfe7f6c4326f98f5
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VUpload.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/VUpload.java b/client/src/com/vaadin/client/ui/VUpload.java index 866a6ca4cf..c08d75e9b7 100644 --- a/client/src/com/vaadin/client/ui/VUpload.java +++ b/client/src/com/vaadin/client/ui/VUpload.java @@ -270,13 +270,22 @@ public class VUpload extends SimplePanel { /* * Visit server a moment after upload has started to see possible * changes from UploadStarted event. Will be cleared on complete. + * + * Must get the id here as the upload can finish before the timer + * expires and in that case nextUploadId has been updated and is + * wrong. */ + final int thisUploadId = nextUploadId; t = new Timer() { @Override public void run() { - VConsole.log("Visiting server to see if upload started event changed UI."); - client.updateVariable(paintableId, "pollForStart", - nextUploadId, true); + // Only visit the server if the upload has not already + // finished + if (thisUploadId == nextUploadId) { + VConsole.log("Visiting server to see if upload started event changed UI."); + client.updateVariable(paintableId, "pollForStart", + thisUploadId, true); + } } }; t.schedule(800); |