-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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) { |
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 dataCls
becomes useless after the new change, we should remove it.
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.
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.
68ff2b1
to
6a6b30e
Compare
Hi @codelipenghui ! |
@mgrenonville You can left a comment with content |
Maybe we could add a construct method for |
@@ -134,6 +131,7 @@ public int getMaxPendingChuckedMessage() { | |||
|
|||
private RegexSubscriptionMode regexSubscriptionMode = RegexSubscriptionMode.PersistentOnly; | |||
|
|||
@JsonIgnore |
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.
Will this introduce breaking change?
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 it's not needed anymore since #16487
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 am requesting changes because I think this is a breaking change. If that is incorrect, please let me know.
public static <T> T loadData(Map<String, Object> config, | ||
T existingData, | ||
Class<T> dataCls) { | ||
T existingData) { |
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.
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.
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.
+1. We can keep the old method and just mark deprecated.
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.
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
public static <T> T loadData(Map<String, Object> config, | ||
T existingData, | ||
Class<T> dataCls) { | ||
T existingData) { |
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.
+1. We can keep the old method and just mark deprecated.
@@ -149,12 +147,13 @@ public int getMaxPendingChuckedMessage() { | |||
|
|||
private boolean resetIncludeHead = false; | |||
|
|||
@JsonIgnore |
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.
Can you add some details about why we add @JsonIgnore
here?
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.
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
The pr had no activity for 30 days, mark with Stale label. |
The pr had no activity for 30 days, mark with Stale label. |
I don't think #11646 is related to this |
Since we will start the RC version of
So drag this PR to |
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 |
Motivation
When using
loadConf
, ConfigurationDataUtils was loading existing valuesin a Map using Jackson mapper. If there is a
@JsonIgnore
, Jacksonignores theses fields, but there will be forgotten in the new instance.
Modifications
Using
readerForUpdating(existingData).readValue(configJson)
willrefresh only overriden values in config map.
Verifying this change
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@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