Repository: networknt/json-schema-validator (java)
Issue: NullPointerException at com.networknt.schema.JsonSchema.combineCurrentUriWithIds(JsonSchema.java:90)
Here is my code:

```groovy
    def jsonSchema = this.getClass().getClassLoader().getResource("schema/test.json").text
    JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)
    JsonSchema schema = factory.getSchema(jsonSchema)
```

If the schema's `$id` field does not start with a scheme, it will throw a null pointer exception. Here is the full stack trace:

```
java.lang.NullPointerException
	at com.networknt.schema.JsonSchema.combineCurrentUriWithIds(JsonSchema.java:90)
	at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:72)
	at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:58)
	at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:53)
	at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:254)
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:282)
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:290)
```

Here is my test schema:

```json
{
  "$id": "test",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Test description",
  "properties": {
    "test": {
      "description": "Sample property",
      "examples": [
        "hello",
        "world"
      ],
      "type": "string"
    }
  },
  "required": [
    "test"
  ],
  "type": "object"
}
```

It should throw a `JsonSchemaException` instead of a `NullPointerException`, but in `combineCurrentUriWithIds`, `currentUri` will be `null` and therefore `currentUri.toString()` on line 90 will throw a NPE. 

Pull request description: Fix NPE
Closes #347 

Patch:
diff --git a/src/main/java/com/networknt/schema/JsonSchema.java b/src/main/java/com/networknt/schema/JsonSchema.java
index be5bb64..a12b3bd 100644
--- a/src/main/java/com/networknt/schema/JsonSchema.java
+++ b/src/main/java/com/networknt/schema/JsonSchema.java
@@ -95,7 +95,7 @@ public class JsonSchema extends BaseJsonValidator {
             try {
                 return this.validationContext.getURIFactory().create(currentUri, id);
             } catch (IllegalArgumentException e) {
-                throw new JsonSchemaException(ValidationMessage.of(ValidatorTypeCode.ID.getValue(), ValidatorTypeCode.ID, id, currentUri.toString()));
+                throw new JsonSchemaException(ValidationMessage.of(ValidatorTypeCode.ID.getValue(), ValidatorTypeCode.ID, id, currentUri == null ? "null" : currentUri.toString()));
             }
         }
     }


Test patch:
diff --git a/src/test/java/com/networknt/schema/Issue347Test.java b/src/test/java/com/networknt/schema/Issue347Test.java
new file mode 100644
index 0000000..d110d65
--- /dev/null
+++ b/src/test/java/com/networknt/schema/Issue347Test.java
@@ -0,0 +1,22 @@
+package com.networknt.schema;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class Issue347Test {
+
+    @Test
+    public void failure() {
+        ObjectMapper mapper = new ObjectMapper();
+        JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
+        try {
+            JsonSchema schema = factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"));
+        } catch (Throwable e) {
+            assertThat(e, instanceOf(JsonSchemaException.class));
+            assertEquals("test: null is an invalid segment for URI {2}", e.getMessage());
+        }
+    }
+}
diff --git a/src/test/resources/schema/issue347-v7.json b/src/test/resources/schema/issue347-v7.json
new file mode 100644
index 0000000..2ae91c0
--- /dev/null
+++ b/src/test/resources/schema/issue347-v7.json
@@ -0,0 +1,19 @@
+{
+  "$id": "test",
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "description": "Test description",
+  "properties": {
+    "test": {
+      "description": "Sample property",
+      "examples": [
+        "hello",
+        "world"
+      ],
+      "type": "string"
+    }
+  },
+  "required": [
+    "test"
+  ],
+  "type": "object"
+}