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

Be more defensive about provided channelMax values #695

Merged

Conversation

wangqiandeniangniang
Copy link

Proposed Changes

1、format two line align
2、ChannelManager add channelMax < 0 condition, friendly tips

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (correction or otherwise)
  • [x ] Cosmetics (whitespace, appearance)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

If this is a relatively large or complex change, kick off the discussion by
explaining why you chose the solution you did and what alternatives you
considered, etc.

1、format two line align
2、add channelMax < 0 condition, friendly tips
@@ -70,6 +70,8 @@ public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFac


public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector) {
if (channelMax < 0)
throw new IllegalStateException("create ChannelManager: 'channelMax' must be greater or equal to 0.");
Copy link
Member

Choose a reason for hiding this comment

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

IllegalArgumentException seems to be more appropriate for an invalid input argument if you ask me.

Choose a reason for hiding this comment

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

I consider the situation, channelMax should be a positive integer, negative integer is illegal. Is there a better recommendation? thank you for reply.

Copy link
Member

Choose a reason for hiding this comment

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

The recommendation is to use IllegalArgumentException as a more appropriate exception type for invalid arguments.

Choose a reason for hiding this comment

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

Got it, Thanks

Choose a reason for hiding this comment

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

modified and submitted,trouble review code

1、modify IllegalStateException to IllegalArgumentException
@michaelklishin michaelklishin changed the title style: Be more defensive about provided channelMax values Jul 8, 2021
@michaelklishin michaelklishin merged commit ebc3e29 into rabbitmq:main Jul 8, 2021
@michaelklishin
Copy link
Member

Thank you!

@acogoluegnes acogoluegnes added this to the 5.14.0 milestone Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants