panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

bug: return error before creating multi pools if lbs is invalid to avoid leaks #317

Closed akshaynanavare closed 6 months ago

akshaynanavare commented 6 months ago

1. Are you opening this pull request for bug-fixs, optimizations or new feature?

Yes, for small optimization of multi pools.

2. Please describe how these code changes achieve your intention.

If lbs is invalid then we should immediately return from NewMultiPool func instead of creating pool arrays and then check for lbs validation

3. Please link to the relevant issues (if any).

NA

4. Which documentation changes (if any) need to be made/updated because of this PR?

NA

4. Checklist

panjf2000 commented 6 months ago

I think you missed https://github.com/panjf2000/ants/blob/dev/multipool_func.go#L56-L58

akshaynanavare commented 6 months ago

I think you missed https://github.com/panjf2000/ants/blob/dev/multipool_func.go#L56-L58

@panjf2000 Yes, Added now. Thanks UT is already there for both of the funcs If you want explicitly to cover this code, I will add

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.30%. Comparing base (5c07bca) to head (7b5ec33). Report is 3 commits behind head on dev.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #317 +/- ## ======================================= Coverage 91.30% 91.30% ======================================= Files 11 11 Lines 759 759 ======================================= Hits 693 693 Misses 45 45 Partials 21 21 ``` | [Flag](https://app.codecov.io/gh/panjf2000/ants/pull/317/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan) | Coverage Ξ” | | |---|---|---| | [unittests](https://app.codecov.io/gh/panjf2000/ants/pull/317/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan) | `91.30% <100.00%> (ΓΈ)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.