]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/internal/UndoClusterUpdateProcessor.java
NPE fix for Acorn cluster stream undo handling
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / internal / UndoClusterUpdateProcessor.java
index 8b3e4f066a4e53a6033bc4c9fc8892aacee3f6eb..e75e2e0ceae71ad77da44d013442b6f10a996e11 100644 (file)
@@ -13,17 +13,21 @@ import org.simantics.acorn.lru.ClusterChangeSet.Entry;
 import org.simantics.acorn.lru.ClusterChangeSet.Type;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.service.ClusterUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class UndoClusterUpdateProcessor extends ClusterUpdateProcessorBase {
-       
+
+       private static final Logger LOGGER = LoggerFactory.getLogger(UndoClusterUpdateProcessor.class);
+
        public final static boolean DEBUG = false;
 
        final private ClusterChangeSet ccs;
-       
+
        private int oldValuesIndex = 0;
        private int statementMaskIndex = 0;
-       
-       final public List<Entry> entries = new ArrayList<Entry>();
+
+       final public List<Entry> entries = new ArrayList<>();
        
        public UndoClusterUpdateProcessor(ClusterManager client, ClusterStreamChunk chunk, ClusterChangeSet ccs) throws DatabaseException {
                super(client, readOperation(client, chunk, ccs));
@@ -31,27 +35,8 @@ public class UndoClusterUpdateProcessor extends ClusterUpdateProcessorBase {
        }
        
        private static byte[] readOperation(ClusterManager manager, ClusterStreamChunk chunk, ClusterChangeSet ccs) throws AcornAccessVerificationException, IllegalAcornStateException {
-               
-//             ClusterStreamChunk chunk;
-//             manager.streamLRU.acquireMutex();
-//             try {
-//                     chunk = ccs.getChunk(manager);
-//             } catch (Throwable t) {
-//                     throw new IllegalStateException(t);
-//             } finally {
-//                     manager.streamLRU.releaseMutex();
-//             }
-//
-//             chunk.acquireMutex();
-//             try {
-//             chunk.ve
-                       chunk.makeResident();
-                       return chunk.getOperation(ccs.chunkOffset);
-//             } catch (Throwable t) {
-//                     throw new IllegalStateException(t);
-//             } finally {
-//                     chunk.releaseMutex();
-//             }
+               chunk.makeResident();
+               return chunk.getOperation(ccs.chunkOffset);
        }
        
        @Override
@@ -110,5 +95,10 @@ public class UndoClusterUpdateProcessor extends ClusterUpdateProcessorBase {
                }
 
        }
-       
+
+       @Override
+       void setImmutable(boolean value) {
+               LOGGER.error("Attempted to undo `setImmutable({})` cluster operation for cluster {} which is not supported.", value, ccs.cuid);
+       }
+
 }