浏览代码

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
tags/7.1.0
Artur Signell 11 年前
父节点
当前提交
d6fca78207
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12
    3
      client/src/com/vaadin/client/ui/VUpload.java

+ 12
- 3
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);

正在加载...
取消
保存