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
  while i was browsing some code in a debug session i noted the following in
* Cache ActionEvent methods to avoid repeated replection
* method lookups.
private static final HashMap eventMethods = new HashMap();
  protected boolean fireEvent(RunData data, Class deltaClass, Object
deltaValue, String theButton)
String methodKey = getClass().getName()+":"

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

  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
  - Bjørn Vidar Remme

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