fix(FileWatcher): gracefully handle inotify instance exhaustion#679
Open
Score2 wants to merge 1 commit intoTabooLib:dev/6.2.3from
Open
fix(FileWatcher): gracefully handle inotify instance exhaustion#679Score2 wants to merge 1 commit intoTabooLib:dev/6.2.3from
Score2 wants to merge 1 commit intoTabooLib:dev/6.2.3from
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux, when the OS inotify instance limit is reached (
fs.inotify.max_user_instances),FileWatcherconstructor throws aRuntimeException, causingExceptionInInitializerErrorduring<clinit>. Since JVM permanently marks the class as failed after a<clinit>error,FileWatcher.INSTANCEbecomes inaccessible for the entire ClassLoader lifetime.This causes
ConfigLoaderto crash mid-visit before writing tofiles[name], so all subsequent@ConfigNodefields report"xxx.yml not defined"— affecting every plugin withautoReload = trueloaded after the limit is hit.Fix
IOExceptioninFileWatcher(int)constructor; setwatchService = nulland emit aPrimitiveIO.warninginstead of throwingDISABLElifecycle callback whenwatchServiceis nulladdSimpleListenerreturns early (no-op) whenwatchServiceis nullINSTANCEis always a valid object (degraded mode), so callers are unaffected