Skip to content

Commit 6987f73

Browse files
authored
Merge branch 'main' into rz/feat/screenshot-masking
2 parents b85f24e + 382d6c1 commit 6987f73

File tree

8 files changed

+194
-12
lines changed

8 files changed

+194
-12
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
3737

3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # pin@v2
39+
uses: github/codeql-action/init@89a39a4e59826350b863aa6b6252a07ad50cf83e # pin@v2
4040
with:
4141
languages: 'java'
4242

@@ -45,4 +45,4 @@ jobs:
4545
./gradlew buildForCodeQL --no-build-cache
4646
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # pin@v2
48+
uses: github/codeql-action/analyze@89a39a4e59826350b863aa6b6252a07ad50cf83e # pin@v2

.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@63d1636bead951f6e034ed62c2a3610965fef010 # v2
37+
uses: getsentry/craft@41defb379de52e5f0e3943944fa5575b22fb9f92 # v2
3838
env:
3939
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
4040
with:

AGENTS.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding agents when working with code in this repository.
4+
5+
## STOP — Required Reading (Do This First)
6+
7+
Before doing ANYTHING else (including answering questions), you MUST use the Read tool to load these files:
8+
1. `.cursor/rules/coding.mdc`
9+
2. `.cursor/rules/overview_dev.mdc`
10+
11+
Then identify and read any topically relevant `.cursor/rules/*.mdc` files for the area you're working on (e.g., `opentelemetry.mdc` for OTel work, `metrics.mdc` for metrics work). Use the Glob tool on `.cursor/rules/*.mdc` to discover available rule files.
12+
13+
Do NOT skip this step. Do NOT proceed without reading these files first.
14+
15+
## Project Overview
16+
17+
This is the Sentry Java/Android SDK - a comprehensive error monitoring and performance tracking SDK for Java and Android applications. The repository contains multiple modules for different integrations and platforms.
18+
19+
## Build System
20+
21+
The project uses **Gradle** with Kotlin DSL. Key build files:
22+
- `build.gradle.kts` - Root build configuration
23+
- `settings.gradle.kts` - Multi-module project structure
24+
- `buildSrc/` and `build-logic/` - Custom build logic and plugins
25+
- `Makefile` - High-level build commands
26+
27+
## Essential Commands
28+
29+
### Development Workflow
30+
```bash
31+
# Format code and regenerate .api files (REQUIRED before committing)
32+
./gradlew spotlessApply apiDump
33+
34+
# Run all tests and linter
35+
./gradlew check
36+
37+
# Build entire project
38+
./gradlew build
39+
40+
# Create coverage reports
41+
./gradlew jacocoTestReport koverXmlReportRelease
42+
43+
# Generate documentation
44+
./gradlew aggregateJavadocs
45+
```
46+
47+
### Testing
48+
```bash
49+
# Run unit tests for a specific file
50+
./gradlew ':<module>:testDebugUnitTest' --tests="*<file name>*" --info
51+
52+
# Run system tests (requires Python virtual env)
53+
make systemTest
54+
55+
# Run specific test suites
56+
./gradlew :sentry-android-core:testDebugUnitTest
57+
./gradlew :sentry:test
58+
```
59+
60+
### Code Quality
61+
```bash
62+
# Check code formatting
63+
./gradlew spotlessJavaCheck spotlessKotlinCheck
64+
65+
# Apply code formatting
66+
./gradlew spotlessApply
67+
68+
# Update API dump files (after API changes)
69+
./gradlew apiDump
70+
71+
# Dependency updates check
72+
./gradlew dependencyUpdates -Drevision=release
73+
```
74+
75+
### Android-Specific Commands
76+
```bash
77+
# Assemble Android test APKs
78+
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease
79+
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest -DtestBuildType=release
80+
81+
# Run critical UI tests
82+
./scripts/test-ui-critical.sh
83+
```
84+
85+
## Development Workflow Rules
86+
87+
### Planning and Implementation Process
88+
1. **First think through the problem**: Read the codebase for relevant files and propose a plan
89+
2. **Check in before beginning**: Verify the plan before starting implementation
90+
3. **Use todo tracking**: Work through todo items, marking them as complete as you go
91+
4. **High-level communication**: Give high-level explanations of changes made, not step-by-step descriptions
92+
5. **Simplicity first**: Make every task and code change as simple as possible. Avoid massive or complex changes. Impact as little code as possible.
93+
6. **Format and regenerate**: Once done, format code and regenerate .api files: `./gradlew spotlessApply apiDump`
94+
7. **Propose commit**: As final step, git stage relevant files and propose (but not execute) a single git commit command
95+
96+
## Module Architecture
97+
98+
The repository is organized into multiple modules:
99+
100+
### Core Modules
101+
- **`sentry`** - Core Java SDK implementation
102+
- **`sentry-android-core`** - Core Android SDK implementation
103+
- **`sentry-android`** - High-level Android SDK
104+
105+
### Integration Modules
106+
- **Spring Framework**: `sentry-spring*`, `sentry-spring-boot*`
107+
- **Logging**: `sentry-logback`, `sentry-log4j2`, `sentry-jul`
108+
- **Web**: `sentry-servlet*`, `sentry-okhttp`, `sentry-apache-http-client-5`
109+
- **GraphQL**: `sentry-graphql*`, `sentry-apollo*`
110+
- **Android UI**: `sentry-android-fragment`, `sentry-android-navigation`, `sentry-compose`
111+
- **Reactive**: `sentry-reactor`, `sentry-ktor-client`
112+
- **Monitoring**: `sentry-opentelemetry*`, `sentry-quartz`
113+
114+
### Utility Modules
115+
- **`sentry-test-support`** - Shared test utilities
116+
- **`sentry-system-test-support`** - System testing infrastructure
117+
- **`sentry-samples`** - Example applications
118+
- **`sentry-bom`** - Bill of Materials for dependency management
119+
120+
### Key Architectural Patterns
121+
- **Multi-platform**: Supports JVM, Android, and Kotlin Multiplatform (Compose modules)
122+
- **Modular Design**: Each integration is a separate module with minimal dependencies
123+
- **Options Pattern**: Features are opt-in via `SentryOptions` and similar configuration classes
124+
- **Transport Layer**: Pluggable transport implementations for different environments
125+
- **Scope Management**: Thread-safe scope/context management for error tracking
126+
127+
## Development Guidelines
128+
129+
### Code Style
130+
- **Languages**: Java 8+ and Kotlin
131+
- **Formatting**: Enforced via Spotless - always run `./gradlew spotlessApply` before committing
132+
- **API Compatibility**: Binary compatibility is enforced - run `./gradlew apiDump` after API changes
133+
134+
### Testing Requirements
135+
- Write comprehensive unit tests for new features
136+
- Android modules require both unit tests and instrumented tests where applicable
137+
- System tests validate end-to-end functionality with sample applications
138+
- Coverage reports are generated for both JaCoCo (Java/Android) and Kover (KMP modules)
139+
140+
### Contributing Guidelines
141+
1. Follow existing code style and language
142+
2. Do not modify API files (e.g. sentry.api) manually - run `./gradlew apiDump` to regenerate them
143+
3. Write comprehensive tests
144+
4. New features must be **opt-in by default** - extend `SentryOptions` or similar Option classes with getters/setters
145+
5. Consider backwards compatibility
146+
147+
## Useful Resources
148+
149+
- Main SDK documentation: https://develop.sentry.dev/sdk/overview/
150+
- Internal contributing guide: https://docs.sentry.io/internal/contributing/
151+
- Git commit message conventions: https://develop.sentry.dev/engineering-practices/commit-messages/
152+
153+
This SDK is production-ready and used by thousands of applications. Changes should be thoroughly tested and maintain backwards compatibility.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Fix crash when unregistering `SystemEventsBroadcastReceiver` with try-catch block. ([#5106](https://github.com/getsentry/sentry-java/pull/5106))
8+
9+
## 8.33.0
10+
511
### Features
612

713
- Add screenshot masking support using view hierarchy ([#5077](https://github.com/getsentry/sentry-java/pull/5077))

CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CLAUDE.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
## STOP — Required Reading (Do This First)
44

5-
## Project Overview
5+
Before doing ANYTHING else (including answering questions), you MUST use the Read tool to load [AGENTS.md](AGENTS.md) and follow ALL of its instructions, including reading the required `.cursor/rules/*.mdc` files it references.
66

77
This is the Sentry Java/Android SDK - a comprehensive error monitoring and performance tracking SDK for Java and Android applications. The repository contains multiple modules for different integrations and platforms.
88

@@ -173,4 +173,5 @@ When working on these specific areas, read the corresponding cursor rule file fi
173173
- Internal contributing guide: https://docs.sentry.io/internal/contributing/
174174
- Git commit message conventions: https://develop.sentry.dev/engineering-practices/commit-messages/
175175

176-
This SDK is production-ready and used by thousands of applications. Changes should be thoroughly tested and maintain backwards compatibility.
176+
This SDK is production-ready and used by thousands of applications. Changes should be thoroughly tested and maintain backwards compatibility.
177+
Do NOT skip this step. Do NOT proceed without reading these files first.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android.useAndroidX=true
1212
android.experimental.lint.version=8.9.0
1313

1414
# Release information
15-
versionName=8.32.0
15+
versionName=8.33.0
1616

1717
# Override the SDK name on native crashes on Android
1818
sentryAndroidSdkName=sentry.native.android

sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ private void scheduleUnregisterReceiver() {
203203
}
204204

205205
try {
206-
options.getExecutorService().submit(() -> unregisterReceiver());
206+
options.getExecutorService().submit(() -> unregisterReceiver(options));
207207
} catch (RejectedExecutionException e) {
208-
unregisterReceiver();
208+
unregisterReceiver(options);
209209
}
210210
}
211211

212-
private void unregisterReceiver() {
212+
private void unregisterReceiver(final @NotNull SentryAndroidOptions options) {
213213
final @Nullable SystemEventsBroadcastReceiver receiverRef;
214214
try (final @NotNull ISentryLifecycleToken ignored = receiverLock.acquire()) {
215215
isStopped = true;
@@ -218,7 +218,14 @@ private void unregisterReceiver() {
218218
}
219219

220220
if (receiverRef != null) {
221-
context.unregisterReceiver(receiverRef);
221+
try {
222+
context.unregisterReceiver(receiverRef);
223+
} catch (Throwable exception) {
224+
options
225+
.getLogger()
226+
.log(
227+
SentryLevel.ERROR, exception, "Failed to unregister SystemEventsBroadcastReceiver");
228+
}
222229
}
223230
}
224231

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class SystemEventsBreadcrumbsIntegrationTest {
5252
lateinit var shadowActivityManager: ShadowActivityManager
5353

5454
fun getSut(
55+
contextForSut: Context = context,
5556
enableSystemEventBreadcrumbs: Boolean = true,
5657
enableSystemEventBreadcrumbsExtras: Boolean = false,
5758
executorService: ISentryExecutorService = ImmediateExecutorService(),
@@ -64,7 +65,7 @@ class SystemEventsBreadcrumbsIntegrationTest {
6465
this.executorService = executorService
6566
}
6667
return SystemEventsBreadcrumbsIntegration(
67-
context,
68+
contextForSut,
6869
SystemEventsBreadcrumbsIntegration.getDefaultActions().toTypedArray(),
6970
handler,
7071
)
@@ -313,6 +314,20 @@ class SystemEventsBreadcrumbsIntegrationTest {
313314
assertFalse(fixture.options.isEnableSystemEventBreadcrumbs)
314315
}
315316

317+
@Test
318+
fun `Do not crash if receiver already unregistered`() {
319+
val realContext = ApplicationProvider.getApplicationContext<Context>()
320+
val sut = fixture.getSut(realContext)
321+
322+
sut.register(fixture.scopes, fixture.options)
323+
324+
realContext.unregisterReceiver(sut.receiver)
325+
326+
val result = runCatching { sut.onBackground() }
327+
328+
assertFalse(result.isFailure)
329+
}
330+
316331
@Test
317332
fun `when str has full package, return last string after dot`() {
318333
val sut = fixture.getSut()

0 commit comments

Comments
 (0)