You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can cause errors based on the current Java version, because at some point between Java 11 and Java 18, the content-type of a local .json file started coming back as application/json instead of content/unknown:
Java version: 11.0.10
path: C:\Users\bcimino\dev\tqa\target\classes\has_comments.json
content type: content/unknown
parse syntax: CONF
== via ConfigFactory.parseFile(C:\Users\bcimino\dev\tqa\target\classes\has_comments.json) ==
{
# C:\Users\bcimino\dev\tqa\target\classes\has_comments.json: 3
# this is a comment
"a" : 5
}
== via ConfigFactory.parseResources(has_comments.json) ==
{
# has_comments.json @ file:/C:/Users/bcimino/dev/tqa/target/classes/has_comments.json: 3
# this is a comment
"a" : 5
}
Java 18
Java version: 18.0.1
path: C:\Users\bcimino\dev\tqa\target\classes\has_comments.json
content type: application/json
parse syntax: CONF
== via ConfigFactory.parseFile(C:\Users\bcimino\dev\tqa\target\classes\has_comments.json) ==
{
# C:\Users\bcimino\dev\tqa\target\classes\has_comments.json: 3
# this is a comment
"a" : 5
}
== via ConfigFactory.parseResources(has_comments.json) ==
com.typesafe.config.ConfigException$Parse: has_comments.json @ file:/C:/Users/bcimino/dev/tqa/target/classes/has_comments.json: 2: Token not allowed in valid JSON: '//'
Workaround
This can be worked around by loading the file "by hand" into a String and using ConfigFactory.parseString().
The text was updated successfully, but these errors were encountered:
brandoncimino
changed the title
ConfigFactory.parseResources() ignores ConfigParseOptions.setSyntax()ConfigFactory.parseResources() overrides ConfigParseOptions.setSyntax()Jul 13, 2022
If Java's
URLConnection.getContentType()
returns one of theapplication/json
,application/hocon
, ortext/x-java-properties
, then that value will override the providedConfigParseOptions.syntax
:config/config/src/main/java/com/typesafe/config/impl/Parseable.java
Lines 236 to 244 in 4458ea9
This can cause errors based on the current Java version, because at some point between Java 11 and Java 18, the
content-type
of a local.json
file started coming back asapplication/json
instead ofcontent/unknown
:Example
Java 11
Java 18
Workaround
This can be worked around by loading the file "by hand" into a
String
and usingConfigFactory.parseString()
.The text was updated successfully, but these errors were encountered: