Skip to content

Commit

Permalink
fixup! fix(file.util): avoid inotify problems in containers by using …
Browse files Browse the repository at this point in the history
…polling over FileWatcher
  • Loading branch information
pichlermarc committed Apr 25, 2024
1 parent 47843bc commit c2dc59d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/src/main/java/com/dynatrace/file/util/FilePollerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@ class FilePollerFactory {
private FilePollerFactory() {}

/**
* Creates the default {@link FilePoller} based on the current OS.
* Creates the default {@link FilePoller}.
*
* @implNote This method may choose to use a {@link java.nio.file.WatchService}-based implementation
* which can be problematic when used in conjunction with container bind-mounts. If the resulting {@link FilePoller}
* will be used in such a manner, consider using {@link FilePollerFactory#getPollBased(String, Duration)}.
*
* @implNote On Linux and Windows, * the poll mechanism is based on the {@link
* java.nio.file.WatchService WatchService}. For macOS, * where there is no native
* implementation for the {@link java.nio.file.WatchService WatchService} * bindings, this
* method provides a {@link PollBasedFilePoller}, which polls the file of interest *
* periodically (according to the {@code pollInterval}).
* @param fileName The name of the file to be watched.
* @param pollInterval The interval in which the {@link PollBasedFilePoller} polls for changes.
* Only applicable on macOS. Will default to 60s if {@code null} is passed.
* @param pollInterval The interval in which the {@link FilePoller} will update, if applicable. Interval MAY not apply
* to {@link java.nio.file.WatchService} based implementations.
* Will default to 60s if {@code null} is passed.
* @return An object that implements the abstract methods on {@link FilePoller}.
* @throws IOException if the initialization of the {@link WatchServiceBasedFilePoller} is not
* successful.
* @throws IOException if the initialization of the {@link FilePoller} is not successful
*/
static FilePoller getDefault(String fileName, Duration pollInterval) throws IOException {
if (IS_MAC_OS) {
Expand Down

0 comments on commit c2dc59d

Please sign in to comment.