summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java8
1 files changed, 6 insertions, 2 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 dbb394cea2..64e0df1b06 100644
--- a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
@@ -269,13 +269,17 @@ public class FileUploadHandler implements RequestHandler {
session.lock();
try {
UI uI = session.getUIById(Integer.parseInt(uiId));
+ if (uI == null) {
+ throw new IOException(
+ "File upload ignored because the UI was not found and stream variable cannot be determined");
+ }
+ // Set UI so that it can be used in stream variable clean up
UI.setCurrent(uI);
streamVariable = uI.getConnectorTracker()
.getStreamVariable(connectorId, variableName);
String secKey = uI.getConnectorTracker().getSeckey(streamVariable);
if (secKey == null || !secKey.equals(parts[3])) {
- // TODO Should rethink error handling
return true;
}
@@ -456,7 +460,7 @@ public class FileUploadHandler implements RequestHandler {
try {
// Store ui reference so we can do cleanup even if connector is
// detached in some event handler
- UI ui = connector.getUI();
+ UI ui = UI.getCurrent();
boolean forgetVariable = streamToReceiver(session, inputStream,
streamVariable, filename, mimeType, contentLength);
if (forgetVariable) {