Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-01-28 07:28:17 +0000
committerEike Stepper2018-01-28 07:28:17 +0000
commit4ab5ee15ed9887866f87862c81c1e914768ed9c3 (patch)
tree1484e874532feee1b0a9af20793c12b299586533 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view
parentc1582196f77d353afe25b79831bb049493f19bbc (diff)
downloadcdo-4ab5ee15ed9887866f87862c81c1e914768ed9c3.tar.gz
cdo-4ab5ee15ed9887866f87862c81c1e914768ed9c3.tar.xz
cdo-4ab5ee15ed9887866f87862c81c1e914768ed9c3.zip
[528129] Transient objects are attached to CDOTransaction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=528129
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java45
1 files changed, 41 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
index 8f1c1c56c3..5b3ec98b0b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
@@ -42,8 +42,10 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper;
import org.eclipse.emf.internal.cdo.object.CDONotificationBuilder;
+import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.fsm.FiniteStateMachine;
import org.eclipse.net4j.util.fsm.ITransition;
@@ -65,7 +67,9 @@ import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
+import org.eclipse.emf.spi.cdo.InternalCDOView.ViewAndState;
+import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
@@ -86,6 +90,10 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_STATEMACHINE, CDOStateMachine.class);
+ private static final Field NATIVE_VIEW_AND_STATE_FIELD = ReflectUtil.getAccessibleField(CDOObjectImpl.class, "viewAndState");
+
+ private static final Field LEGACY_VIEW_AND_STATE_FIELD = ReflectUtil.getAccessibleField(CDOLegacyWrapper.class, "viewAndState");
+
private InternalCDOObject lastTracedObject;
private CDOState lastTracedState;
@@ -299,15 +307,15 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
// If we have an error, we will keep the graph exactly like it was before.
process(object, CDOEvent.DETACH, objectsToDetach);
- // postDetach requires the object to be TRANSIENT
+ // postDetach() requires the object to be TRANSIENT
for (InternalCDOObject content : objectsToDetach)
{
- CDOState oldState = content.cdoInternalSetState(CDOState.TRANSIENT);
+ CDOState oldState = setStateQuietely(content, CDOState.TRANSIENT);
content.cdoInternalPostDetach(false);
- content.cdoInternalSetState(oldState);
+ setStateQuietely(content, oldState);
}
- // detachObject needs to know the state before we change the object to TRANSIENT
+ // detachObject() needs to know the state before we change the object to TRANSIENT
for (InternalCDOObject content : objectsToDetach)
{
transaction.detachObject(content);
@@ -610,6 +618,35 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
object.cdoInternalSetState(state);
}
+ private CDOState setStateQuietely(InternalCDOObject object, CDOState state)
+ {
+ Field viewAndStateField;
+ if (object instanceof CDOObjectImpl)
+ {
+ viewAndStateField = NATIVE_VIEW_AND_STATE_FIELD;
+ }
+ else if (object instanceof CDOLegacyWrapper)
+ {
+ viewAndStateField = LEGACY_VIEW_AND_STATE_FIELD;
+ }
+ else
+ {
+ return object.cdoInternalSetState(state);
+ }
+
+ try
+ {
+ ViewAndState viewAndState = (ViewAndState)viewAndStateField.get(object);
+ CDOState oldState = viewAndState.state;
+ ReflectUtil.setValue(viewAndStateField, object, viewAndState.getViewAndState(state));
+ return oldState;
+ }
+ catch (Exception ex)
+ {
+ return object.cdoInternalSetState(state);
+ }
+ }
+
private Lock getLock(InternalCDOObject object)
{
InternalCDOView view = object.cdoView();

Back to the top