Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in WatchQueueReader #2563

Merged
merged 1 commit into from
Nov 11, 2021
Merged

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Nov 8, 2021

Fix NPE in WatchQueueReader. The NPE would cause the watch queue to stop being watched, and script files will no longer be reloaded when changed.

This seems to occur when files were created and quickly removed within the watched directories. It should resolve #2537 and #2535

Signed-off-by: Jimmy Tanagra <[email protected]>
@jimtng jimtng force-pushed the watchqueuereader-npe branch from 15763d5 to a80bf7d Compare November 8, 2021 06:23
@jimtng jimtng changed the title Fix NPE on WatchQueueReader Fix NPE in WatchQueueReader Nov 8, 2021
@cweitkamp cweitkamp added the bug An unexpected problem or unintended behavior of the Core label Nov 8, 2021
Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the NPE! It is also identified by the null analysis. I think it's a good idea to do the null check because there can be all sorts of native implementation specific weirdness going on after reading the WatchService JavaDocs:

 * <p> The implementation that observes events from the file system is intended
 * to map directly on to the native file event notification facility where
 * available, or to use a primitive mechanism, such as polling, when a native
 * facility is not available. Consequently, many of the details on how events
 * are detected, their timeliness, and whether their ordering is preserved are
 * highly implementation specific. For example, when a file in a watched
 * directory is modified then it may result in a single {@link
 * StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} event in some
 * implementations but several events in other implementations. Short-lived
 * files (meaning files that are deleted very quickly after they are created)
 * may not be detected by primitive implementations that periodically poll the
 * file system to detect changes.

@wborn wborn merged commit 8343703 into openhab:main Nov 11, 2021
@wborn wborn added this to the 3.2 milestone Nov 11, 2021
@jimtng jimtng deleted the watchqueuereader-npe branch November 12, 2021 22:56
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
Signed-off-by: Jimmy Tanagra <[email protected]>
GitOrigin-RevId: 8343703
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenHAB stops watching any files for changes
3 participants