facebook / wangle

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.
Apache License 2.0
3.04k stars 536 forks source link

Fix bug of PipelineBase::removeHelper #93

Closed EFLql closed 7 years ago

EFLql commented 7 years ago

There is a bug when removeHelper's arguments is handler == nullptr and checkEqual== false.Because std::vecotr<>::erase will return a iterator following the last removed element, In this case the loop should't add it when the function named removeAt has executed.

facebook-github-bot commented 7 years ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

facebook-github-bot commented 7 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

facebook-github-bot commented 7 years ago

@snarkmaster has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

snarkmaster commented 7 years ago

@EFLql, we won't merge this commit as-is because it does not follow the ambient coding style. Please add whitespace around { and } as in the rest of the code.

Additionally, I would put /* no increment */ into the third, now-empty expression of the for loop.

fugalh commented 7 years ago

Good catch. Yeah, this function is kind of a mess. I think this change probably makes it more correct, but I think it's still not very clear and I'm not very confident that there's no bugs.

Can you rewrite it using std::remove_if or similar? http://en.cppreference.com/w/cpp/algorithm/remove http://en.cppreference.com/w/cpp/algorithm

EFLql commented 7 years ago

@fugalh Yeah, it is clear by using std::remove_if.

facebook-github-bot commented 7 years ago

@snarkmaster has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

snarkmaster commented 7 years ago

@EFLql, the unit test no longer passes with your change --

Start 11: PipelineTest
11/19 Test #11: PipelineTest .........................***Exception: Other  0.01 sec
      Start 12: CodecTest