From d8b0b504894255543e68f074b30051a91f8a1154 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Fri, 30 Aug 2013 14:38:48 +0300 Subject: [PATCH] Always unlock the same session instance that was locked (#12481) Change-Id: I15ff1177d827bc8fee9f8f723f9a288b0c3aea71 --- server/src/com/vaadin/server/AbstractClientConnector.java | 5 +++-- server/src/com/vaadin/server/FileDownloader.java | 6 ++++-- server/src/com/vaadin/ui/AbstractMedia.java | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index 91a9e41522..a73ca3d985 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -625,7 +625,8 @@ public abstract class AbstractClientConnector implements ClientConnector, String[] parts = path.split("/", 2); String key = parts[0]; - getSession().lock(); + VaadinSession session = getSession(); + session.lock(); try { ConnectorResource resource = (ConnectorResource) getResource(key); if (resource == null) { @@ -633,7 +634,7 @@ public abstract class AbstractClientConnector implements ClientConnector, } stream = resource.getStream(); } finally { - getSession().unlock(); + session.unlock(); } stream.writeResponse(request, response); return true; diff --git a/server/src/com/vaadin/server/FileDownloader.java b/server/src/com/vaadin/server/FileDownloader.java index 9b49ad8edd..bd7d9caafd 100644 --- a/server/src/com/vaadin/server/FileDownloader.java +++ b/server/src/com/vaadin/server/FileDownloader.java @@ -129,7 +129,9 @@ public class FileDownloader extends AbstractExtension { // Ignore if it isn't for us return false; } - getSession().lock(); + VaadinSession session = getSession(); + + session.lock(); DownloadStream stream; try { @@ -151,7 +153,7 @@ public class FileDownloader extends AbstractExtension { stream.setContentType("application/octet-stream;charset=UTF-8"); } } finally { - getSession().unlock(); + session.unlock(); } stream.writeResponse(request, response); return true; diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 97947b568d..d7d593c29e 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -30,6 +30,7 @@ import com.vaadin.server.Resource; import com.vaadin.server.ResourceReference; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.ui.AbstractMediaState; import com.vaadin.shared.ui.MediaControl; @@ -90,7 +91,8 @@ public abstract class AbstractMedia extends AbstractComponent { DownloadStream stream; - getSession().lock(); + VaadinSession session = getSession(); + session.lock(); try { List sources = getState().sources; @@ -108,7 +110,7 @@ public abstract class AbstractMedia extends AbstractComponent { .getResource(reference); stream = resource.getStream(); } finally { - getSession().unlock(); + session.unlock(); } stream.writeResponse(request, response); -- 2.39.5