-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][client] Add support for loading non-serializable properties with ConsumerBuilder::loadConf #18344
base: master
Are you sure you want to change the base?
Conversation
d9c93a1
to
f7ef902
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch adds value.
The only downside is that in case we add a new non serialisable field we will have to add it to this list
pulsar-client/src/test/java/org/apache/pulsar/client/impl/ConsumerBuilderImplTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach generally makes sense since something like a messageListener
would not be expected to be "deep copied".
configurationData.setNegativeAckRedeliveryBackoff(negativeAckRedeliveryBackoff); | ||
configurationData.setAckTimeoutRedeliveryBackoff(ackTimeoutRedeliveryBackoff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth just making these two (and some of the others) serializable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardest part is making them work with Jackson. Not sure it's possible for RedeliveryBackoff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe RB can be serialized by configuring a mix-in (on the mapper) that provides a json creator constructor for RB. Not saying that it is ideal, just that it can be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RB being an interface. I'm not sure it can be done. How to decide which impl to use ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we could use @JsonTypeInfo
+ @JsonSubTypes
in a mix-in. This would work well as long as we know about all of the RB impls.
NOTE: Whatever we do for RB could apply to the ClientConfigurationData.authentication
as it also currently ignored and is also an interface. There may be other fields as well.
2d7b1f6
to
4b6b973
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #18344 +/- ##
============================================
+ Coverage 43.96% 45.85% +1.89%
+ Complexity 10358 10117 -241
============================================
Files 757 697 -60
Lines 72773 68044 -4729
Branches 7818 7285 -533
============================================
- Hits 31993 31203 -790
+ Misses 37104 33259 -3845
+ Partials 3676 3582 -94
Flags with carried forward coverage won't be shown. Click here to find out more.
|
4b6b973
to
98e6e37
Compare
The pr had no activity for 30 days, mark with Stale label. |
Motivation
Currently
ConsumerBuilder::loadConf
resets non-serializable ofConsumerConfigurationData
tonull
.It would be useful that
ConsumerBuilder::loadConf
supports loading non-serializable fields.An alternative is to not modify fields not present in the property map in
ConfigurationDataUtils::loadData
as proposed by #13298 . This PR is for discussion.Modifications
In
ConsumerBuilder::loadConf
, save values for each non-serializable property and apply it after callingConfigurationDataUtils::loadData
Verifying this change
This change added tests and can be verified as follows:
ConsumerBuilderImplTest::testLoadConf
andConsumerBuilderImplTest::testLoadConfNotModified
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: cbornet#7