X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Finternal%2FClusterSupport2.java;h=b1b1e8365f22bd8da329284a344639add33093cd;hp=7cd007ace0f8918a1a191c8fa7ca9abfbff4e392;hb=d9a9d77c7024260e3e3b3a8558ddc84b2a8b99b3;hpb=0144ba232323a0e4f7ec8fe0681a150faafd7caf diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterSupport2.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterSupport2.java index 7cd007ace..b1b1e8365 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterSupport2.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterSupport2.java @@ -8,6 +8,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; import org.simantics.acorn.ClusterManager; +import org.simantics.acorn.exception.AcornAccessVerificationException; +import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.ClusterBase; @@ -82,7 +84,11 @@ public class ClusterSupport2 implements ClusterSupport, IClusterTable { @Override public int getClusterKeyByClusterUIDOrMake(ClusterUID clusterUID) { - return impl.getClusterKeyByClusterUIDOrMakeWithoutMutex(clusterUID); + try { + return impl.getClusterKeyByClusterUIDOrMakeWithoutMutex(clusterUID); + } catch (IllegalAcornStateException | AcornAccessVerificationException e) { + throw new RuntimeException(e); + } } @Override @@ -185,14 +191,16 @@ public class ClusterSupport2 implements ClusterSupport, IClusterTable { } } - public ResourceSegment getResourceSegment(int resourceIndex, ClusterUID clusterUID, long offset, short size) - throws DatabaseException { + public ResourceSegment getResourceSegment(int resourceIndex, ClusterUID clusterUID, long offset, short size) throws DatabaseException { if (DEBUG) System.out.println("DEBUG: getResourceSegment ri=" + resourceIndex + " cid=" + clusterUID + " offset=" + offset + " size=" + size); - org.simantics.db.Database.Session.ResourceSegment t = impl.getResourceSegment(clusterUID.asBytes(), resourceIndex, offset, size); - return new ResourceSegment(t.getValueSize(), t.getSegment()); - + try { + org.simantics.db.Database.Session.ResourceSegment t = impl.getResourceSegment(clusterUID.asBytes(), resourceIndex, offset, size); + return new ResourceSegment(t.getValueSize(), t.getSegment()); + } catch (AcornAccessVerificationException | IllegalAcornStateException e) { + throw new DatabaseException(e); + } } protected byte[] getValueBig(ClusterBase cluster, int resourceIndex, int offset, int length) throws DatabaseException { @@ -202,8 +210,11 @@ public class ClusterSupport2 implements ClusterSupport, IClusterTable { ClusterUID clusterUID = cluster.clusterUID; - return impl.getResourceFile(clusterUID.asBytes(), resourceIndex); - + try { + return impl.getResourceFile(clusterUID.asBytes(), resourceIndex); + } catch (AcornAccessVerificationException | IllegalAcornStateException e) { + throw new DatabaseException(e); + } } protected InputStream getValueStreamBig(ClusterBase cluster, final int resourceIndex, int offset, int length) throws DatabaseException { @@ -247,7 +258,8 @@ public class ClusterSupport2 implements ClusterSupport, IClusterTable { @Override public int read() throws IOException { - if(left <= 0) throw new IllegalStateException(); + if(left <= 0) + throw new IOException("left <= 0 for " + _s); if(offset == _s.bytes.length) { short slen = (short)Math.min(left, IMAX);