Skip to content

Commit 2fd6b28

Browse files
committed
reduce I/O in the collect() method of the NativeEventCollector.
1 parent 72d5644 commit 2fd6b28

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ public void collect() {
118118
}
119119

120120
final File outboxDir = new File(outboxPath);
121-
if (!outboxDir.isDirectory()) {
122-
options.getLogger().log(SentryLevel.DEBUG, "Outbox path is not a directory: %s", outboxPath);
121+
final File[] files = outboxDir.listFiles();
122+
if (files == null) {
123+
options
124+
.getLogger()
125+
.log(
126+
SentryLevel.DEBUG,
127+
"Outbox path is not a directory or an I/O error occurred: %s",
128+
outboxPath);
123129
return;
124130
}
125-
126-
final File[] files = outboxDir.listFiles((d, name) -> isRelevantFileName(name));
127-
if (files == null || files.length == 0) {
131+
if (files.length == 0) {
128132
options.getLogger().log(SentryLevel.DEBUG, "No envelope files found in outbox.");
129133
return;
130134
}
@@ -134,7 +138,7 @@ public void collect() {
134138
.log(SentryLevel.DEBUG, "Scanning %d files in outbox for native events.", files.length);
135139

136140
for (final File file : files) {
137-
if (!file.isFile()) {
141+
if (!file.isFile() || !isRelevantFileName(file.getName())) {
138142
continue;
139143
}
140144

0 commit comments

Comments
 (0)