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

ConfigException throws NPE when ConfigOrigin is null #367

Open
wsargent opened this issue Jan 15, 2016 · 3 comments
Open

ConfigException throws NPE when ConfigOrigin is null #367

wsargent opened this issue Jan 15, 2016 · 3 comments

Comments

@wsargent
Copy link

If a string is parsed that results in a null ConfigOrigin, then ConfigException will throw NPE.

config 1.3.0:

[error]  java.lang.NullPointerException: null (ConfigException.java:23)
[error] com.typesafe.config.ConfigException.<init>(ConfigException.java:23)
[info]
[error] com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:198)
[error] com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:204)
[error] com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:170)
[error] com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:85)
[error] com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:79)
[error] com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseKey(ConfigDocumentParser.java:283)
[error] com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:397)
[error] com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parse(ConfigDocumentParser.java:595)
[error] com.typesafe.config.impl.ConfigDocumentParser.parse(ConfigDocumentParser.java:14)
[error] com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:260)
[error] com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:248)
[error] com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
[error] com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
[error] com.typesafe.config.impl.Parseable.parse(Parseable.java:299)
[error] com.typesafe.config.ConfigFactory.parseString(ConfigFactory.java:1046)
[error] com.typesafe.config.ConfigFactory.parseString(ConfigFactory.java:1056)

The source is that origin.description is called without a null check.

    protected ConfigException(ConfigOrigin origin, String message,
            Throwable cause) {
        super(origin.description() + ": " + message, cause);
        this.origin = origin;
    }
@aaubert
Copy link

aaubert commented Jan 22, 2016

I have got the same exception when calling ConfigFactory.load().

java.lang.NullPointerException
    at com.typesafe.config.ConfigException.<init>(ConfigException.java:23)
    at com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:198)
    at com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:204)
    at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:170)
    at com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:85)
    at com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:79)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseKey(ConfigDocumentParser.java:283)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:397)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parse(ConfigDocumentParser.java:595)
    at com.typesafe.config.impl.ConfigDocumentParser.parse(ConfigDocumentParser.java:14)
    at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:260)
    at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:248)
    at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
    at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
    at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:307)
    at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:747)
    at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:710)
    at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
    at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
    at com.typesafe.config.impl.Parseable.parse(Parseable.java:152)
    at com.typesafe.config.impl.SimpleIncluder.fromBasename(SimpleIncluder.java:185)
    at com.typesafe.config.impl.ConfigImpl.parseResourcesAnySyntax(ConfigImpl.java:132)
    at com.typesafe.config.ConfigFactory.parseResourcesAnySyntax(ConfigFactory.java:1024)
    at com.typesafe.config.ConfigFactory.parseApplicationConfig(ConfigFactory.java:238)
    at com.typesafe.config.ConfigFactory.defaultApplication(ConfigFactory.java:519)
    at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:305)
    at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:302)
    at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:65)
    at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:92)
    at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:302)
    at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:278)

@aaubert
Copy link

aaubert commented Jan 25, 2016

In ConfigDocumentParser at line 264 and 283, the method PathParser.parsePathNodeExpression is called with a null value for the ConfigOrigin.

@abrighton
Copy link

This bug is still present in version 1.3.2.

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

No branches or pull requests

4 participants