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

[fix][client] Fix ConfigurationDataUtils loadConf strategy #13298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mgrenonville
Copy link
Contributor

@mgrenonville mgrenonville commented Dec 14, 2021

Motivation

When using loadConf, ConfigurationDataUtils was loading existing values
in a Map using Jackson mapper. If there is a @JsonIgnore, Jackson
ignores theses fields, but there will be forgotten in the new instance.

Modifications

Using readerForUpdating(existingData).readValue(configJson) will
refresh only overriden values in config map.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as org.apache.pulsar.client.impl.conf.ConfigurationDataUtilsTest.

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

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no
  • The rest endpoints: no
  • The admin cli options: no
  • Anything that affects deployment: no (at least, it will no longer fails silently on @JsonIgnore properties)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • no-need-doc
    This was a bug in loadConf code, it is intended to work as follow (I think)

  • doc-not-needed

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 14, 2021
@@ -51,20 +51,18 @@ public static ObjectMapper getThreadLocal() {
return mapper.get();
}

private ConfigurationDataUtils() {}
private ConfigurationDataUtils() {
}

public static <T> T loadData(Map<String, Object> config,
T existingData,
Class<T> dataCls) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The dataCls becomes useless after the new change, we should remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for review !
You're right, I've done the update.

Fixes apache#11646

When using `loadConf`, ConfigurationDataUtils was loading existing values
in a Map using Jackson mapper. If there is a `@JsonIgnore`, Jackson
ignores theses fields, but there will be forgotten in the new instance.
Using `readerForUpdating(existingData).readValue(configJson)` will
refresh only overriden values in config map.
Since it's using existing object to write values, `dataCls` param
becomes useless, thus removed.
@mgrenonville
Copy link
Contributor Author

mgrenonville commented Jan 5, 2022

Hi @codelipenghui !
It's strange, I see that CI test are failing however, when executing these tests on my computer, they work. Are they known to be flaky ?

@codelipenghui
Copy link
Contributor

@mgrenonville You can left a comment with content /pulsarbot run-failure-checks to trigger to rerun the failed tests.

@gaoran10
Copy link
Contributor

gaoran10 commented Jan 9, 2022

Maybe we could add a construct method for DeadLetterPolicy, then we could use the conf to set DeadLetterPolicy.

@@ -134,6 +131,7 @@ public int getMaxPendingChuckedMessage() {

private RegexSubscriptionMode regexSubscriptionMode = RegexSubscriptionMode.PersistentOnly;

@JsonIgnore
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this introduce breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not needed anymore since #16487

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

I am requesting changes because I think this is a breaking change. If that is incorrect, please let me know.

Comment on lines 57 to +58
public static <T> T loadData(Map<String, Object> config,
T existingData,
Class<T> dataCls) {
T existingData) {
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm mistaken, I believe this is part of the public API and could be used by user applications to build the ClientConfigurationData. We would need to find a way to introduce this without breaking the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. We can keep the old method and just mark deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I think it could have been used by users.
we should keep the old, make it work the same way as before and use the new method

Comment on lines 57 to +58
public static <T> T loadData(Map<String, Object> config,
T existingData,
Class<T> dataCls) {
T existingData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. We can keep the old method and just mark deprecated.

@@ -149,12 +147,13 @@ public int getMaxPendingChuckedMessage() {

private boolean resetIncludeHead = false;

@JsonIgnore
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some details about why we add @JsonIgnore here?

Copy link
Contributor

Choose a reason for hiding this comment

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

KeySharedPolicy is not deserializable:

    @Test
    public void test() {
        Map<String, Object> config = new HashMap<>();
        config.put("keySharedPolicy", KeySharedPolicy.autoSplitHashRange());
        consumerBuilderImpl.loadConf(config);
    }

fails with com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.apache.pulsar.client.api.KeySharedPolicy

@github-actions
Copy link

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

@github-actions
Copy link

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

@tisonkun
Copy link
Member

tisonkun commented Dec 6, 2022

#11646 (comment)

@tisonkun tisonkun closed this Dec 6, 2022
@cbornet
Copy link
Contributor

cbornet commented Dec 6, 2022

I don't think #11646 is related to this

@cbornet cbornet reopened this Dec 6, 2022
@tisonkun tisonkun changed the title [11646][Pulsar Java client] Fix ConfigurationDataUtils loadConf strategy [fix][client] Fix ConfigurationDataUtils loadConf strategy Dec 10, 2022
@poorbarcode
Copy link
Contributor

Since we will start the RC version of 3.0.0 on 2023-04-11, I will change the label/milestone of PR who have not been merged.

  • The PR of type feature is deferred to 3.1.0
  • The PR of type fix is deferred to 3.0.1

So drag this PR to 3.0.1

@michaeljmarshall
Copy link
Member

As discussed on the mailing list https://lists.apache.org/thread/w4jzk27qhtosgsz7l9bmhf1t7o9mxjhp, there is no plan to release 2.9.6, so I am going to remove the release/2.9.6 label

@Technoboy- Technoboy- modified the milestones: 3.1.0, 3.2.0 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
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.

None yet