Skip to content

Commit d6a5897

Browse files
Do not log if sentry.properties in rundir has not been found (#4929)
* Do not log if sentry.properties in rundir has not been found * Format code * changelog --------- Co-authored-by: Sentry Github Bot <[email protected]>
1 parent abfcc92 commit d6a5897

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

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+
- Do not log if `sentry.properties` in rundir has not been found ([#4929](https://github.com/getsentry/sentry-java/pull/4929))
8+
39
## 8.27.0
410

511
### Features

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@
1414
final class FilesystemPropertiesLoader implements PropertiesLoader {
1515
private final @NotNull String filePath;
1616
private final @NotNull ILogger logger;
17+
private boolean logNonExisting;
1718

1819
public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger logger) {
20+
this(filePath, logger, true);
21+
}
22+
23+
public FilesystemPropertiesLoader(
24+
@NotNull String filePath, @NotNull ILogger logger, boolean logNonExisting) {
1925
this.filePath = filePath;
2026
this.logger = logger;
27+
this.logNonExisting = logNonExisting;
2128
}
2229

2330
@Override
@@ -31,10 +38,12 @@ public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger log
3138
return properties;
3239
}
3340
} 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);
41+
if (logNonExisting) {
42+
logger.log(
43+
SentryLevel.ERROR,
44+
"Failed to load Sentry configuration since it is not a file or does not exist: %s",
45+
filePath);
46+
}
3847
} else if (!f.canRead()) {
3948
logger.log(
4049
SentryLevel.ERROR,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class PropertiesProviderFactory {
5858
}
5959

6060
final Properties runDirectoryProperties =
61-
new FilesystemPropertiesLoader("sentry.properties", logger).load();
61+
new FilesystemPropertiesLoader("sentry.properties", logger, false).load();
6262
if (runDirectoryProperties != null) {
6363
providers.add(new SimplePropertiesProvider(runDirectoryProperties));
6464
}

0 commit comments

Comments
 (0)