You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/04/30 09:45:17 UTC

svn commit: r1477494 - /sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Author: cziegeler
Date: Tue Apr 30 07:45:17 2013
New Revision: 1477494

URL: http://svn.apache.org/r1477494
Log:
SLING-2845 :  ResourceUtil.getOrCreateResource should catch PersistenceException when calling create 

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=1477494&r1=1477493&r2=1477494&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java Tue Apr 30 07:45:17 2013
@@ -574,7 +574,17 @@ public class ResourceUtil {
             if ( autoCommit ) {
                 resolver.refresh();
             }
-            rsrc = resolver.create(parentResource, name, resourceProperties);
+            try {
+                rsrc = resolver.create(parentResource, name, resourceProperties);
+            } catch ( final PersistenceException pe ) {
+                // this could be thrown because someone else tried to create this
+                // node concurrently
+                resolver.refresh();
+                rsrc = resolver.getResource(parentResource, name);
+                if ( rsrc == null ) {
+                    throw pe;
+                }
+            }
             if ( autoCommit ) {
                 try {
                     resolver.commit();