[seam-commits] Seam SVN: r8269 - in trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors: feed and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri May 23 10:13:07 EDT 2008


Author: christian.bauer at jboss.com
Date: 2008-05-23 10:13:07 -0400 (Fri, 23 May 2008)
New Revision: 8269

Modified:
   trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/cache/ConnectorCache.java
   trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/FeedAggregatorDAO.java
Log:
Don't throw exception and kill thread on lock aquisition failure

Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/cache/ConnectorCache.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/cache/ConnectorCache.java	2008-05-23 05:22:40 UTC (rev 8268)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/cache/ConnectorCache.java	2008-05-23 14:13:07 UTC (rev 8269)
@@ -18,6 +18,12 @@
 /**
  * Caches lists of stuff and can asynchronously call a connector, upon configurable cache timeout, to
  * refresh these lists.
+ * <p>
+ * All method calls to this application-scoped component are synchronized by Seam. That means you might
+ * get an <tt>IllegalStateException</tt> when an exclusive lock couldn't be aquired by a thread (because
+ * some other thread was already accessing this instance). It's up to the caller to handle that exception,
+ * usually you'd log and swallow it and continue without the result of the cache.
+ * </p>
  *
  * @author Christian Bauer
  */

Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/FeedAggregatorDAO.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/FeedAggregatorDAO.java	2008-05-23 05:22:40 UTC (rev 8268)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/FeedAggregatorDAO.java	2008-05-23 14:13:07 UTC (rev 8269)
@@ -65,13 +65,26 @@
         List<FeedEntryDTO> feedEntries = new ArrayList<FeedEntryDTO>();
 
         for (URL feedURL : feedURLs) {
-            // For each feed, get the feed entries and put them in a sorted collection,
-            // so we get overall sorting
-            log.debug("retrieving feed entries from connector for feed URL: " + feedURL);
-            List<FeedEntryDTO> result = feedConnector.getFeedEntries(feedURL.toString());
-            log.debug("retrieved feed entries: " + result.size());
-            feedEntries.addAll(result);
-            log.debug("number of aggregated feed entries so far: " + feedEntries.size());
+            try {
+                // For each feed, get the feed entries and put them in a sorted collection,
+                // so we get overall sorting
+                log.debug("retrieving feed entries from connector for feed URL: " + feedURL);
+
+                // TODO: This is a synchronized call. This probably means that this is a bottleneck for scalability because
+                // the Seam locking is very coarse-grained. It would be much better if we could aquire exclusive read/write
+                // locks, not just exclusive locks.
+                List<FeedEntryDTO> result = feedConnector.getFeedEntries(feedURL.toString());
+
+                log.debug("retrieved feed entries: " + result.size());
+                feedEntries.addAll(result);
+                log.debug("number of aggregated feed entries so far: " + feedEntries.size());
+
+            } catch (IllegalStateException ex) {
+                // This is most likely (we hope) a message that says that an exlusive read lock couldn't be aquired.
+                // Too bad, we just continue without adding the result... the next user requesting it will probably 
+                // get the lock and then we have the result.
+                log.warn("Illegal state exception thrown by feed connector: " + ex.getMessage());
+            }
         }
 
         Collections.sort(




More information about the seam-commits mailing list