Skip to content

Commit 0fc13c0

Browse files
committed
Merge branch 'main' into feat/profiling-remove-vendored-code
2 parents c2ae57b + dcc6bbf commit 0fc13c0

File tree

10 files changed

+47
-9
lines changed

10 files changed

+47
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111

1212
- Removed SentryExecutorService limit for delayed scheduled tasks ([#4846](https://github.com/getsentry/sentry-java/pull/4846))
1313
- Fix visual artifacts for the Canvas strategy on some devices ([#4861](https://github.com/getsentry/sentry-java/pull/4861))
14+
- [Config] Trim whitespace on properties path ([#4880](https://github.com/getsentry/sentry-java/pull/4880))
15+
- Only set `DefaultReplayBreadcrumbConverter` if replay is available ([#4888](https://github.com/getsentry/sentry-java/pull/4888))
1416

1517
### Improvements
1618

1719
- Fallback to distinct-id as user.id logging attribute when user is not set ([#4847](https://github.com/getsentry/sentry-java/pull/4847))
1820
- Report Timber.tag() as `timber.tag` log attribute ([#4845](https://github.com/getsentry/sentry-java/pull/4845))
1921
- Session Replay: Add screenshot strategy serialization to RRWeb events ([#4851](https://github.com/getsentry/sentry-java/pull/4851))
22+
- Log why a properties file was not loaded ([#4879](https://github.com/getsentry/sentry-java/pull/4879))
2023

2124
### Dependencies
2225

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,24 @@ static void initializeIntegrationsAndProcessors(
146146
final @NotNull SentryAndroidOptions options,
147147
final @NotNull Context context,
148148
final @NotNull io.sentry.util.LoadClass loadClass,
149-
final @NotNull ActivityFramesTracker activityFramesTracker) {
149+
final @NotNull ActivityFramesTracker activityFramesTracker,
150+
final boolean isReplayAvailable) {
150151
initializeIntegrationsAndProcessors(
151152
options,
152153
context,
153154
new BuildInfoProvider(new AndroidLogger()),
154155
loadClass,
155-
activityFramesTracker);
156+
activityFramesTracker,
157+
isReplayAvailable);
156158
}
157159

158160
static void initializeIntegrationsAndProcessors(
159161
final @NotNull SentryAndroidOptions options,
160162
final @NotNull Context context,
161163
final @NotNull BuildInfoProvider buildInfoProvider,
162164
final @NotNull io.sentry.util.LoadClass loadClass,
163-
final @NotNull ActivityFramesTracker activityFramesTracker) {
165+
final @NotNull ActivityFramesTracker activityFramesTracker,
166+
final boolean isReplayAvailable) {
164167

165168
if (options.getCacheDirPath() != null
166169
&& options.getEnvelopeDiskCache() instanceof NoOpEnvelopeCache) {
@@ -254,8 +257,9 @@ static void initializeIntegrationsAndProcessors(
254257
options.setCompositePerformanceCollector(new DefaultCompositePerformanceCollector(options));
255258
}
256259

257-
if (options.getReplayController().getBreadcrumbConverter()
258-
instanceof NoOpReplayBreadcrumbConverter) {
260+
if (isReplayAvailable
261+
&& options.getReplayController().getBreadcrumbConverter()
262+
instanceof NoOpReplayBreadcrumbConverter) {
259263
options
260264
.getReplayController()
261265
.setBreadcrumbConverter(new DefaultReplayBreadcrumbConverter(options));

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ public static void init(
171171
}
172172

173173
AndroidOptionsInitializer.initializeIntegrationsAndProcessors(
174-
options, context, buildInfoProvider, loadClass, activityFramesTracker);
174+
options,
175+
context,
176+
buildInfoProvider,
177+
loadClass,
178+
activityFramesTracker,
179+
isReplayAvailable);
175180

176181
deduplicateIntegrations(options, isFragmentAvailable, isTimberAvailable);
177182
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class AndroidContinuousProfilerTest {
134134
buildInfoProvider,
135135
loadClass,
136136
activityFramesTracker,
137+
false,
137138
)
138139
// Profiler doesn't start if the folder doesn't exists.
139140
// Usually it's generated when calling Sentry.init, but for tests we can create it manually.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class AndroidOptionsInitializerTest {
117117
if (useRealContext) context else mockContext,
118118
loadClass,
119119
activityFramesTracker,
120+
false,
120121
)
121122
}
122123

@@ -162,6 +163,7 @@ class AndroidOptionsInitializerTest {
162163
buildInfo,
163164
loadClass,
164165
activityFramesTracker,
166+
isReplayAvailable,
165167
)
166168
}
167169

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class AndroidProfilerTest {
136136
buildInfoProvider,
137137
loadClass,
138138
activityFramesTracker,
139+
false,
139140
)
140141
// Profiler doesn't start if the folder doesn't exists.
141142
// Usually it's generated when calling Sentry.init, but for tests we can create it manually.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class AndroidTransactionProfilerTest {
152152
buildInfoProvider,
153153
loadClass,
154154
activityFramesTracker,
155+
false,
155156
)
156157
// Profiler doesn't start if the folder doesn't exists.
157158
// Usually it's generated when calling Sentry.init, but for tests we can create it manually.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class SentryInitProviderTest {
168168
mockContext,
169169
loadClass,
170170
activityFramesTracker,
171+
false,
171172
)
172173

173174
assertFalse(sentryOptions.isEnableNdk)

sentry/src/main/java/io/sentry/config/FilesystemPropertiesLoader.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.io.BufferedInputStream;
66
import java.io.File;
77
import java.io.FileInputStream;
8-
import java.io.IOException;
98
import java.io.InputStream;
109
import java.util.Properties;
1110
import org.jetbrains.annotations.NotNull;
@@ -24,15 +23,25 @@ public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger log
2423
@Override
2524
public @Nullable Properties load() {
2625
try {
27-
final File f = new File(filePath);
26+
final File f = new File(filePath.trim());
2827
if (f.isFile() && f.canRead()) {
2928
try (InputStream is = new BufferedInputStream(new FileInputStream(f))) {
3029
final Properties properties = new Properties();
3130
properties.load(is);
3231
return properties;
3332
}
33+
} else if (!f.isFile()) {
34+
logger.log(
35+
SentryLevel.ERROR,
36+
"Failed to load Sentry configuration since it is not a file or does not exist: %s",
37+
filePath);
38+
} else if (!f.canRead()) {
39+
logger.log(
40+
SentryLevel.ERROR,
41+
"Failed to load Sentry configuration since it is not readable: %s",
42+
filePath);
3443
}
35-
} catch (IOException e) {
44+
} catch (Throwable e) {
3645
logger.log(
3746
SentryLevel.ERROR, e, "Failed to load Sentry configuration from file: %s", filePath);
3847
return null;

sentry/src/test/java/io/sentry/config/FilesystemPropertiesLoaderTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ class FilesystemPropertiesLoaderTest {
2222
assertEquals("some-dsn", properties["dsn"])
2323
}
2424

25+
@Test
26+
fun `returns properties when file has whitespace`() {
27+
val file = folder.newFile("sentry.properties")
28+
file.writeText("dsn=some-dsn", Charset.defaultCharset())
29+
val loader =
30+
FilesystemPropertiesLoader(" " + file.absolutePath + " ", NoOpLogger.getInstance())
31+
val properties = loader.load()
32+
assertNotNull(properties)
33+
assertEquals("some-dsn", properties["dsn"])
34+
}
35+
2536
@Test
2637
fun `returns null when property file not found`() {
2738
val loader =

0 commit comments

Comments
 (0)