From ddd9bd75cd6695c8a3c2b69f79399ec7a6249d04 Mon Sep 17 00:00:00 2001 From: doggy-dev Date: Tue, 17 Jul 2018 14:50:47 +0200 Subject: [PATCH] Memory leak fix in ConnectorTracker (#10743) When finished with upload, streamVariable should be disposed. Now StreamVariable is removed also from streamVariableToSeckey. https://github.com/vaadin/framework/issues/10695 #10695 --- server/src/main/java/com/vaadin/ui/ConnectorTracker.java | 3 ++- server/src/main/java/com/vaadin/ui/Upload.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java index 713d9b47c1..8b8ba269cf 100644 --- a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java @@ -846,7 +846,8 @@ public class ConnectorTracker implements Serializable { } Map nameToStreamVar = pidToNameToStreamVariable .get(connectorId); - nameToStreamVar.remove(variableName); + StreamVariable streamVar = nameToStreamVar.remove(variableName); + streamVariableToSeckey.remove(streamVar); if (nameToStreamVar.isEmpty()) { pidToNameToStreamVariable.remove(connectorId); } diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 1a66842e3d..70f31f4957 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -1155,6 +1155,8 @@ public class Upload extends AbstractComponent fireUploadSuccess(event.getFileName(), event.getMimeType(), event.getContentLength()); endUpload(); + if(lastStartedEvent != null) + lastStartedEvent.disposeStreamVariable(); } @Override @@ -1173,6 +1175,8 @@ public class Upload extends AbstractComponent } } finally { endUpload(); + if(lastStartedEvent != null) + lastStartedEvent.disposeStreamVariable(); } } }; -- 2.39.5