Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 @@ -38,7 +38,7 @@ public FilesystemPropertiesLoader(@NotNull String filePath, @NotNull ILogger log
logger.log(
SentryLevel.ERROR, "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,16 @@ 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