Skip to content

Commit 5bb432e

Browse files
committed
[bugfix] Locks do not need to be acquired for the transaction life-time for permission changes
1 parent 0540047 commit 5bb432e

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/org/exist/security/PermissionFactory.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.exist.storage.lock.Lock.LockMode;
4040
import org.exist.storage.txn.Txn;
4141
import com.evolvedbinary.j8fu.function.ConsumerE;
42-
import org.exist.util.LockException;
4342
import org.exist.util.SyntaxException;
4443
import org.exist.xmldb.XmldbURI;
4544
import org.exist.xquery.XPathException;
@@ -134,8 +133,8 @@ private static void updatePermissions(final DBBroker broker, final Txn transacti
134133

135134
final DocumentImpl doc = lockedDoc.getDocument();
136135

137-
// keep a write lock in the transaction
138-
transaction.acquireDocumentLock(() -> brokerPool.getLockManager().acquireDocumentWriteLock(doc.getURI()));
136+
// // keep a write lock in the transaction
137+
// transaction.acquireDocumentLock(() -> brokerPool.getLockManager().acquireDocumentWriteLock(doc.getURI()));
139138

140139

141140
final Permission permissions = doc.getPermissions();
@@ -144,8 +143,8 @@ private static void updatePermissions(final DBBroker broker, final Txn transacti
144143
broker.storeXMLResource(transaction, doc);
145144
}
146145
} else {
147-
// keep a write lock in the transaction
148-
transaction.acquireCollectionLock(() -> brokerPool.getLockManager().acquireCollectionWriteLock(collection.getURI()));
146+
// // keep a write lock in the transaction
147+
// transaction.acquireCollectionLock(() -> brokerPool.getLockManager().acquireCollectionWriteLock(collection.getURI()));
149148

150149
final Permission permissions = collection.getPermissionsNoLock();
151150
permissionModifier.accept(permissions);
@@ -154,7 +153,7 @@ private static void updatePermissions(final DBBroker broker, final Txn transacti
154153
}
155154
broker.flush();
156155
}
157-
} catch(final XPathException | PermissionDeniedException | IOException | LockException e) {
156+
} catch(final XPathException | PermissionDeniedException | IOException e) {
158157
throw new PermissionDeniedException("Permission to modify permissions is denied for user '" + broker.getCurrentSubject().getName() + "' on '" + pathUri.toString() + "': " + e.getMessage(), e);
159158
}
160159
}

src/org/exist/storage/txn/Txn.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ public long getId() {
8181
return id;
8282
}
8383

84-
/**
85-
* @deprecated Moving a Lock to a Txn is error prone and should not be done
86-
* instead use {@link #acquireLock(Lock, LockMode)} to take a second lock
87-
*/
88-
@Deprecated
89-
public void registerLock(final Lock lock, final LockMode lockMode) {
90-
locksHeld.add(new LockInfo(new Tuple2<>(lock, lockMode), () -> lock.release(lockMode)));
91-
}
92-
9384
public void acquireLock(final Lock lock, final LockMode lockMode) throws LockException {
9485
lock.acquire(lockMode);
9586
locksHeld.add(new LockInfo(new Tuple2<>(lock, lockMode), () -> lock.release(lockMode)));

0 commit comments

Comments
 (0)