8000 ObjectSchema.getAdditionalPropeties throws NPE on empty object · Issue #12 · everit-org/json-schema · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ObjectSchema.getAdditionalPropeties throws NPE on empty object #12
Closed
@andrejserafim

Description

@andrejserafim

For example

  @Test
  public void validateMetaSchema() {

    JSONObject jsonSchema = new JSONObject(new JSONTokener(
        MetaSchemaTest.class
            .getResourceAsStream("/org/everit/json/schema/json-schema-draft-04.json")));

    JSONObject jsonSubject = new JSONObject("{\n" +
            "  \"type\": \"object\",\n" +
            "  \"properties\": {}\n" +
            "}");

    Schema schema = SchemaLoader.load(jsonSchema);
    schema.validate(jsonSubject);
  }

throws

java.lang.NullPointerException
    at java.util.Arrays.stream(Arrays.java:5004)
    at org.everit.json.schema.ObjectSchema.getAdditionalProperties(ObjectSchema.java:259)
    at org.everit.json.schema.ObjectSchema.testAdditionalProperties(ObjectSchema.java:251)
    at org.everit.json.schema.ObjectSchema.validate(ObjectSchema.java:320)
    at org.everit.json.schema.ObjectSchema.testProperties(ObjectSchema.java:269)
    at org.everit.json.schema.ObjectSchema.validate(ObjectSchema.java:318)
...

This is because JSONObject.getNames(subject) can return null. Do you mind if I raise a PR to fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0