Skip to content

Commit 9492166

Browse files
authored
Merge branch 'main' into markushi/chore/re-apply-7.x.x-changelog
2 parents 9fa1ce6 + 21a214b commit 9492166

File tree

55 files changed

+931
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+931
-304
lines changed

CHANGELOG.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
## Unreleased
44

5-
### Behavioural Changes
6-
7-
- Use `java.net.URI` for parsing URLs in `UrlUtils` ([#4210](https://github.com/getsentry/sentry-java/pull/4210))
8-
- This could affect grouping for issues with messages containing URLs that fall in known corner cases that were handled incorrectly previously (e.g. email in URL path)
9-
105
### Fixes
116

7+
- The SDK now handles `null` on many APIs instead of expecting a non `null` value ([#4245](https://github.com/getsentry/sentry-java/pull/4245))
8+
- Certain APIs like `setTag`, `setData`, `setExtra`, `setContext` previously caused a `NullPointerException` when invoked with either `null` key or value.
9+
- The SDK now tries to have a sane fallback when `null` is passed and no longer throws `NullPointerException`
10+
- If `null` is passed, the SDK will
11+
- do nothing if a `null` key is passed, returning `null` for non void methods
12+
- remove any previous value if the new value is set to `null`
1213
- Add support for setting in-app-includes/in-app-excludes via AndroidManifest.xml ([#4240](https://github.com/getsentry/sentry-java/pull/4240))
1314
- Modifications to OkHttp requests are now properly propagated to the affected span / breadcrumbs ([#4238](https://github.com/getsentry/sentry-java/pull/4238))
1415
- Please ensure the SentryOkHttpInterceptor is added last to your OkHttpClient, as otherwise changes to the `Request` by subsequent interceptors won't be considered
@@ -22,6 +23,11 @@
2223
- Set `sentry.capture-open-telemetry-events=true` in Springs `application.properties` to enable it
2324
- Set `sentry.captureOpenTelemetryEvents: true` in Springs `application.yml` to enable it
2425

26+
### Behavioural Changes
27+
28+
- Use `java.net.URI` for parsing URLs in `UrlUtils` ([#4210](https://github.com/getsentry/sentry-java/pull/4210))
29+
- This could affect grouping for issues with messages containing URLs that fall in known corner cases that were handled incorrectly previously (e.g. email in URL path)
30+
2531
### Internal
2632

2733
- Also use port when checking if a request is made to Sentry DSN ([#4231](https://github.com/getsentry/sentry-java/pull/4231))

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ object Config {
6969
val slf4jJdk14 = "org.slf4j:slf4j-jdk14:1.7.30"
7070
val logbackVersion = "1.2.9"
7171
val logbackClassic = "ch.qos.logback:logback-classic:$logbackVersion"
72+
val logbackCore = "ch.qos.logback:logback-core:$logbackVersion"
7273

7374
val log4j2Version = "2.20.0"
7475
val log4j2Api = "org.apache.logging.log4j:log4j-api:$log4j2Version"
7576
val log4j2Core = "org.apache.logging.log4j:log4j-core:$log4j2Version"
7677

77-
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind"
78+
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind:2.18.3"
7879
val jacksonKotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:2.18.3"
7980

8081
val springBootStarter = "org.springframework.boot:spring-boot-starter:$springBootVersion"

sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class InternalSentrySdkTest {
319319
fun `serializeScope provides fallback app data if none is set`() {
320320
val options = SentryAndroidOptions()
321321
val scope = Scope(options)
322-
scope.setContexts("app", null)
322+
scope.setContexts("app", null as Any?)
323323

324324
val serializedScope = InternalSentrySdk.serializeScope(context, options, scope)
325325
assertTrue(((serializedScope["contexts"] as Map<*, *>)["app"] as Map<*, *>).containsKey("app_name"))

sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/OtelStrongRefSpanWrapper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ public void setThrowable(@Nullable Throwable throwable) {
225225
}
226226

227227
@Override
228-
public void setTag(@NotNull String key, @NotNull String value) {
228+
public void setTag(@Nullable String key, @Nullable String value) {
229229
delegate.setTag(key, value);
230230
}
231231

232232
@Override
233-
public @Nullable String getTag(@NotNull String key) {
233+
public @Nullable String getTag(@Nullable String key) {
234234
return delegate.getTag(key);
235235
}
236236

@@ -240,12 +240,12 @@ public boolean isFinished() {
240240
}
241241

242242
@Override
243-
public void setData(@NotNull String key, @NotNull Object value) {
243+
public void setData(@Nullable String key, @Nullable Object value) {
244244
delegate.setData(key, value);
245245
}
246246

247247
@Override
248-
public @Nullable Object getData(@NotNull String key) {
248+
public @Nullable Object getData(@Nullable String key) {
249249
return delegate.getData(key);
250250
}
251251

@@ -281,7 +281,7 @@ public boolean isNoOp() {
281281
}
282282

283283
@Override
284-
public void setContext(@NotNull String key, @NotNull Object context) {
284+
public void setContext(@Nullable String key, @Nullable Object context) {
285285
delegate.setContext(key, context);
286286
}
287287

sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/OtelTransactionSpanForwarder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ public void setThrowable(@Nullable Throwable throwable) {
152152
}
153153

154154
@Override
155-
public void setTag(@NotNull String key, @NotNull String value) {
155+
public void setTag(@Nullable String key, @Nullable String value) {
156156
rootSpan.setTag(key, value);
157157
}
158158

159159
@Override
160-
public @Nullable String getTag(@NotNull String key) {
160+
public @Nullable String getTag(@Nullable String key) {
161161
return rootSpan.getTag(key);
162162
}
163163

@@ -167,12 +167,12 @@ public boolean isFinished() {
167167
}
168168

169169
@Override
170-
public void setData(@NotNull String key, @NotNull Object value) {
170+
public void setData(@Nullable String key, @Nullable Object value) {
171171
rootSpan.setData(key, value);
172172
}
173173

174174
@Override
175-
public @Nullable Object getData(@NotNull String key) {
175+
public @Nullable Object getData(@Nullable String key) {
176176
return rootSpan.getData(key);
177177
}
178178

@@ -277,7 +277,7 @@ public void finish(
277277
}
278278

279279
@Override
280-
public void setContext(@NotNull String key, @NotNull Object context) {
280+
public void setContext(@Nullable String key, @Nullable Object context) {
281281
// thoughts:
282282
// - span would have to save it on global storage too since we can't add complex data to otel
283283
// span

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/OtelSpanWrapper.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,15 @@ public void setThrowable(@Nullable Throwable throwable) {
330330
}
331331

332332
@Override
333-
public void setTag(@NotNull String key, @NotNull String value) {
333+
public void setTag(@Nullable String key, @Nullable String value) {
334334
context.setTag(key, value);
335335
}
336336

337337
@Override
338-
public @Nullable String getTag(@NotNull String key) {
338+
public @Nullable String getTag(@Nullable String key) {
339+
if (key == null) {
340+
return null;
341+
}
339342
return context.getTags().get(key);
340343
}
341344

@@ -357,12 +360,22 @@ public boolean isFinished() {
357360
}
358361

359362
@Override
360-
public void setData(@NotNull String key, @NotNull Object value) {
361-
data.put(key, value);
363+
public void setData(@Nullable String key, @Nullable Object value) {
364+
if (key == null) {
365+
return;
366+
}
367+
if (value == null) {
368+
data.remove(key);
369+
} else {
370+
data.put(key, value);
371+
}
362372
}
363373

364374
@Override
365-
public @Nullable Object getData(@NotNull String key) {
375+
public @Nullable Object getData(@Nullable String key) {
376+
if (key == null) {
377+
return null;
378+
}
366379
return data.get(key);
367380
}
368381

@@ -422,7 +435,7 @@ public boolean isNoOp() {
422435
}
423436

424437
@Override
425-
public void setContext(@NotNull String key, @NotNull Object context) {
438+
public void setContext(@Nullable String key, @Nullable Object context) {
426439
contexts.put(key, context);
427440
}
428441

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies {
6363
testImplementation(kotlin(Config.kotlinStdLib))
6464
testImplementation(Config.TestLibs.kotlinTestJunit)
6565
testImplementation("ch.qos.logback:logback-classic:1.5.16")
66+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6667
testImplementation(Config.Libs.slf4jApi2)
6768
testImplementation(Config.Libs.apolloKotlin)
6869
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dependencies {
6565
testImplementation(kotlin(Config.kotlinStdLib))
6666
testImplementation(Config.TestLibs.kotlinTestJunit)
6767
testImplementation("ch.qos.logback:logback-classic:1.5.16")
68+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6869
testImplementation(Config.Libs.slf4jApi2)
6970
testImplementation(Config.Libs.apolloKotlin)
7071
}

sentry-samples/sentry-samples-spring-boot-jakarta/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies {
6363
testImplementation(kotlin(Config.kotlinStdLib))
6464
testImplementation(Config.TestLibs.kotlinTestJunit)
6565
testImplementation("ch.qos.logback:logback-classic:1.5.16")
66+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6667
testImplementation(Config.Libs.slf4jApi2)
6768
testImplementation(Config.Libs.apolloKotlin)
6869
testImplementation(projects.sentry)

sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ dependencies {
6363
}
6464
testImplementation(kotlin(Config.kotlinStdLib))
6565
testImplementation(Config.TestLibs.kotlinTestJunit)
66-
testImplementation(Config.Libs.logbackClassic)
66+
testImplementation("ch.qos.logback:logback-classic:1.5.16")
67+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6768
testImplementation(Config.Libs.slf4jApi2)
6869
testImplementation(Config.Libs.apolloKotlin)
6970
testImplementation("org.apache.httpcomponents:httpclient")

0 commit comments

Comments
 (0)