X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FPlatformUtil.java;h=344b2d6cf94a6d43c446ea07bb073ed241fd4507;hb=c2ab38c94029486a379c79a7b38604f1c03afa44;hp=ac08db001142e0b7b8b4131f101bb7e3c0f90d69;hpb=0dfe4ea2175a61a41ffa1e32b64a143076a7d362;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java index ac08db001..344b2d6cf 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; -import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -45,22 +44,20 @@ import org.eclipse.equinox.p2.metadata.VersionedId; import org.osgi.framework.Bundle; import org.simantics.databoard.Bindings; import org.simantics.databoard.adapter.AdaptException; -import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.mutable.Variant; import org.simantics.databoard.container.DataContainer; import org.simantics.databoard.container.DataContainers; -import org.simantics.databoard.container.FormatHandler; import org.simantics.graph.compiler.CompilationResult; import org.simantics.graph.compiler.GraphCompiler; import org.simantics.graph.compiler.GraphCompilerPreferences; import org.simantics.graph.compiler.ValidationMode; import org.simantics.graph.representation.Extensions; import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.graph.representation.TransferableGraphFileReader; import org.simantics.ltk.FileSource; import org.simantics.ltk.ISource; import org.simantics.ltk.Problem; import org.simantics.scl.reflection.OntologyVersions; -import org.simantics.utils.datastructures.ArrayMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -315,7 +312,11 @@ public class PlatformUtil { AtomicReference problem = new AtomicReference<>(); Collection gbundles = Arrays.stream(getBundles()) - .parallel() + // #7806: Due to databoard Binding/Serializer construction process thread-unsafety + // not even the DataContainer.readHeader invocations can run in parallel, most likely + // due to recurring serializer construction for Variant datatypes. + // Therefore, we must disable parallel loading for now. + //.parallel() .map(b -> { try { return problem.get() == null ? getGraph(b) : null; @@ -388,8 +389,10 @@ public class PlatformUtil { private static GraphBundleEx tryGetOnDemandGraph(Bundle bundle, URL url) throws IOException { try { Integer cachedHash = readCachedHash(url); - if (cachedHash == null) + if (cachedHash == null) { + LOGGER.info("No cached hash for " + bundle); return null; + } Supplier graphSource = () -> { try { @@ -414,40 +417,10 @@ public class PlatformUtil { throw new IOException("Problem loading graph.tg from bundle " + bundle.getSymbolicName(), e); } } - - private static FormatHandler FORMAT_HANDLER = new FormatHandler() { - @Override - public Binding getBinding() { - return TransferableGraph1.BINDING; - } - @Override - public TransferableGraph1 process(DataContainer container) throws Exception { - return (TransferableGraph1) container.content.getValue(TransferableGraph1.BINDING); - } - }; - - @SuppressWarnings("unchecked") - private static Map> handlers = ArrayMap.make( - new String[] { - "graph:1", - "sharedLibrary:1" - }, - FORMAT_HANDLER, - FORMAT_HANDLER); - - private static TransferableGraph1 readTG(InputStream is) throws Exception { - // For an unknown reason this is totally broken when running the TestSCLOsgi - // in the SDK Tycho build. It returns incomplete results because the - // ReadableByteChannel used by ByteFileReader starts returning 0 unexpectedly. -// try (TransferableGraphFileReader reader = new TransferableGraphFileReader(is)) { -// return reader.readTG(); -// } - return DataContainers.readFile(new DataInputStream(is), handlers); - } private static TransferableGraph1 readTG(URL url) throws Exception { try (InputStream is = url.openStream()) { - return readTG(is); + return TransferableGraphFileReader.read(is); } }