[gatein-commits] gatein SVN: r5162 - portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 18 09:48:40 EST 2010


Author: chris.laprun at jboss.com
Date: 2010-11-18 09:48:39 -0500 (Thu, 18 Nov 2010)
New Revision: 5162

Modified:
   portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
Log:
- GTNWSRP-158, GTNWSRP-161, GTNWSRP-163: Synchronize update of the ProducerInfo since it can be called concurrently when portlet invocations trigger a ProducerInfo refresh.

Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java	2010-11-18 14:45:07 UTC (rev 5161)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java	2010-11-18 14:48:39 UTC (rev 5162)
@@ -68,10 +68,11 @@
    @Override
    protected void save(ProducerInfo info, String messageOnError)
    {
-      ChromatticSession session = persister.getSession();
 
       try
       {
+         ChromatticSession session = persister.getSession();
+
          ProducerInfosMapping pims = getProducerInfosMapping(session);
          ProducerInfoMapping pim = pims.createProducerInfo(info.getId());
          String key = session.persist(pims, pim, info.getId());
@@ -103,18 +104,23 @@
             + "' hasn't been persisted and thus cannot be updated.");
       }
 
-      ChromatticSession session = persister.getSession();
-      ProducerInfoMapping pim = session.findById(ProducerInfoMapping.class, key);
-      if (pim == null)
+      String oldId;
+      String newId;
+      synchronized (this)
       {
-         throw new IllegalArgumentException("Couldn't find ProducerInfoMapping associated with key " + key);
+         ChromatticSession session = persister.getSession();
+         ProducerInfoMapping pim = session.findById(ProducerInfoMapping.class, key);
+         if (pim == null)
+         {
+            throw new IllegalArgumentException("Couldn't find ProducerInfoMapping associated with key " + key);
+         }
+         oldId = pim.getId();
+         newId = producerInfo.getId();
+         pim.initFrom(producerInfo);
+
+         persister.closeSession(true);
       }
-      String oldId = pim.getId();
-      String newId = producerInfo.getId();
-      pim.initFrom(producerInfo);
 
-      persister.closeSession(true);
-
       // if the consumer's id has changed, return the old one so that state can be updated
       return (oldId.equals(newId)) ? null : oldId;
    }



More information about the gatein-commits mailing list