Skip to content

Conversation

@sungshik
Copy link
Contributor

@sungshik sungshik commented Feb 21, 2025

This PR makes a few changes to the existing code, originally made during the implementation of improved overflow support. I isolated them in this separate PR to make reviewing easier. (They would pollute the future improved-overflow-support PR.)

@codecov
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 80.2%. Comparing base (e23a194) to head (c365b4a).
Report is 11 commits behind head on improved-overflow-support-main.

Files with missing lines Patch % Lines
...c/main/java/engineering/swat/watch/WatchEvent.java 0.0% 2 Missing ⚠️
.../engineering/swat/watch/impl/jdk/JDKBaseWatch.java 81.8% 1 Missing and 1 partial ⚠️
.../engineering/swat/watch/impl/jdk/JDKFileWatch.java 90.0% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                        Coverage Diff                         @@
##             improved-overflow-support-main     #18     +/-   ##
==================================================================
+ Coverage                              80.0%   80.2%   +0.2%     
- Complexity                               88      90      +2     
==================================================================
  Files                                    11      11             
  Lines                                   415     416      +1     
  Branches                                 41      41             
==================================================================
+ Hits                                    332     334      +2     
- Misses                                   57      59      +2     
+ Partials                                 26      23      -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

@sungshik sungshik left a comment

Choose a reason for hiding this comment

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

Clarifying comments

@sungshik sungshik marked this pull request as ready for review February 21, 2025 15:50
Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

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

Some minor things, but looks good

var kind = translate(jdkKind);
var rootPath = path;
var relativePath = kind == WatchEvent.Kind.OVERFLOW ? Path.of("") : (@Nullable Path)jdkEvent.context();
var relativePath = context == null ? Path.of("") : (Path) context;
Copy link
Member

Choose a reason for hiding this comment

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

this is now moved from the constructor of WatchEvent to the consumer, is that a win?

nit: looks like we could context inside of this definition.

var relativePath = jdkKind == StandardWatchEventKinds.OVERFLOW  ? Path.of("") : (Path)jdkEvent.context();

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is that a win?

Mja, maybe not. It seemed like a good idea at the time to get rid of the @Nullable and simplify the constructor a bit. But reading the consumer code now after the weekend, it's not so nice actually. I'm changing this back! (But keeping the 2-arg constructor in WatchEvent because I'll need it in the next PRs anyway.)

assert !parent.equals(file);

this.internal = new JDKDirectoryWatch(parent, exec, e -> {
if (fileName.equals(e.getRelativePath())) {
Copy link
Member

Choose a reason for hiding this comment

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

what if an overflow happens for the whole directory, we would still need to deal with that event and mark this file as overflow? or is that bugfix happening later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think this will/should be "magically" covered by one of the next PRs. But, we'll need a test to check this. I added a reminder for this to #12.

…WatchEvent` (because having it outside didn't lead to significantly simpler code overall)
@sungshik sungshik merged commit 53f3038 into improved-overflow-support-main Feb 24, 2025
13 checks passed
@sungshik sungshik deleted the improved-overflow-support/scaffolding branch February 24, 2025 08:48
@sungshik sungshik mentioned this pull request Feb 24, 2025
7 tasks
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