]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java
Disable parallel graph.tg/header read, serializer ctor not thread-safe
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / PlatformUtil.java
index fde15003643668c33548125195e17b199874a6cb..9dfa67efef7be394081c583f325b09ed63dfea4e 100644 (file)
@@ -315,7 +315,11 @@ public class PlatformUtil {
                AtomicReference<IOException> problem = new AtomicReference<>();
 
                Collection<GraphBundle> 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,9 +392,7 @@ public class PlatformUtil {
        private static GraphBundleEx tryGetOnDemandGraph(Bundle bundle, URL url) throws IOException {
                try {
                        Integer cachedHash = readCachedHash(url);
-                       System.out.println("Read cached hashcode from " + bundle + ": " + cachedHash);
                        if (cachedHash == null)
-//                     if (true)
                                return null;
 
                        Supplier<TransferableGraph1> graphSource = () -> {
@@ -416,22 +418,26 @@ public class PlatformUtil {
                        throw new IOException("Problem loading graph.tg from bundle " + bundle.getSymbolicName(), e);
                }
        }
+       
+       private static FormatHandler<TransferableGraph1> FORMAT_HANDLER = new FormatHandler<TransferableGraph1>() {
+        @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<String, FormatHandler<TransferableGraph1>> handlers = ArrayMap.make(
                        new String[] {
-                                       "graph:1"
+                                       "graph:1",
+                                       "sharedLibrary:1"
                        },
-                       new FormatHandler<TransferableGraph1>() {
-                               @Override
-                               public Binding getBinding() {
-                                       return TransferableGraph1.BINDING;
-                               }
-                               @Override
-                               public TransferableGraph1 process(DataContainer container) throws Exception {
-                                       return (TransferableGraph1) container.content.getValue(TransferableGraph1.BINDING);
-                               }
-                       });
+                       FORMAT_HANDLER,
+                       FORMAT_HANDLER);
 
        private static TransferableGraph1 readTG(InputStream is) throws Exception {
                // For an unknown reason this is totally broken when running the TestSCLOsgi