-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Code quality - drop while(true) #526
base: master
Are you sure you want to change the base?
Conversation
} | ||
} else { | ||
break; | ||
while (Objects.nonNull(currentParent)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be replaced by
for (Path currentParent = optional.get(); Objects.nonNull(currentParent); currentParent = currentParent.getParent())
Updated the while loop to a for in Also removed the class' constructor as well as some attributes that were not used. Dropped a lambda instantiation as the raw value it returned could be used instead and avoided the use of a stream to create a list where the list could directly be instantiated instead. |
} else if (kind == ENTRY_MODIFY && event.count() > 1) { | ||
watchKey.reset(); | ||
} else { | ||
} else if (kind != ENTRY_MODIFY || (kind == ENTRY_MODIFY && event.count() == 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME: should be && event.count() <= 1
@@ -118,6 +120,7 @@ private void watchPathChanges() { | |||
} | |||
|
|||
List<WatchEvent<?>> watchEvents = watchKey.pollEvents(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pollEvents is not blocking, might want to add a sleep somewhere in here or use a self-scheduling method instead of a loop
Fix #524 and added comments on the loops where a
while(true)
seemed legitimate to justify them.Note that:
FileBrowseServiceImpl.searchDownAndSelect
, I replaced the use of previous by next inif (Objects.isNull(searchFoundItem))
as I could not make sense of the code the way it was.Other than that, old and new code should be strictly equivalent