Index: PortletWindowSessionNavigationalStates.java =================================================================== --- PortletWindowSessionNavigationalStates.java (revision 667491) +++ PortletWindowSessionNavigationalStates.java (working copy) @@ -17,6 +17,7 @@ package org.apache.jetspeed.container.state.impl; import java.io.Serializable; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -36,7 +37,7 @@ { private static final class PageState implements Serializable { - public Map windowStates = new HashMap(); + public Map windowStates = Collections.synchronizedMap( new HashMap() ); public String maximizedWindowId; } @@ -77,47 +78,48 @@ pageState.maximizedWindowId = null; } - Iterator iter = requestStates.getWindowIdIterator(); - iter = pageState.windowStates.keySet().iterator(); - String windowId; - while ( iter.hasNext() ) - { - windowId = (String)iter.next(); - requestState = requestStates.getPortletWindowNavigationalState(windowId); - if ( requestState == null ) - { - requestState = new PortletWindowRequestNavigationalState(windowId); - } - //regardless, reset portlet mode and window state - requestState.setPortletMode(viewMode); - requestState.setWindowState(normalWindowState); - // get the session case just in case and create a new one - sessionState = (PortletWindowBaseNavigationalState)pageState.windowStates.get(requestState.getWindowId()); - if ( sessionState == null ) - { - if ( storeParameters ) - { - sessionState = new PortletWindowExtendedNavigationalState(); - } - else - { - sessionState = new PortletWindowBaseNavigationalState(); - } - pageState.windowStates.put(requestState.getWindowId(),sessionState); - } - //Now, sync up. NOTE we should not be in this method if there is an portlet action request. - boolean changed = syncStates(false, requestState,(PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId)); - if (changed) - { - removeFromCache(context, requestState.getWindowId(), cache); - removeFromCache(context, page.getId(), decorationCache); - if (storeParameters) - { - ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings(); - } - } - - } + synchronized (pageState.windowStates) { + Iterator iter = pageState.windowStates.keySet().iterator(); + String windowId; + while ( iter.hasNext() ) + { + windowId = (String)iter.next(); + requestState = requestStates.getPortletWindowNavigationalState(windowId); + if ( requestState == null ) + { + requestState = new PortletWindowRequestNavigationalState(windowId); + } + //regardless, reset portlet mode and window state + requestState.setPortletMode(viewMode); + requestState.setWindowState(normalWindowState); + // get the session case just in case and create a new one + sessionState = (PortletWindowBaseNavigationalState)pageState.windowStates.get(requestState.getWindowId()); + if ( sessionState == null ) + { + if ( storeParameters ) + { + sessionState = new PortletWindowExtendedNavigationalState(); + } + else + { + sessionState = new PortletWindowBaseNavigationalState(); + } + pageState.windowStates.put(requestState.getWindowId(),sessionState); + } + //Now, sync up. NOTE we should not be in this method if there is an portlet action request. + boolean changed = syncStates(false, requestState,(PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId)); + if (changed) + { + removeFromCache(context, requestState.getWindowId(), cache); + removeFromCache(context, page.getId(), decorationCache); + if (storeParameters) + { + ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings(); + } + } + + } + } } public void sync(RequestContext context, Page page, PortletWindowRequestNavigationalStates requestStates, JetspeedContentCache cache, JetspeedContentCache decorationCache) @@ -228,28 +230,30 @@ } // now copy missing requestStates from the pageState - iter = pageState.windowStates.keySet().iterator(); - String windowId; - while ( iter.hasNext() ) - { - windowId = (String)iter.next(); - requestState = requestStates.getPortletWindowNavigationalState(windowId); - if ( requestState == null ) - { - requestState = new PortletWindowRequestNavigationalState(windowId); - boolean changed = syncStates(false, requestState,(PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId)); - requestStates.addPortletWindowNavigationalState(windowId, requestState); - if (changed) - { - removeFromCache(context, requestState.getWindowId(), cache); - removeFromCache(context, page.getId(), decorationCache); - if (storeParameters) - { - ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings(); - } - } - } - } + synchronized (pageState.windowStates) { + iter = pageState.windowStates.keySet().iterator(); + String windowId; + while ( iter.hasNext() ) + { + windowId = (String)iter.next(); + requestState = requestStates.getPortletWindowNavigationalState(windowId); + if ( requestState == null ) + { + requestState = new PortletWindowRequestNavigationalState(windowId); + boolean changed = syncStates(false, requestState,(PortletWindowBaseNavigationalState)pageState.windowStates.get(windowId)); + requestStates.addPortletWindowNavigationalState(windowId, requestState); + if (changed) + { + removeFromCache(context, requestState.getWindowId(), cache); + removeFromCache(context, page.getId(), decorationCache); + if (storeParameters) + { + ((PortletWindowExtendedNavigationalState)sessionState).resetDecoratorActionEncodings(); + } + } + } + } + } } private boolean modeChanged(PortletMode req, PortletMode ses)