Skip to content

[fix][client] Add support for loading non-serializable properties with ConsumerBuilder::loadConf - #18344

Open
cbornet wants to merge 1 commit into
apache:masterfrom
cbornet:loadconf-apply-non-serializable
Open

[fix][client] Add support for loading non-serializable properties with ConsumerBuilder::loadConf#18344
cbornet wants to merge 1 commit into
apache:masterfrom
cbornet:loadconf-apply-non-serializable

Conversation

@cbornet

@cbornet cbornet commented Nov 4, 2022

Copy link
Copy Markdown
Contributor

Motivation

Currently ConsumerBuilder::loadConf resets non-serializable of ConsumerConfigurationData to null.
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 calling ConfigurationDataUtils::loadData

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Run ConsumerBuilderImplTest::testLoadConf and ConsumerBuilderImplTest::testLoadConfNotModified

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: cbornet#7

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Nov 4, 2022
@cbornet
cbornet force-pushed the loadconf-apply-non-serializable branch from d9c93a1 to f7ef902 Compare November 4, 2022 12:07

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

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

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

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".

Comment on lines +114 to +115
configurationData.setNegativeAckRedeliveryBackoff(negativeAckRedeliveryBackoff);
configurationData.setAckTimeoutRedeliveryBackoff(ackTimeoutRedeliveryBackoff);

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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 ?

Copy link
Copy Markdown
Contributor

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.

@cbornet
cbornet force-pushed the loadconf-apply-non-serializable branch 2 times, most recently from 2d7b1f6 to 4b6b973 Compare November 5, 2022 11:49
@codecov-commenter

codecov-commenter commented Nov 5, 2022

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.85%. Comparing base (545f33f) to head (98e6e37).
⚠️ Report is 3776 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
unittests 45.85% <100.00%> (+1.89%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...apache/pulsar/client/impl/ConsumerBuilderImpl.java 48.41% <100.00%> (+6.70%) ⬆️

... and 90 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cbornet
cbornet force-pushed the loadconf-apply-non-serializable branch from 4b6b973 to 98e6e37 Compare November 16, 2022 15:26
@github-actions

Copy link
Copy Markdown

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions Bot added the Stale label Dec 18, 2022
@Technoboy- Technoboy- added this to the 3.2.0 milestone Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs release/4.0.14 Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants