-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-6728: Corrected the worker’s instantiation of the HeaderConverter #4815
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
Changes from all commits
8caef16
0ffc79e
864a52f
444d480
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,8 @@ public Converter newConverter(AbstractConfig config, String classPropertyName, C | |
| // Configure the Converter using only the old configuration mechanism ... | ||
| String configPrefix = classPropertyName + "."; | ||
| Map<String, Object> converterConfig = config.originalsWithPrefix(configPrefix); | ||
| log.debug("Configuring the {} converter with configuration:{}{}", | ||
| isKeyConverter ? "key" : "value", System.lineSeparator(), converterConfig); | ||
| plugin.configure(converterConfig, isKeyConverter); | ||
| return plugin; | ||
| } | ||
|
|
@@ -249,20 +251,21 @@ public Converter newConverter(AbstractConfig config, String classPropertyName, C | |
| * @throws ConnectException if the {@link HeaderConverter} implementation class could not be found | ||
| */ | ||
| public HeaderConverter newHeaderConverter(AbstractConfig config, String classPropertyName, ClassLoaderUsage classLoaderUsage) { | ||
| if (!config.originals().containsKey(classPropertyName)) { | ||
| // This configuration does not define the header converter via the specified property name | ||
| return null; | ||
| } | ||
| HeaderConverter plugin = null; | ||
| switch (classLoaderUsage) { | ||
| case CURRENT_CLASSLOADER: | ||
| if (!config.originals().containsKey(classPropertyName)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might want some commentary here, or in the javadoc, about how this works. the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, now I am wondering if we should rename the enums to be clearer. We can follow up on that separately, but I realize these branches aren't really very clear currently.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm concerned about doing that now. If you're okay with waiting, I can file a separate issue for later.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that's just about internal code being readable and understandable, not critical to current issue. |
||
| // This connector configuration does not define the header converter via the specified property name | ||
| return null; | ||
| } | ||
| // Attempt to load first with the current classloader, and plugins as a fallback. | ||
| // Note: we can't use config.getConfiguredInstance because we have to remove the property prefixes | ||
| // before calling config(...) | ||
| plugin = getInstance(config, classPropertyName, HeaderConverter.class); | ||
| break; | ||
| case PLUGINS: | ||
| // Attempt to load with the plugin class loader, which uses the current classloader as a fallback | ||
| // Attempt to load with the plugin class loader, which uses the current classloader as a fallback. | ||
| // Note that there will always be at least a default header converter for the worker | ||
| String converterClassOrAlias = config.getClass(classPropertyName).getName(); | ||
| Class<? extends HeaderConverter> klass; | ||
| try { | ||
|
|
@@ -288,6 +291,7 @@ public HeaderConverter newHeaderConverter(AbstractConfig config, String classPro | |
| String configPrefix = classPropertyName + "."; | ||
| Map<String, Object> converterConfig = config.originalsWithPrefix(configPrefix); | ||
| converterConfig.put(ConverterConfig.TYPE_CONFIG, ConverterType.HEADER.getName()); | ||
| log.debug("Configuring the header converter with configuration:{}{}", System.lineSeparator(), converterConfig); | ||
| plugin.configure(converterConfig); | ||
| return plugin; | ||
| } | ||
|
|
||
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.
Nice, given we're even a little unsure exactly the right way for this to work, this logging should at least help us explain to users even if the behavior isn't entirely obvious.