Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

### Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.jetbrains.annotations.NotNull;
Expand All @@ -24,7 +23,7 @@ public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger log
@Override
public @Nullable Properties load() {
try {
final File f = new File(filePath);
final File f = new File(filePath.trim());
if (f.isFile() && f.canRead()) {
try (InputStream is = new BufferedInputStream(new FileInputStream(f))) {
final Properties properties = new Properties();
Expand All @@ -42,7 +41,7 @@ public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger log
"Failed to load Sentry configuration since it is not readable: %s",
filePath);
}
} catch (IOException e) {
} catch (Throwable e) {
logger.log(
SentryLevel.ERROR, e, "Failed to load Sentry configuration from file: %s", filePath);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ class FilesystemPropertiesLoaderTest {
assertEquals("some-dsn", properties["dsn"])
}

@Test
fun `returns properties when file has whitespace`() {
val file = folder.newFile("sentry.properties")
file.writeText("dsn=some-dsn", Charset.defaultCharset())
val loader =
FilesystemPropertiesLoader(" " + file.absolutePath + " ", NoOpLogger.getInstance())
val properties = loader.load()
assertNotNull(properties)
assertEquals("some-dsn", properties["dsn"])
}

@Test
fun `returns null when property file not found`() {
val loader =
Expand Down
Loading