polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [48/50] [abbrv] zest-qi4j git commit: Prevent deadlock situation in applyChanges.
Date Fri, 17 Apr 2015 16:06:08 GMT
Prevent deadlock situation in applyChanges.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/ba0b2064
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/ba0b2064
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/ba0b2064

Branch: refs/heads/master
Commit: ba0b2064527416320af21ed430295118a69d1961
Parents: 4da4e22
Author: Arvid Huss <arvid.huss@jayway.com>
Authored: Tue Apr 23 13:51:27 2013 +0200
Committer: Arvid Huss <arvid.huss@jayway.com>
Committed: Tue Apr 23 13:51:27 2013 +0200

----------------------------------------------------------------------
 .../ConcurrentModificationCheckConcern.java     | 53 +++++++++++---------
 1 file changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/ba0b2064/core/spi/src/main/java/org/qi4j/spi/entitystore/ConcurrentModificationCheckConcern.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/qi4j/spi/entitystore/ConcurrentModificationCheckConcern.java
b/core/spi/src/main/java/org/qi4j/spi/entitystore/ConcurrentModificationCheckConcern.java
index f6599f5..8c3e22c 100644
--- a/core/spi/src/main/java/org/qi4j/spi/entitystore/ConcurrentModificationCheckConcern.java
+++ b/core/spi/src/main/java/org/qi4j/spi/entitystore/ConcurrentModificationCheckConcern.java
@@ -102,30 +102,37 @@ public abstract class ConcurrentModificationCheckConcern
         {
             lock.writeLock().lock();
 
-            versions.checkForConcurrentModification( loaded, module, currentTime );
-
-            final StateCommitter committer = uow.applyChanges();
-
-            return new StateCommitter()
+            try
             {
-                @Override
-                public void commit()
-                {
-                    committer.commit();
-                    versions.forgetVersions( loaded );
-
-                    lock.writeLock().unlock();
-                }
-
-                @Override
-                public void cancel()
-                {
-                    committer.cancel();
-                    versions.forgetVersions( loaded );
-
-                    lock.writeLock().unlock();
-                }
-            };
+               versions.checkForConcurrentModification( loaded, module, currentTime );
+
+               final StateCommitter committer = uow.applyChanges();
+
+               return new StateCommitter()
+               {
+                   @Override
+                   public void commit()
+                   {
+                       committer.commit();
+                       versions.forgetVersions( loaded );
+
+                       lock.writeLock().unlock();
+                   }
+
+                   @Override
+                   public void cancel()
+                   {
+                       committer.cancel();
+                       versions.forgetVersions( loaded );
+
+                       lock.writeLock().unlock();
+                   }
+               };
+            } catch( EntityStoreException e )
+            {
+               lock.writeLock().unlock();
+               throw e;
+            }
         }
 
         @Override


Mime
View raw message