Skip to content

Commit

Permalink
Fix standalone tomcat jndi issue (#3873)
Browse files Browse the repository at this point in the history
* fix standalone tomcat jndi issue

* format

* add changelog entry

* adapt changelog
  • Loading branch information
lbloder authored Nov 12, 2024
1 parent fba10b8 commit 566da76
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

- Using MaxBreadcrumb with value 0 no longer crashes. ([#3836](https://github.com/getsentry/sentry-java/pull/3836))
- Accept manifest integer values when requiring floating values ([#3823](https://github.com/getsentry/sentry-java/pull/3823))
- Fix standalone tomcat jndi issue ([#3873](https://github.com/getsentry/sentry-java/pull/3873))
- Using Sentry Spring Boot on a standalone tomcat caused the following error:
- Failed to bind properties under 'sentry.parsed-dsn' to io.sentry.Dsn

## 7.16.0

Expand Down
6 changes: 3 additions & 3 deletions sentry/src/main/java/io/sentry/Baggage.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static Baggage fromEvent(
final Baggage baggage = new Baggage(options.getLogger());
final SpanContext trace = event.getContexts().getTrace();
baggage.setTraceId(trace != null ? trace.getTraceId().toString() : null);
baggage.setPublicKey(options.getParsedDsn().getPublicKey());
baggage.setPublicKey(options.retrieveParsedDsn().getPublicKey());
baggage.setRelease(event.getRelease());
baggage.setEnvironment(event.getEnvironment());
final User user = event.getUser();
Expand Down Expand Up @@ -405,7 +405,7 @@ public void setValuesFromTransaction(
final @NotNull SentryOptions sentryOptions,
final @Nullable TracesSamplingDecision samplingDecision) {
setTraceId(transaction.getSpanContext().getTraceId().toString());
setPublicKey(sentryOptions.getParsedDsn().getPublicKey());
setPublicKey(sentryOptions.retrieveParsedDsn().getPublicKey());
setRelease(sentryOptions.getRelease());
setEnvironment(sentryOptions.getEnvironment());
setUserSegment(user != null ? getSegment(user) : null);
Expand All @@ -427,7 +427,7 @@ public void setValuesFromScope(
final @Nullable User user = scope.getUser();
final @NotNull SentryId replayId = scope.getReplayId();
setTraceId(propagationContext.getTraceId().toString());
setPublicKey(options.getParsedDsn().getPublicKey());
setPublicKey(options.retrieveParsedDsn().getPublicKey());
setRelease(options.getRelease());
setEnvironment(options.getEnvironment());
if (!SentryId.EMPTY_ID.equals(replayId)) {
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/DsnUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static boolean urlContainsDsnHost(@Nullable SentryOptions options, @Nulla
return false;
}

final @NotNull Dsn dsn = options.getParsedDsn();
final @NotNull Dsn dsn = options.retrieveParsedDsn();
final @NotNull URI sentryUri = dsn.getSentryUri();
final @Nullable String dsnHost = sentryUri.getHost();

Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/RequestDetailsResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public RequestDetailsResolver(final @NotNull SentryOptions options) {

@NotNull
RequestDetails resolve() {
final Dsn dsn = options.getParsedDsn();
final Dsn dsn = options.retrieveParsedDsn();
final URI sentryUri = dsn.getSentryUri();
final String envelopeUrl = sentryUri.resolve(sentryUri.getPath() + "/envelope/").toString();

Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private static boolean initConfigurations(final @NotNull SentryOptions options)
}

// This creates the DSN object and performs some checks
options.getParsedDsn();
options.retrieveParsedDsn();

ILogger logger = options.getLogger();

Expand Down
8 changes: 5 additions & 3 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,15 @@ public void addIntegration(@NotNull Integration integration) {
}

/**
* Evaluates and parses the DSN. May throw an exception if the DSN is invalid.
* Evaluates and parses the DSN. May throw an exception if the DSN is invalid. Renamed from
* `getParsedDsn` as this would cause an error when deploying as WAR to Tomcat due to `JNDI`
* property binding.
*
* @return the parsed DSN or throws if dsn is invalid
*/
@ApiStatus.Internal
@NotNull
Dsn getParsedDsn() throws IllegalArgumentException {
Dsn retrieveParsedDsn() throws IllegalArgumentException {
return parsedDsn.getValue();
}

Expand Down Expand Up @@ -2457,7 +2459,7 @@ public void setEnableScreenTracking(final boolean enableScreenTracking) {
*/
void loadLazyFields() {
getSerializer();
getParsedDsn();
retrieveParsedDsn();
getEnvelopeReader();
getDateProvider();
}
Expand Down

0 comments on commit 566da76

Please sign in to comment.