From: Hannu Niemistö Date: Fri, 8 Jun 2018 11:10:30 +0000 (+0300) Subject: Prevent NPE if the path to the module source cannot be found X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F1826%2F1;p=simantics%2Fplatform.git Prevent NPE if the path to the module source cannot be found gitlab #18 Change-Id: Iac92cfae81f8caffa5c8dfba129e3e9868801e82 (cherry picked from commit c52bf8a84f74dd22f49ca1c6e5443720c2d0ac3a) --- diff --git a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java index af6af0872..fc9799de7 100644 --- a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java +++ b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java @@ -146,7 +146,10 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up @Override public boolean isUpdateable() { try { - return Files.exists(getPath()); + Path path = getPath(); + if(path == null) + return false; + return Files.exists(path); } catch (IOException e) { return false; } @@ -156,6 +159,8 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up public void update(String newSourceText) { try { Path path = getPath(); + if(path == null) + return; Files.write(path, newSourceText.getBytes(Charset.forName("UTF-8"))); } catch(IOException e) { e.printStackTrace(); diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index 4a51875b2..751294a11 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1999,7 +1999,7 @@ importJava "org.simantics.scl.runtime.Lists" where unique :: [a] -> [a] "Like `unique`, but uses the given function for finding the key values used for uniqueness testing." - uniqueBy :: (a -> b) -> [a] -> [a] + uniqueBy :: (a -> b) -> [a] -> [a] "Works like `unique` but uses the given function for equality tests." uniqueWith :: (a -> a -> Boolean) -> [a] -> [a]