Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPC-82 : Potential concurency issues in FederatingPortletInvokerSer…
Browse files Browse the repository at this point in the history
…vice and ContainerPortletInvoker
  • Loading branch information
vietj committed Apr 4, 2013
1 parent 6e9b11c commit 1d437df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ private FederatedPortletInvoker getOrResolveFederatedInvoker(String federatedId,
{
synchronized (this)
{
invokerCache.put(federatedId, federatedPortletInvoker); // put newly resolved invoker in cache
Map<String, FederatedPortletInvoker> copy = new HashMap<String, FederatedPortletInvoker>(invokerCache);
copy.put(federatedId, federatedPortletInvoker); // put newly resolved invoker in cache
invokerCache = copy;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ public class ContainerPortletInvoker extends PortletInvokerInterceptor
public static final String PORTLET_CONTAINER = "PORTLET_CONTAINER";

/** . */
private Map<String, Portlet> portlets = new HashMap<String, Portlet>();
private volatile Map<String, PortletImpl> portlets = new HashMap<String, PortletImpl>();

public void addPortletContainer(PortletContainer portletContainer)
public synchronized void addPortletContainer(PortletContainer portletContainer)
{
Map<String, Portlet> portlets = new HashMap<String, Portlet>(this.portlets);
Map<String, PortletImpl> portlets = new HashMap<String, PortletImpl>(this.portlets);
PortletImpl portlet = new PortletImpl(portletContainer);
portlets.put(portlet.getContext().getId(), portlet);

//
this.portlets = portlets;
}

public void removePortletContainer(PortletContainer portletContainer)
public synchronized void removePortletContainer(PortletContainer portletContainer)
{
Map<String, Portlet> portlets = new HashMap<String, Portlet>(this.portlets);
Map<String, PortletImpl> portlets = new HashMap<String, PortletImpl>(this.portlets);
PortletImpl portlet = new PortletImpl(portletContainer);
portlets.remove(portlet.getContext().getId());

Expand Down Expand Up @@ -107,7 +107,7 @@ public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentE
throw new IllegalArgumentException("No null portlet id accepted");
}
String portletId = portletContext.getId();
PortletImpl portlet = (PortletImpl)portlets.get(portletId);
PortletImpl portlet = portlets.get(portletId);
if (portlet == null)
{
throw new NoSuchPortletException(portletId);
Expand Down Expand Up @@ -153,13 +153,13 @@ else if (e instanceof RuntimeException)

public PropertyMap getProperties(PortletContext portletContext, Set<String> keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
PortletImpl portlet = portlets.get(portletContext.getId());
if (portlet == null)
{
throw new NoSuchPortletException(portletContext.getId());
}
ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
ContainerPreferencesInfo prefs = info.getPreferences();
PropertyMap result = new SimplePropertyMap();
for (String key : keys)
{
Expand All @@ -174,13 +174,13 @@ public PropertyMap getProperties(PortletContext portletContext, Set<String> keys

public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
PortletImpl portlet = portlets.get(portletContext.getId());
if (portlet == null)
{
throw new NoSuchPortletException(portletContext.getId());
}
ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
ContainerPreferencesInfo prefs = info.getPreferences();
PropertyMap result = new SimplePropertyMap();
for (String key : prefs.getKeys())
{
Expand Down

0 comments on commit 1d437df

Please sign in to comment.