]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java
Acorn: Fix WriteRunnable.runReally() and other fixes
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / cluster / ClusterSmall.java
index 726071dbecd3c5d5521ba457481dfffc83efaa43..b84d4d51fe84fef82e1dc1f8a63fdb817cf3c82b 100644 (file)
@@ -16,15 +16,16 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
 
+import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.acorn.internal.ClusterChange;
 import org.simantics.acorn.internal.ClusterStream;
 import org.simantics.acorn.internal.ClusterSupport2;
 import org.simantics.acorn.internal.DebugPolicy;
 import org.simantics.db.Resource;
+import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ExternalValueException;
 import org.simantics.db.exception.ValidationException;
-import org.simantics.db.impl.ClusterBase;
 import org.simantics.db.impl.ClusterI;
 import org.simantics.db.impl.ClusterSupport;
 import org.simantics.db.impl.ClusterTraitsBase;
@@ -708,8 +709,7 @@ final public class ClusterSmall extends ClusterImpl {
         }
     }
     @Override
-    public byte[] getValue(int resourceKey, ClusterSupport support)
-    throws DatabaseException {
+    public byte[] getValue(int resourceKey, ClusterSupport support) throws DatabaseException {
         if (DEBUG)
             System.out.println("ClusterSmall.getValue " + resourceKey);
         int resourceIndex = ClusterTraitsBase.getResourceIndexFromResourceKeyNoThrow(resourceKey);
@@ -838,12 +838,11 @@ final public class ClusterSmall extends ClusterImpl {
         return resourceTable.getUsedSize();
     }
 
-    public int getNumberOfResources() {
-        
-        if(proxy) throw new IllegalStateException();
+    public int getNumberOfResources() throws IllegalAcornStateException {
+        if(proxy)
+            throw new IllegalAcornStateException("proxy == true for " + clusterId);
         
         return resourceTable.getUsedSize();
-        
     }
 
     @Override
@@ -1134,7 +1133,13 @@ final public class ClusterSmall extends ClusterImpl {
             });
             return "ClusterSmall[" + getClusterUID() + " - " + getClusterId() + " - " + getNumberOfResources() + " - " + foreignTable.getResourceHashMap().size() + " - " + set.size() + "]";
         } catch (DatabaseException e) {
-            return "ClusterSmall[" + getNumberOfResources() + "]";
+            try {
+                return "ClusterSmall[" + getNumberOfResources() + "]";
+            } catch (IllegalAcornStateException e1) {
+                Logger.defaultLogError(e1);
+                e1.printStackTrace();
+                return "An exception occured!!";
+            }
         }
     }