Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-05-12 09:55:33 +0000
committerCaspar De Groot2011-05-12 09:55:33 +0000
commit0675165fb5d4641d39f6334f527b500ad48e8905 (patch)
treea35f96a68442d6b5c1b6db0e20c15a65e76029d1 /plugins/org.eclipse.emf.cdo.server.hibernate
parent1d51ff38dbbc07736b0486ec6471a15e8bde6f4d (diff)
downloadcdo-0675165fb5d4641d39f6334f527b500ad48e8905.tar.gz
cdo-0675165fb5d4641d39f6334f527b500ad48e8905.tar.xz
cdo-0675165fb5d4641d39f6334f527b500ad48e8905.zip
[Bug 341081] Make loaded revisions immutable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=341081
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java20
2 files changed, 28 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index 6a8d50f2a8..d4dee966ec 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -467,7 +467,14 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
public InternalCDORevision readRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int listChunk,
CDORevisionCacheAdder cache)
{
- return readRevision(id, branchVersion.getBranch().getPoint(System.currentTimeMillis()), listChunk, cache);
+ InternalCDORevision revision = readRevision(id, branchVersion.getBranch().getPoint(System.currentTimeMillis()),
+ listChunk, cache);
+ if (revision != null)
+ {
+ revision.freeze();
+ }
+
+ return revision;
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
index 389ddece8d..a4f0625986 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
@@ -43,6 +43,8 @@ public class WrappedHibernateList implements InternalCDOList
{
private List<Object> delegate;
+ private boolean frozen;
+
public WrappedHibernateList()
{
}
@@ -463,4 +465,22 @@ public class WrappedHibernateList implements InternalCDOList
delegate.set(HibernateUtil.getInstance().getCDOID(o));
}
}
+
+ public void freeze()
+ {
+ frozen = true;
+ }
+
+ private void checkFrozen()
+ {
+ if (frozen)
+ {
+ throw new IllegalStateException("Cannot modify a frozen list");
+ }
+ }
+
+ public void setWithoutFrozenCheck(int i, Object value)
+ {
+ getDelegate().set(i, value);
+ }
}

Back to the top