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

Fix standalone tomcat jndi issue #3873

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading