Skip to content

Commit cfd11d5

Browse files
Merge branch 'main' into refactor/apply-plugins-per-module [pr-shepherd]
2 parents f8f3432 + 449c56d commit cfd11d5

54 files changed

Lines changed: 1742 additions & 1015 deletions

File tree

Some content is hidden

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

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
fetch-depth: 0
3535
submodules: 'recursive'
3636
- name: Prepare release
37-
uses: getsentry/craft@7a7857552e2cdc08b502de96e6076849c01fba32 # v2.35.0
37+
uses: getsentry/craft@0ff75896d43285ca376c7254e8143bac23acd429 # v2.35.1
3838
env:
3939
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
4040
with:

‎.github/workflows/spring-boot-3-matrix.yml‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ jobs:
7171
- name: Build sample artifacts
7272
run: |
7373
./gradlew \
74-
:sentry-samples:sentry-samples-spring-boot-jakarta:bootJar \
75-
:sentry-samples:sentry-samples-spring-boot-jakarta:testClasses \
7674
:sentry-samples:sentry-samples-spring-boot-webflux-jakarta:bootJar \
7775
:sentry-samples:sentry-samples-spring-boot-webflux-jakarta:testClasses \
7876
:sentry-samples:sentry-samples-spring-boot-jakarta-opentelemetry:bootJar \
@@ -83,12 +81,11 @@ jobs:
8381
:sentry-samples:sentry-samples-spring-jakarta:testClasses \
8482
:sentry-opentelemetry:sentry-opentelemetry-agent:assemble
8583
86-
- name: Test sentry-samples-spring-boot-jakarta
84+
- name: Test sentry-spring-boot-jakarta integration suites
8785
run: |
88-
python3 test/system-test-runner.py test \
89-
--module "sentry-samples-spring-boot-jakarta" \
90-
--agent false \
91-
--auto-init "true"
86+
./gradlew \
87+
:sentry-spring-boot-jakarta:integrationTest \
88+
:sentry-spring-boot-jakarta:integrationTestOtelAgent
9289
9390
- name: Test sentry-samples-spring-boot-webflux-jakarta
9491
run: |

‎.github/workflows/system-tests-backend.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
sample: [ "sentry-samples-spring-boot-jakarta" ]
27+
sample: [ "sentry-samples-spring-boot" ]
2828
agent: [ "false" ]
2929
agent-auto-init: [ "true" ]
3030
include:
31-
- sample: "sentry-samples-spring-boot"
32-
agent: "false"
33-
agent-auto-init: "true"
3431
- sample: "sentry-samples-spring-boot-opentelemetry-noagent"
3532
agent: "false"
3633
agent-auto-init: "true"

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Always remove the first-draw listener after the first frame, even if no layout pass follows it ([#6152](https://github.com/getsentry/sentry-java/pull/6152))
8+
39
## 8.61.1
410

511
### Fixes
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.sentry.gradle
2+
3+
import org.gradle.api.file.ConfigurableFileCollection
4+
import org.gradle.api.tasks.Classpath
5+
import org.gradle.api.tasks.InputFiles
6+
import org.gradle.api.tasks.PathSensitive
7+
import org.gradle.api.tasks.PathSensitivity
8+
import org.gradle.process.CommandLineArgumentProvider
9+
10+
/**
11+
* Tells a test task's JVM where to find the built OpenTelemetry agent and the app to run with it.
12+
*
13+
* The test launches the app in a child JVM, so neither file is on the test classpath. Declaring
14+
* them here makes them task inputs: the test reruns when either changes and depends on the tasks
15+
* that build them.
16+
*/
17+
abstract class ChildJvmTestArguments : CommandLineArgumentProvider {
18+
@get:InputFiles
19+
@get:PathSensitive(PathSensitivity.NONE)
20+
abstract val agentJar: ConfigurableFileCollection
21+
22+
@get:Classpath abstract val appClasspath: ConfigurableFileCollection
23+
24+
override fun asArguments(): List<String> = buildList {
25+
add("-Dsentry.test.agentJar=${agentJar.singleFile.absolutePath}")
26+
if (!appClasspath.isEmpty) {
27+
add("-Dsentry.test.appClasspath=${appClasspath.asPath}")
28+
}
29+
}
30+
}

‎gradle/libs.versions.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ spotless = "8.8.0"
5050
springboot2 = "2.7.18"
5151
springboot3 = "3.5.0"
5252
springboot4 = "4.1.0"
53+
springKafka3 = "3.3.5"
5354
sqldelight = "2.3.2"
5455
vanniktechMavenPublish = "0.30.0"
5556

@@ -224,7 +225,8 @@ springboot3-starter-jdbc = { module = "org.springframework.boot:spring-boot-star
224225
springboot3-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "springboot3" }
225226
springboot3-starter-cache = { module = "org.springframework.boot:spring-boot-starter-cache", version.ref = "springboot3" }
226227
spring-kafka2 = { module = "org.springframework.kafka:spring-kafka", version = "2.8.11" }
227-
spring-kafka3 = { module = "org.springframework.kafka:spring-kafka", version = "3.3.5" }
228+
spring-kafka3 = { module = "org.springframework.kafka:spring-kafka", version.ref = "springKafka3" }
229+
spring-kafka3-test = { module = "org.springframework.kafka:spring-kafka-test", version.ref = "springKafka3" }
228230
spring-kafka4 = { module = "org.springframework.kafka:spring-kafka" }
229231
kafka-clients = { module = "org.apache.kafka:kafka-clients", version = "3.8.1" }
230232
springboot4-otel = { module = "io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter", version.ref = "otelInstrumentation" }

‎sentry-android-core/src/main/java/io/sentry/android/core/internal/util/FirstDrawDoneListener.java‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,15 @@ public void onDraw() {
109109
if (view == null) {
110110
return;
111111
}
112-
// OnDrawListeners cannot be removed within onDraw, so we remove it with a
113-
// GlobalLayoutListener
114-
view.getViewTreeObserver()
115-
.addOnGlobalLayoutListener(
116-
new ViewTreeObserver.OnGlobalLayoutListener() {
117-
@Override
118-
public void onGlobalLayout() {
119-
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
120-
view.getViewTreeObserver().removeOnDrawListener(FirstDrawDoneListener.this);
121-
}
122-
});
112+
// OnDrawListeners cannot be removed within onDraw. Posting the removal instead of waiting for
113+
// the next global layout guarantees it happens, even if no layout pass follows the draw.
114+
mainThreadHandler.post(
115+
() -> {
116+
final ViewTreeObserver observer = view.getViewTreeObserver();
117+
if (observer.isAlive()) {
118+
observer.removeOnDrawListener(this);
119+
}
120+
});
123121
mainThreadHandler.postAtFrontOfQueue(callback);
124122
}
125123

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ import java.io.ByteArrayOutputStream
3838
import java.io.InputStreamReader
3939
import java.util.concurrent.atomic.AtomicReference
4040
import kotlin.test.BeforeTest
41-
import kotlin.test.Ignore
4241
import kotlin.test.Test
4342
import kotlin.test.assertEquals
4443
import kotlin.test.assertNotEquals
4544
import kotlin.test.assertNotNull
4645
import kotlin.test.assertNull
4746
import kotlin.test.assertTrue
47+
import org.awaitility.kotlin.await
4848
import org.junit.runner.RunWith
4949
import org.mockito.kotlin.mock
5050
import org.mockito.kotlin.whenever
@@ -87,6 +87,12 @@ class InternalSentrySdkTest {
8787
}
8888
}
8989

90+
// Sentry.init moves any leftover session.json to previous_session.json on the executor. Wait
91+
// for that to finish, otherwise it can move the session a test has just persisted. Test
92+
// options set sessionFlushTimeoutMillis to 0, so waitPreviousSessionFlush() only polls.
93+
val cache = options.envelopeDiskCache as EnvelopeCache
94+
await.until { cache.waitPreviousSessionFlush() }
95+
9096
capturedEnvelopes.clear()
9197
}
9298

@@ -634,14 +640,6 @@ class InternalSentrySdkTest {
634640
assertThat(activeSession.get().sessionId).isNotEqualTo(oldSid)
635641
}
636642

637-
// Flaky: intermittently fails with FileNotFoundException reading session.json at the
638-
// `sessionFile.reader()` call below, i.e. persistCurrentSession() did not leave a session file
639-
// on disk by the time this test reads it back. Seen across unrelated PRs, e.g.:
640-
// https://scans.gradle.com/s/55fnn6xhtfyfq/tests/task/:sentry-android-core:testReleaseUnitTest/details/io.sentry.android.core.InternalSentrySdkTest/updateSessionForDroppedEventNonTerminating%20flags%20an%20unhandled%20error%20without%20sending%20an%20envelope?top-execution=1
641-
// https://scans.gradle.com/s/ojzzz4yxag7rw/tests/task/:sentry-android-core:testReleaseUnitTest/details/io.sentry.android.core.InternalSentrySdkTest/updateSessionForDroppedEventNonTerminating%20flags%20an%20unhandled%20error%20without%20sending%20an%20envelope?top-execution=1
642-
// Disabling until root-caused; see https://github.com/getsentry/sentry-java/pull/5990 for the
643-
// code under test.
644-
@Ignore("Flaky: intermittently fails to find the persisted session.json, needs root-causing")
645643
@Test
646644
fun `updateSessionForDroppedEventNonTerminating flags an unhandled error without sending an envelope`() {
647645
val fixture = Fixture()

‎sentry-android-core/src/test/java/io/sentry/android/core/internal/util/FirstDrawDoneListenerTest.kt‎

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -113,49 +113,14 @@ class FirstDrawDoneListenerTest {
113113
}
114114

115115
@Test
116-
fun `registerForNextDraw unregister itself after onDraw`() {
116+
fun `registerForNextDraw unregisters itself after onDraw without a layout pass`() {
117117
val view = fixture.getSut()
118118
FirstDrawDoneListener.registerForNextDraw(view, {}, fixture.buildInfo)
119119
assertFalse(fixture.onDrawListeners.isEmpty())
120120

121-
// Does not remove OnDrawListener before onDraw, even if OnGlobalLayout is triggered
122-
view.viewTreeObserver.dispatchOnGlobalLayout()
123-
assertFalse(fixture.onDrawListeners.isEmpty())
124-
125-
// Removes OnDrawListener in the next OnGlobalLayout after onDraw
126-
view.viewTreeObserver.dispatchOnDraw()
127-
view.viewTreeObserver.dispatchOnGlobalLayout()
128-
assertTrue(fixture.onDrawListeners.isEmpty())
129-
}
130-
131-
@Test
132-
fun `OnGlobalLayoutListener is removed after cleanup`() {
133-
val view = fixture.getSut()
134-
135-
// Initialize mOnGlobalLayoutListeners via a dummy add/remove
136-
val dummyGlobalListener = ViewTreeObserver.OnGlobalLayoutListener {}
137-
view.viewTreeObserver.addOnGlobalLayoutListener(dummyGlobalListener)
138-
view.viewTreeObserver.removeOnGlobalLayoutListener(dummyGlobalListener)
139-
140-
// CopyOnWriteArray wraps an internal ArrayList called mData
141-
val copyOnWriteArray: Any = view.viewTreeObserver.getProperty("mOnGlobalLayoutListeners")
142-
val mDataField = copyOnWriteArray.javaClass.getDeclaredField("mData")
143-
mDataField.isAccessible = true
144-
145-
@Suppress("UNCHECKED_CAST")
146-
fun globalLayoutListeners(): ArrayList<*> = mDataField.get(copyOnWriteArray) as ArrayList<*>
147-
148-
assertTrue(globalLayoutListeners().isEmpty())
149-
150-
FirstDrawDoneListener.registerForNextDraw(view, {}, fixture.buildInfo)
151-
152-
// onDraw registers a cleanup OnGlobalLayoutListener
153121
view.viewTreeObserver.dispatchOnDraw()
154-
assertFalse(globalLayoutListeners().isEmpty())
122+
Shadows.shadowOf(Looper.getMainLooper()).idle()
155123

156-
// onGlobalLayout fires the cleanup, which removes both the draw and layout listeners
157-
view.viewTreeObserver.dispatchOnGlobalLayout()
158-
assertTrue(globalLayoutListeners().isEmpty())
159124
assertTrue(fixture.onDrawListeners.isEmpty())
160125
}
161126

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public final class io/sentry/opentelemetry/agent/AgentMarker {
2+
public fun <init> ()V
3+
}
4+

0 commit comments

Comments
 (0)