Skip to content

fix(FileWatcher): gracefully handle inotify instance exhaustion#679

Merged
Bkm016 merged 1 commit intoTabooLib:dev/6.2.3from
Score2:fix/filewatcher-inotify-exhaustion
Mar 28, 2026
Merged

fix(FileWatcher): gracefully handle inotify instance exhaustion#679
Bkm016 merged 1 commit intoTabooLib:dev/6.2.3from
Score2:fix/filewatcher-inotify-exhaustion

Conversation

@Score2
Copy link
Copy Markdown
Contributor

@Score2 Score2 commented Mar 16, 2026

Problem

On Linux, when the OS inotify instance limit is reached (fs.inotify.max_user_instances), FileWatcher constructor throws a RuntimeException, causing ExceptionInInitializerError during <clinit>. Since JVM permanently marks the class as failed after a <clinit> error, FileWatcher.INSTANCE becomes inaccessible for the entire ClassLoader lifetime.

This causes ConfigLoader to crash mid-visit before writing to files[name], so all subsequent @ConfigNode fields report "xxx.yml not defined" — affecting every plugin with autoReload = true loaded after the limit is hit.

Fix

  • Catch IOException in FileWatcher(int) constructor; set watchService = null and emit a PrimitiveIO.warning instead of throwing
  • Skip scheduler registration and DISABLE lifecycle callback when watchService is null
  • addSimpleListener returns early (no-op) when watchService is null
  • INSTANCE is always a valid object (degraded mode), so callers are unaffected

…shing

When the OS inotify instance limit is reached, FileWatcher constructor
threw RuntimeException causing ExceptionInInitializerError on <clinit>.
This permanently broke FileWatcher.INSTANCE for the ClassLoader lifetime,
causing ConfigLoader to crash before registering config files, which then
triggered false "@ConfigNode file not defined" warnings for all plugins
using autoReload=true on the same server.

- Catch IOException in constructor, set watchService=null with a warning
- Skip scheduling and DISABLE callback when watchService is null
- addSimpleListener is a no-op when watchService is null
- INSTANCE is always a valid (possibly degraded) object
@Bkm016 Bkm016 merged commit fbdf5a4 into TabooLib:dev/6.2.3 Mar 28, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants