diff options
author | Henri Sara <hesara@vaadin.com> | 2013-04-29 14:19:02 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2013-04-29 14:19:02 +0300 |
commit | 747c99eea95b7dba0b9ea8023a01e4e97222194d (patch) | |
tree | 1bc49591d74fbda909c548345d91389be3042744 /server | |
parent | 97e5714b0aa99e39fd1c6ec7089631ea3a6f9fcb (diff) | |
parent | d214efa39a011002eb88e683676508e438842fe4 (diff) | |
download | vaadin-framework-747c99eea95b7dba0b9ea8023a01e4e97222194d.tar.gz vaadin-framework-747c99eea95b7dba0b9ea8023a01e4e97222194d.zip |
Merge commit 'd214efa39a011002eb88e683676508e438842fe4'
Conflicts:
client/src/com/vaadin/client/ui/orderedlayout/Slot.java
Change-Id: I2fb5d1ac4b5c10a1fe5b1a6f976c1f59283b9169
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/event/ActionManager.java | 60 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinServlet.java | 32 |
2 files changed, 50 insertions, 42 deletions
diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 7a4b39444e..ce3e27d539 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -15,7 +15,7 @@ */ package com.vaadin.event; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import com.vaadin.event.Action.Container; @@ -44,10 +44,10 @@ public class ActionManager implements Action.Container, Action.Handler, private static final long serialVersionUID = 1641868163608066491L; /** List of action handlers */ - protected HashSet<Action> ownActions = null; + protected LinkedHashSet<Action> ownActions = null; /** List of action handlers */ - protected HashSet<Handler> actionHandlers = null; + protected LinkedHashSet<Handler> actionHandlers = null; /** Action mapper */ protected KeyMapper<Action> actionMapper = null; @@ -90,7 +90,7 @@ public class ActionManager implements Action.Container, Action.Handler, @Override public <T extends Action & Action.Listener> void addAction(T action) { if (ownActions == null) { - ownActions = new HashSet<Action>(); + ownActions = new LinkedHashSet<Action>(); } if (ownActions.add(action)) { requestRepaint(); @@ -115,7 +115,7 @@ public class ActionManager implements Action.Container, Action.Handler, if (actionHandler != null) { if (actionHandlers == null) { - actionHandlers = new HashSet<Handler>(); + actionHandlers = new LinkedHashSet<Handler>(); } if (actionHandlers.add(actionHandler)) { @@ -150,20 +150,7 @@ public class ActionManager implements Action.Container, Action.Handler, actionMapper = null; - HashSet<Action> actions = new HashSet<Action>(); - if (actionHandlers != null) { - for (Action.Handler handler : actionHandlers) { - Action[] as = handler.getActions(actionTarget, viewer); - if (as != null) { - for (Action action : as) { - actions.add(action); - } - } - } - } - if (ownActions != null) { - actions.addAll(ownActions); - } + LinkedHashSet<Action> actions = getActionSet(actionTarget, viewer); /* * Must repaint whenever there are actions OR if all actions have been @@ -225,22 +212,7 @@ public class ActionManager implements Action.Container, Action.Handler, @Override public Action[] getActions(Object target, Object sender) { - HashSet<Action> actions = new HashSet<Action>(); - if (ownActions != null) { - for (Action a : ownActions) { - actions.add(a); - } - } - if (actionHandlers != null) { - for (Action.Handler h : actionHandlers) { - Action[] as = h.getActions(target, sender); - if (as != null) { - for (Action a : as) { - actions.add(a); - } - } - } - } + LinkedHashSet<Action> actions = getActionSet(target, sender); return actions.toArray(new Action[actions.size()]); } @@ -259,4 +231,22 @@ public class ActionManager implements Action.Container, Action.Handler, } } + private LinkedHashSet<Action> getActionSet(Object target, Object sender) { + LinkedHashSet<Action> actions = new LinkedHashSet<Action>(); + if (ownActions != null) { + actions.addAll(ownActions); + + } + if (actionHandlers != null) { + for (Action.Handler h : actionHandlers) { + Action[] as = h.getActions(target, sender); + if (as != null) { + for (Action a : as) { + actions.add(a); + } + } + } + } + return actions; + } } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 1facf6e29a..de074941c1 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -666,14 +666,32 @@ public class VaadinServlet extends HttpServlet implements Constants { protected void writeStaticResourceResponse(HttpServletRequest request, HttpServletResponse response, URL resourceUrl) throws IOException { // Write the resource to the client. - final OutputStream os = response.getOutputStream(); - final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE]; - int bytes; - InputStream is = resourceUrl.openStream(); - while ((bytes = is.read(buffer)) >= 0) { - os.write(buffer, 0, bytes); + URLConnection connection = resourceUrl.openConnection(); + try { + int length = connection.getContentLength(); + if (length >= 0) { + response.setContentLength(length); + } + } catch (Throwable e) { + // This can be ignored, content length header is not required. + // Need to close the input stream because of + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700 to + // prevent it from hanging, but that is done below. + } + + InputStream is = connection.getInputStream(); + try { + final OutputStream os = response.getOutputStream(); + final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE]; + int bytes; + while ((bytes = is.read(buffer)) >= 0) { + os.write(buffer, 0, bytes); + } + } finally { + if (is != null) { + is.close(); + } } - is.close(); } private URL findResourceURL(String filename, ServletContext sc) |