Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

JSON Parsing failure results in NPE #8

Closed
BarDweller opened this issue Oct 8, 2019 · 1 comment
Closed

JSON Parsing failure results in NPE #8

BarDweller opened this issue Oct 8, 2019 · 1 comment
Assignees

Comments

@BarDweller
Copy link

malformed mappings.json entries such as

  "cloudant": {
    "credentials": {
      "searchPatterns": [
        "user-provided:cloudant-test:username",
        "cloudfoundry:cloudant",
        "env:cloudant_credentials",
        "file:/server/localdev-config.json:cloudant_credentials"
      ]
    }
  }

Cause project start up to fail with an NPE

Caused by: java.lang.NullPointerException
    at com.ibm.cloud.spring.env.CloudServicesConfigMap.getValue (CloudServicesConfigMap.java:128)
    at com.ibm.cloud.spring.env.CloudServicesPropertySource.getProperty (CloudServicesPropertySource.java:39)
    at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find (SpringConfigurationPropertySource.java:111)

Seemingly because the code makes an assumption that there will always be an immediate child of a mappings.json entry called searchPatterns and does not test for the situation where that does not exist.

in this case the malformed json has 'credentials' as the child, which means this code
https://github.com/ibm-developer/ibm-cloud-spring-bind/blob/master/src/main/java/com/ibm/cloud/spring/env/CloudServicesConfigMap.java#L127-#L128
fails because 'array' ends up as null causing the NPE.

@gee4vee gee4vee self-assigned this Oct 9, 2019
@gee4vee
Copy link
Contributor

gee4vee commented Oct 11, 2019

Fixed in v1.1.2

@gee4vee gee4vee closed this as completed Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants