Skip to content

Commit

Permalink
fix: not reuse readers
Browse files Browse the repository at this point in the history
The exporter and the record stream shared the same reader, which caused IndexOutOfBounds exceptions due to concurrent access
  • Loading branch information
ChrisKujawa committed Dec 1, 2021
1 parent abdd511 commit 949804a
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ object EngineFactory {
grpcResponseWriter
)

val reader = logStream.newLogStreamReader().join()
val exporterReader = logStream.newLogStreamReader().join()
val recordStreamReader = logStream.newLogStreamReader().join()

val exporterRunner = ExporterRunner(
exporters = exporters,
reader = { position -> createRecordStream(reader, position) }
reader = { position -> createRecordStream(exporterReader, position) }
)
logStream.registerRecordAvailableListener(exporterRunner::onRecordsAvailable)

Expand All @@ -105,7 +106,7 @@ object EngineFactory {
logStream.close()
scheduler.stop()
},
recordStream = { createRecordStream(reader) },
recordStream = { createRecordStream(recordStreamReader) },
clock = clock
)
}
Expand Down

0 comments on commit 949804a

Please sign in to comment.