Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

[rest.li] Fix race condition in FileStore.get() causing IndexOutOfBoundsException - #1148

Merged
jcleezer merged 2 commits into
linkedin:masterfrom
emilyki:fix-filestore-race-condition
Feb 25, 2026
Merged

[rest.li] Fix race condition in FileStore.get() causing IndexOutOfBoundsException#1148
jcleezer merged 2 commits into
linkedin:masterfrom
emilyki:fix-filestore-race-condition

Conversation

@emilyki

@emilyki emilyki commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace manual file.length() + FileInputStream read loop with Files.readAllBytes() in FileStore.get() to eliminate a TOCTOU race condition where concurrent file modification (e.g., ZooKeeper property sync) causes IndexOutOfBoundsException
  • Add RuntimeException catch in StoreEventPublisher.startPublishing() so unexpected errors still publish a null value instead of propagating uncaught and preventing D2 service discovery initialization

Testing Done

  • Existing FileStoreTest tests pass
  • Verified compilation with ./gradlew :d2:compileJava

@jcleezer jcleezer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jcleezer
jcleezer merged commit fe8ca31 into linkedin:master Feb 25, 2026
1 of 2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants