-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fixes #5521 ResourceCollection NPE #5527
Merged
+40
−46
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a1e8375
Fixes #5521 ResourceCollection NPE
gregw 6066574
Fixes #5521 ResourceCollection NPE
gregw 288340a
Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-…
gregw ae4f9f6
Fixes #5521 ResourceCollection NPE
gregw 1acef42
feedback from review
gregw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
Is it possible to get here if there are no resources in the RC?
I thought we prevented that in the constructors.
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.
perhaps not... but I think the EmptyResource is a good safety net in case anything changes.
Although I'm now thinking more fondly of allowing a RC to have directories that don't exist... as we can't prevent them from being deleted anyway.
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.
The addPath method IMHO is problematic:
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.
I agree the javadoc could be improved, but I don't see the problem with the variable return, as that is just what all the different scenarioes that do exist. Specifically if the result is
If I updated the javadoc to say that, then would that be OK?
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.
Makes sense
Yup, agreed.
This makes sense to me, a sub-collection.
But what if the asked for path has hits for both for files and directories (of the same addPath) across the RC?
What does that mean?
Example:
The file /tmp/foo/zed exists
The directory /tmp/bar/zed/ exists
RC of [/tmp/foo, /tmp/bar] is created.
RC.addPath("zed") means what?
Is this case 1?
This is a tough one.
I could argue that the return on this should be another ResourceCollection (of the same size) with each entry being the original RC with the non-existent path tacked on.
But what is the value on either approach?
In both approaches, a user of the Resource would test for exists() on the result and then move on.
But in the second approach, we allow for "potential" resources.
But that only works for directories IMO.
Having potential files across multiple hits would just be extra confusing.
Yeah, I'm not sure there is a perfect solution here.
Yup, this one makes sense too.
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.
@joakime and @janbartel we can only merge directories, we cannot merge files, nor can we merge files with directories nor directories with errors or files with errors.
ResourceCollection is implementing defacto standard directory overlays as done by things like docker and fancy file systems. If you mount layer A on top of layer B, then files in A replace files in B; if you list files then you see the union of files in A & B; if you create a new file it is created in A.
I believe the semantics we have implemented does that.
... and also we are just fixing NPE here, not re-inventing this class :)
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.
The questions still stand.
Even if they are not relevant for this PR, they could lead to filing a new issue and PR.
If you are going to fix the javadoc here, then the javadoc needs to be clear.
So far, your first proposal for the javadoc changes has vague parts (hence the questions).
IMO, If there are known warts, then the javadoc should point out those warts.
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.
OK.
OK.
OK (so long as it is javadoc'ed).
? What do you mean "the non-existent resource of the first collection"??? I'm not in favour of returning something that is known not to exist. The caller should be able to expect consistency: either this method returns something that exists, or it throws an exception.
OK.
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.
@janbartel We have always been able to get resources that do not exist. In fact that is how we can create new resources eg when implementing PUT methods.
I'll update the javadoc.... but remember we have a real NPE here that we need to fix for a 10.0.0 before we go redesigning the entire resource contract.