Author: mduerig
Date: Mon Sep 30 14:36:03 2013
New Revision: 1527597
URL: http://svn.apache.org/r1527597
Log:
OAK-1053: Deadlock between ChangeProcessor and Session logout
Instead of synchronising SessionDelegate.refreshAtNextAccess() make
RefreshStrategy sufficiently thread safe
Modified:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/RefreshStrategy.java
Modified:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java?rev=1527597&r1=1527596&r2=1527597&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
(original)
+++
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
Mon Sep 30 14:36:03 2013
@@ -16,8 +16,14 @@
*/
package org.apache.jackrabbit.oak.jcr.delegate;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Lists.newArrayList;
+import static org.apache.jackrabbit.oak.commons.PathUtils.denotesRoot;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+
import java.io.IOException;
import java.util.List;
+
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.jcr.ItemExistsException;
@@ -33,10 +39,10 @@ import org.apache.jackrabbit.oak.api.Que
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
import org.apache.jackrabbit.oak.jcr.security.AccessManager;
import org.apache.jackrabbit.oak.jcr.session.RefreshStrategy;
import org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation;
+import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
import org.apache.jackrabbit.oak.spi.commit.Editor;
import org.apache.jackrabbit.oak.spi.commit.EditorHook;
import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
@@ -51,11 +57,6 @@ import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Lists.newArrayList;
-import static org.apache.jackrabbit.oak.commons.PathUtils.denotesRoot;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-
/**
* TODO document
*/
@@ -91,8 +92,8 @@ public class SessionDelegate {
this.idManager = new IdentifierManager(root);
}
- public synchronized void refreshAtNextAccess() {
- refreshStrategy.accept(RefreshStrategy.Once.RESETTING_VISITOR);
+ public void refreshAtNextAccess() {
+ refreshStrategy.refreshAtNextAccess();
}
/**
Modified:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/RefreshStrategy.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/RefreshStrategy.java?rev=1527597&r1=1527596&r2=1527597&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/RefreshStrategy.java
(original)
+++
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/RefreshStrategy.java
Mon Sep 30 14:36:03 2013
@@ -121,6 +121,21 @@ public class RefreshStrategy {
}
/**
+ * Force the next call to {@link #needsRefresh(SessionOperation)} to
return {@code true} for
+ * every {@link Once} strategy in this composite.
+ * <p>
+ * This method is safe for calling concurrently to any other method of
this class.
+ */
+ public void refreshAtNextAccess() {
+ accept(new Visitor() {
+ @Override
+ public void visit(Once strategy) {
+ strategy.reset();
+ }
+ });
+ }
+
+ /**
* Visitor for traversing the composite.
*/
public static class Visitor {
@@ -145,7 +160,7 @@ public class RefreshStrategy {
public static RefreshStrategy NEVER = new Default(false);
/** Value returned from {@code needsRefresh} */
- protected boolean refresh;
+ protected volatile boolean refresh;
/**
* @param refresh value returned from {@code needsRefresh}
@@ -182,14 +197,6 @@ public class RefreshStrategy {
*/
public static class Once extends Default {
- /** Visitor for resetting this refresh strategy */
- public static final Visitor RESETTING_VISITOR = new Visitor() {
- @Override
- public void visit(Once strategy) {
- strategy.reset();
- }
- };
-
/**
* @param enabled whether this refresh strategy is initially enabled
*/