From c3a0958c94beaaeaeac22cab131f32c0b893c30a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 11 Jun 2019 07:26:55 +1000 Subject: [PATCH] issue 34 - npe reading npm without canonical --- .../src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java | 2 +- .../java/org/hl7/fhir/utilities/cache/PackageCacheManager.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index bc2bf795f..58f7f249b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -271,7 +271,7 @@ import com.google.gson.JsonObject; } public String canonical() { - return npm.get("canonical").getAsString(); + return npm.has("canonical") ? npm.get("canonical").getAsString() : null; } /** diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index 41e580d6d..51ff093c1 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -245,6 +245,9 @@ public class PackageCacheManager { public void recordMap(String url, String id) throws IOException { + if (url == null) + return; + if (!(new File(Utilities.path(cacheFolder, "packages.ini")).exists())) throw new Error("File "+Utilities.path(cacheFolder, "packages.ini")+" not found #1"); IniFile ini = new IniFile(Utilities.path(cacheFolder, "packages.ini"));