Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Fixed check for volume source being null or empty #1044

Closed
wants to merge 4 commits into from
Closed

Fixed check for volume source being null or empty #1044

wants to merge 4 commits into from

Conversation

piccobit
Copy link

This bug was hidden by the second condition which is normally always false and was only discovered when I disabled the second condition to allow the usage of named volumes which don't start with a '/'.

This bug was hidden by the second condition which is normally always false and was only discovered when I disabled this second condition to allow the usage of named volumes which don't start with a '/'.
Fixed check for source being null or empty
@@ -150,7 +150,7 @@ public JobValidator(final boolean shouldValidateJobHash,
errors.add("Volume path is not absolute: " + path);
continue;
}
if (!isNullOrEmpty(source) && !source.startsWith("/")) {
if (isNullOrEmpty(source) && !source.startsWith("/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this logic wasn't correct before? Wouldn't this now throw an NPE if source is null?

Copy link
Author

@piccobit piccobit Dec 15, 2016

Choose a reason for hiding this comment

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

@rohansingh Ah, yes, you're right! In our use case with the named volume I've removed the second condition completely and also the printing of the source in case of an error!

Copy link
Author

@piccobit piccobit Dec 15, 2016

Choose a reason for hiding this comment

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

Ok, I've separated the checks for the volume source to prevent the NPE and requested another PR.
Apologize the mess, these are my first PRs, I'm more a Gerrit guy. ;-)

@@ -150,7 +150,11 @@ public JobValidator(final boolean shouldValidateJobHash,
errors.add("Volume path is not absolute: " + path);
continue;
}
if (!isNullOrEmpty(source) && !source.startsWith("/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can just change && to ||, but I guess more specific errors can't hurt.

Copy link
Contributor

@davidxia davidxia left a comment

Choose a reason for hiding this comment

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

Could you amend the PR to have just one commit?

@@ -150,7 +150,11 @@ public JobValidator(final boolean shouldValidateJobHash,
errors.add("Volume path is not absolute: " + path);
continue;
}
if (!isNullOrEmpty(source) && !source.startsWith("/")) {
if (isNullOrEmpty(source)) {
Copy link
Member

Choose a reason for hiding this comment

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

it seems like before, a null or empty source was allowed. Now this will cause an error. Am I correct on that and is that change intentional?

Copy link
Author

Choose a reason for hiding this comment

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

@mattnworb I'm preparing another PR adding an option to allow also 'named volumes' and this PR needs the above change.
It would be fine for me if you cancel this PR and my new PR includes the changes above.

Copy link
Member

Choose a reason for hiding this comment

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

@piccobit thanks - it would be helpful to see both changes in context.

@mattnworb
Copy link
Member

we seem to mention in https://github.com/spotify/helios/blob/master/docs/user_manual.md#volumes that the right-hand side of the volume can be left off or empty

@davidxia
Copy link
Contributor

Ah, the original code makes sense then.

@davidxia davidxia closed this Dec 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants