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 when parsing values set to null #1

Closed
alfredomusumeci opened this issue Aug 8, 2022 · 0 comments
Closed

NullPointerException when parsing values set to null #1

alfredomusumeci opened this issue Aug 8, 2022 · 0 comments

Comments

@alfredomusumeci
Copy link

alfredomusumeci commented Aug 8, 2022

Hello,

A NullPointerException is thrown whenever a null value is present in a YAML file, more specifically: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "input" is null.

The following is a simple case to reproduce the error:

apiVersion: dummyApi
kind: CustomResourceDefinition
metadata:
  name: null

If I then use the function allFromPath to parse the above YAML file, the error is thrown.

The proposed solution has to do with the method handling the parsing itself, more specifically:

    public static Iterable<YAMLValue> allFromPath(Path path) {
        try (var inputStream = Files.newInputStream(path)) {
            return stream(parser.get().loadAll(inputStream))
                    .map(YAMLValueImpl::new)
                    .collect(Collectors.toList());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

I suppose the error arises from the line YAMLValueImpl:new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant