Fix producer max pending messages validation inconsistency#284
Conversation
ProducerBuilder.Create validated MaxPendingMessages, but PulsarClient.CreateProducer accepted 0 through ProducerOptions. This allowed an invalid producer configuration to reach the internal send queue, making the behavior inconsistent depending on which API was used to create the producer. Add the missing validation to PulsarClient.CreateProducer and add unit tests for both creation paths.
c1b9d17 to
00032aa
Compare
blankensteiner
left a comment
There was a problem hiding this comment.
Thanks for the PR. Two small corrections and I can merge it :-)
| using DotPulsar.Exceptions; | ||
|
|
||
| [Trait("Category", "Unit")] | ||
| public sealed class PulsarClientProducerValidationTests |
There was a problem hiding this comment.
This class should just be called "PulsarClientTests", otherwise everything is fine :-)
There was a problem hiding this comment.
I can rename that class, but there is already an existing integration test class named PulsarClientTests in this test project. Do you want me to rename the new unit test class and also rename the existing integration class, or would you prefer I keep the current name to avoid duplicate types?
There was a problem hiding this comment.
The convention is that if we have a class called DotPulsar.SomeNamespace.ClassName, then we can find all tests for that class in DotPulsar.Tests.SomeNamespace.ClassNameTests, so if there is already a class with that name, then just add the new tests to that class :-)
| using DotPulsar.Extensions; | ||
|
|
||
| [Trait("Category", "Unit")] | ||
| public sealed class ProducerBuilderTests |
There was a problem hiding this comment.
This class should be moved to the "Internal" namespace :-)
|
Thanks! :-) |
Summary
ProducerBuilder.Create()rejectsMaxPendingMessages = 0, butPulsarClient.CreateProducer(ProducerOptions<TMessage>)did not.This made producer creation behavior inconsistent depending on which API path was used. It also allowed an invalid
configuration to reach the internal send queue, which could hide problems until high-volume or production usage.
Changes
MaxPendingMessages > 0validation inPulsarClient.CreateProducerWhy
Both producer creation APIs should enforce the same contract. Rejecting invalid configuration early is clearer and
prevents subtle runtime issues caused by a zero-capacity pending message limit.
Testing
PulsarClient.CreateProducer(ProducerOptions<TMessage>)ProducerBuilder.Create()