Browse Source

Limit previous solution for non-push mode UI (#11629)

* add test case

* Limit the workaround for non-push mode

Fixes #11616
tags/8.9.0.alpha1
Zhe Sun 4 years ago
parent
commit
bc576f48aa

+ 8
- 3
server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java View File



package com.vaadin.server.communication; package com.vaadin.server.communication;


import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.Upload.FailedEvent; import com.vaadin.ui.Upload.FailedEvent;


import static java.nio.charset.StandardCharsets.UTF_8;

/** /**
* Handles a file upload request submitted via an Upload component. * Handles a file upload request submitted via an Upload component.
* *
} finally { } finally {
session.unlock(); 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 // Note, we are not throwing interrupted exception forward as it is
// not a terminal level error like all other exception. // not a terminal level error like all other exception.
} catch (final Exception e) { } catch (final Exception e) {

+ 18
- 0
uitest/src/main/java/com/vaadin/tests/components/upload/InterruptUploadWithPush.java View File

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.";
}

}

+ 4
- 0
uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadWithPushTest.java View File

package com.vaadin.tests.components.upload;

public class InterruptUploadWithPushTest extends InterruptUploadTest {
}

Loading…
Cancel
Save