File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package io .sentry .dsn ;
22
33import io .sentry .config .Lookup ;
4+ import io .sentry .util .Util ;
45import org .slf4j .Logger ;
56import org .slf4j .LoggerFactory ;
67
@@ -79,12 +80,12 @@ public Dsn(URI dsn) throws InvalidDsnException {
7980 public static String dsnLookup () {
8081 String dsn = Lookup .lookup ("dsn" );
8182
82- if (dsn == null ) {
83+ if (Util . isNullOrEmpty ( dsn ) ) {
8384 // check if the user accidentally set "dns" instead of "dsn"
8485 dsn = Lookup .lookup ("dns" );
8586 }
8687
87- if (dsn == null ) {
88+ if (Util . isNullOrEmpty ( dsn ) ) {
8889 logger .warn ("*** Couldn't find a suitable DSN, Sentry operations will do nothing!"
8990 + " See documentation: https://docs.sentry.io/clients/java/ ***" );
9091 dsn = DEFAULT_DSN ;
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ public void testDsnLookupWithEnvironmentVariable(@Mocked("getenv") final System
116116 assertThat (Dsn .dsnLookup (), is (dsn ));
117117 }
118118
119+ @ Test
120+ public void testDsnLookupWithEmptyEnvironmentVariable (@ Mocked ("getenv" ) final System system ) throws Exception {
121+ final String dsn = "" ;
122+ new NonStrictExpectations () {{
123+ System .getenv ("SENTRY_DSN" );
124+ result = dsn ;
125+ }};
126+
127+ assertThat (Dsn .dsnLookup (), is (Dsn .DEFAULT_DSN ));
128+ }
129+
119130 @ Test (expectedExceptions = InvalidDsnException .class )
120131 public void testMissingSecretKeyInvalid () throws Exception {
121132 new Dsn ("http://publicKey:@host/9" );
You can’t perform that action at this time.
0 commit comments