-
Notifications
You must be signed in to change notification settings - Fork 8
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
Handle absent start file when collecting files #1085
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,15 +41,18 @@ public FileCollection(Supplier<Path> base, PassageFileExtension extension) { | |
this.extensions = extension; | ||
} | ||
|
||
public Collection<Path> get() throws LicensingException { | ||
try (Stream<Path> all = filesIn(base.get())) { | ||
public Collection<Path> get() throws LicensingException, IllegalArgumentException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IllegalArgumentException is RuntimeException is must not be declared as it is a part of interface IllegalArgumentException means development, not runtime error. |
||
try (Stream<Path> all = files(base.get())) { | ||
return filtered(all); | ||
} catch (IOException e) { | ||
throw new LicensingException(BaseMessages.getString("FileCollection.failure"), e); //$NON-NLS-1$ | ||
} | ||
} | ||
|
||
private Stream<Path> filesIn(Path path) throws IOException { | ||
private Stream<Path> files(Path path) throws IOException { | ||
if (!Files.exists(path)) { | ||
throw new IllegalArgumentException("Root of file collection does not exist"); //$NON-NLS-1$ | ||
} | ||
return Files.walk(path) // | ||
.filter(Files::isRegularFile); | ||
} | ||
|
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.
Again, empty set is legal, where incorrect configuration (wrong path) is not.
Supplier must provide existing path, and
LocalConditions
must rely on it.base(LicensedProduct
declaration can benefit from doc mentioning the fact though.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'm not sure if this is really intended? If I understand it correctly in one application multiple different local-conditions can be specified so that a user can choose where to place a license file. For example in
<user-home>/.passage/<path-to-product-version>
or within the installation location.I think it is more user-friend if it is sufficient to choose one location to put the license file into than to be forced to place it into every available location.
If that is the case, it is perfectly legal that for example
UserHomeCondition.base()
method returns a path that does not exists (if the user put the license file into the installation location maybe not even<user-home>/.passage
must exists).And I don't know a better place where to check that. Please suggest one, if you do.
Alternatively the supplier could return an
Optional<Path>
and sub-classes would have to return an empty Optional if the path does not exists. But I suspect that this requires more code since each sub-class where it is not an error if the path is absent has to check the existence in its base() implementation.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.
Condition mining does only mining.
Condition mining cannot do so, when equipped with not-existing path to mine over.
Equip condition mining with existing path and be sure you get all conditions from the location.
There are several
MinedConditions
implementations, each configure existing base path.If you implement custom version of
MinedConditions
on base ofLocalConditions
, just make sure it never gets invalid base path.If you are not ready to guarantee this, you can create your own implementation of pure
MinedConditions
interface and rely on your custom assumptions in it.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.
IMHO it should also be valid and would make sense to mine over a non-existing path and consider it as empty.
I cannot confirm that. For example the
UserHomeResidentConditions
uses paths, that do not necessarily exist (at least I cannot find any code path that ensures the existence).And for example if I launch Passages License-Operator in version 2.4.0-M3 for the very first time, i.e. without having a license file and without having the agreements yet accepted so that
<user-home>/.passage/org.eclipse.passage.loc.operator.product/2.4.0/
does not exist, I get the following errors:IMHO it is valid that for example
<user-home>/.passage/org.eclipse.passage.loc.operator.product/2.4.0/
does not exist at the very first start and I think it would lead to a bad user experience to require that a user has to create those folders manually in advance.And in general the path searched by the
UserHomeResidentConditions
could remain empty if the license file is placed at an alternative location and the product has no agreements. Therefore I think it would be quite inconvenient to require its existence.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.
Have created personal ticket for Passage Operator startup issue: #1088