Skip to content
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

Non-final method invocation in constructor #38149

Closed
wants to merge 7 commits into from
Closed

Non-final method invocation in constructor #38149

wants to merge 7 commits into from

Conversation

krisds
Copy link
Contributor

@krisds krisds commented Feb 1, 2019

As requested, I will split #38033 into separate PRs. Here is the first part.

This one resolves:

@colings86 colings86 added the :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs label Feb 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

Thanks @krisds for this PR. I can see the problem in the constructor and your solution looks like it would solve that. However, I would like to propose to do this in a different way: move the offending parts in BlobStoreRepository out of the constructor and into the doStart method instead. This should ensure correct initialization in a simpler way.

Did you look into writing a unit test provoking an issue for this? I suspect, we would not error on bad chunksize settings, that should be relatively easy to provoke.

@krisds
Copy link
Contributor Author

krisds commented Feb 6, 2019

Thanks for the tip, @henningandersen. I'll try a rewrite as suggested.

Any suggestions on where a unit test for this should go ? Any existing unit test I could try to base this on ?

@henningandersen
Copy link
Contributor

I think this new test belongs in BlobStoreRepositoryTests, that class also contains setupRepo that sets up a filesystem like store.

@krisds
Copy link
Contributor Author

krisds commented Feb 6, 2019

I hope this is about what you expected. I'm not familiar enough with the project to make sure the expected test result is correct. It rejects bad values for chunksize, which make some sense to me, but please doublecheck.

Added test case ensuring that compress and chunkSize are not called in
the BlobStoreRepository constructor, since this is unsafe. Plus fixed
testBadChunks to only use illegal chunkSizes for verification.
@henningandersen
Copy link
Contributor

Thanks for your update, looks good. Added one more test and a small correction, have pushed this back to your branch for inclusion into this PR.

@henningandersen
Copy link
Contributor

test this please

@henningandersen
Copy link
Contributor

test this please

@krisds
Copy link
Contributor Author

krisds commented Feb 7, 2019

Looks good to me. Test passes on my machine.

@henningandersen
Copy link
Contributor

@elasticmachine test this please

@ywelsch ywelsch self-requested a review February 11, 2019 08:20
@henningandersen
Copy link
Contributor

I have had a second set of eyes on this and our suggestion is to fix the compress problem by instead passing it into the constructor and moving the compress boolean to the BlobStoreRepository. We should then be able to remove the isCompress method completely. This will furthermore remove the need for the clunky test I added.

@krisds, do you want to carry out this work? If this is larger than what you intended with your contribution, we can also take over this work.

@ywelsch ywelsch removed their request for review February 11, 2019 09:07
@krisds
Copy link
Contributor Author

krisds commented Feb 11, 2019

@henningandersen, I don't mind if you want to take over. It will be a few days before I can get back to this myself anyway. As long as we get a nice fix, I'm happy.

@henningandersen
Copy link
Contributor

@krisds thanks for raising this PR. As agreed above, I have opened a new PR containing the necessary changes here: #39073 . I will therefore close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants