From c52bf8a84f74dd22f49ca1c6e5443720c2d0ac3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 8 Jun 2018 14:10:30 +0300 Subject: [PATCH] Prevent NPE if the path to the module source cannot be found gitlab #18 Change-Id: Iac92cfae81f8caffa5c8dfba129e3e9868801e82 --- .../simantics/scl/osgi/internal/BundleModuleSource.java | 7 ++++++- bundles/org.simantics.scl.runtime/scl/Prelude.scl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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] -- 2.43.2