_Platform:_
openjdk version "11.0.2" 2019-01-15_IDE:_
IntelliJ IDEA 2020.2.3 (Ultimate Edition)_Build system:_
6.7_Android Gradle Plugin:_
_Sentry Android Gradle Plugin:_
_Proguard/R8:_
_Platform installed with:_
The version of the SDK:
3.1.3
I have the following issue:
Sentry does not load sentry.properties from disk by default if the file is in the root directory with the application.
Adding the system property to tell sentry where the file is located is required to load the properties file.
System.setProperty("sentry.properties.file", "sentry.properties");
Sentry.init(options -> {
options.setEnableExternalConfiguration(true);
});
Steps to reproduce:
Place properties file in working directory with application when using external configuration.
Actual result:
Exception in thread "main" java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at io.sentry.Sentry.initConfigurations(Sentry.java:183)
at io.sentry.Sentry.init(Sentry.java:153)
at io.sentry.Sentry.init(Sentry.java:124)
at io.sentry.Sentry.init(Sentry.java:110)
Expected result:
Works as before with version 1 and auto detects the file.
thanks for raising this.
I think it tries to read by default from the ClassLoader, cc @maciejwalkowiak to confirm.
As @marandaneto said, by default it tries to load a file from the root of the classpath. Now I see that in 1.7.x in addition to that it did look into the root directory. I'll prepare a fix for that.
not sure if it's documented already, but it'd be nice to document which configuration has precedence over others eg file from classpath, then file in the root, system envs, etc... otherwise, they will overwrite each other and it'll be hard to find out.
It is in Javadocs: https://getsentry.github.io/sentry-java/io/sentry/config/PropertiesProviderFactory.html#create-- but not in the reference docs. I'll add there too.
yeah worth adding it, this question also came thru different channels, thanks.
Gonna be released on the next version :)