Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in set operation of a compoposed json-values lens #149

Closed
jlcanales opened this issue Aug 10, 2020 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@jlcanales
Copy link

Version of json-values you are using
json-values version: 8.2.2
JVM version: 11

Describe the bug
When set operation is used on a composed lents, a NullPointerException happens using it over a JsObj where the complete lens path doesn't exist.

To Reproduce
Lens<JsObj, JsObj> calification = JsObj.lens.obj("calification");
Lens<JsObj, Boolean> validated = calification.compose(JsObj.lens.bool("isValidated"));

    JsObj json = validated.set.apply(Boolean.TRUE).apply(JsObj.empty());

The set operation works find when the lens path exists. This is the case:

    Lens<JsObj, JsObj> calification = JsObj.lens.obj("calification");
    Lens<JsObj, Boolean> validated = calification.compose(JsObj.lens.bool("isValidated"));

    JsObj json = validated.set.apply(Boolean.TRUE).apply(JsObj.of("calification", JsObj.empty()));

Expected behavior
Composed lens should works in the same way that a complete path lens. For example:

    Lens<JsObj, Boolean> validated = JsObj.lens.bool(JsPath.path("/calification/isValidated"));
    JsObj json = validated.set.apply(Boolean.TRUE).apply(JsObj.empty());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants