portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bjørn Vidar Remme <bvre...@gmail.com>
Subject JS1.6: PortletActionEvent.fireEvent thread safe?
Date Tue, 01 Nov 2005 18:23:26 GMT
Hi,
  while i was browsing some code in a debug session i noted the following in
PortletActionEvent:
  =====
 /**
* Cache ActionEvent methods to avoid repeated replection
* method lookups.
*/
private static final HashMap eventMethods = new HashMap();
 [CUT]
  protected boolean fireEvent(RunData data, Class deltaClass, Object
deltaValue, String theButton)
{
 [CUT]
String methodKey = getClass().getName()+":"
+theButton+":"+classes[0].getName()
+":"+classes[1].getName();

Method method = (Method)eventMethods.get(methodKey);
if(method == null)
{
method = getClass().getMethod(theButton, classes);
eventMethods.put(methodKey, method);
}

[CUT]
  =====
  Note the static HashMap at the top and the put/get in fireEvent().
 Is it not possible that multiple threads work on this static map at the
same time?
  A HashMap object is not synchronized and according to the JavaDoc:
''' If multiple threads access this map concurrently, and at least one of
the threads modifies the map structurally, it must be synchronized
externally.'''
  - Bjørn Vidar Remme

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message