[fix][client] Fix ConfigurationDataUtils loadConf strategy - #13298
[fix][client] Fix ConfigurationDataUtils loadConf strategy#13298mgrenonville wants to merge 1 commit into
Conversation
|
|
||
| public static <T> T loadData(Map<String, Object> config, | ||
| T existingData, | ||
| Class<T> dataCls) { |
There was a problem hiding this comment.
The dataCls becomes useless after the new change, we should remove it.
There was a problem hiding this comment.
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 |
|
|
||
| private RegexSubscriptionMode regexSubscriptionMode = RegexSubscriptionMode.PersistentOnly; | ||
|
|
||
| @JsonIgnore |
There was a problem hiding this comment.
Will this introduce breaking change?
michaeljmarshall
left a comment
There was a problem hiding this comment.
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.
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.
+1. We can keep the old method and just mark deprecated.
There was a problem hiding this comment.
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.
+1. We can keep the old method and just mark deprecated.
|
|
||
| private boolean resetIncludeHead = false; | ||
|
|
||
| @JsonIgnore |
There was a problem hiding this comment.
Can you add some details about why we add @JsonIgnore here?
There was a problem hiding this comment.
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. |
|
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
yeswas chosen, please highlight the changes@JsonIgnoreproperties)Documentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
no-need-docThis was a bug in
loadConfcode, it is intended to work as follow (I think)doc-not-needed