jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1196062 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/SessionImpl.java test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java
Date Tue, 01 Nov 2011 15:42:09 GMT
Author: stefan
Date: Tue Nov  1 15:42:08 2011
New Revision: 1196062

URL: http://svn.apache.org/viewvc?rev=1196062&view=rev
Log:
JCR-3131: NPE in ItemManager when calling Session.save() with nothing to save

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=1196062&r1=1196061&r2=1196062&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Tue Nov  1 15:42:08 2011
@@ -806,7 +806,10 @@ public class SessionImpl extends Abstrac
      * {@inheritDoc}
      */
     public void save() throws RepositoryException {
-        perform(new SessionSaveOperation());
+        // JCR-3131: no need to perform save op when there's nothing to save...
+        if (context.getItemStateManager().hasAnyTransientItemStates()) {
+            perform(new SessionSaveOperation());
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java?rev=1196062&r1=1196061&r2=1196062&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/acl/WriteTest.java
Tue Nov  1 15:42:08 2011
@@ -504,4 +504,30 @@ public class WriteTest extends AbstractW
             // success
         }
     }
+    
+    // https://issues.apache.org/jira/browse/JCR-3131
+    public void testEmptySaveNoRootAccess() throws RepositoryException, NotExecutableException
{
+
+        Session s = getTestSession();
+        s.save();
+
+        Privilege[] read = privilegesFromName(Privilege.JCR_READ);
+
+        try {
+            JackrabbitAccessControlList tmpl = getPolicy(acMgr, "/", testUser.getPrincipal());
+            tmpl.addEntry(testUser.getPrincipal(), read, false, getRestrictions(superuser,
path));
+            acMgr.setPolicy(tmpl.getPath(), tmpl);
+            superuser.save();
+
+            // empty save operation
+            s.save();
+        }
+        finally {
+            // undo revocation of read privilege
+            JackrabbitAccessControlList tmpl = getPolicy(acMgr, "/", testUser.getPrincipal());
+            tmpl.addEntry(testUser.getPrincipal(), read, true, getRestrictions(superuser,
path));
+            acMgr.setPolicy(tmpl.getPath(), tmpl);
+            superuser.save();
+        }
+    }
 }
\ No newline at end of file



Mime
View raw message