aromanenko-dev commented on code in PR #24992:
URL: https://github.com/apache/beam/pull/24992#discussion_r1088817034
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/io/Providers.java:
##########
@@ -42,12 +42,30 @@ private Providers() {}
public static <T extends Identifyable> Map<String, T> loadProviders(Class<T>
klass) {
Map<String, T> providers = new HashMap<>();
for (T provider : ServiceLoader.load(klass)) {
- checkArgument(
- !providers.containsKey(provider.identifier()),
- "Duplicate providers exist with identifier `%s` for class %s.",
- provider.identifier(),
- klass);
- providers.put(provider.identifier(), provider);
+ // Avro provider is treated as a special case until two providers may
exist: in "core"
+ // (deprecated) and in "extensions/avro" (actual).
+ if (provider.identifier().equals("avro")) {
+ // Avro provider from "extensions/avro" must have a priority.
+ if (provider
+ .toString()
+ .startsWith(
+
"org.apache.beam.sdk.extensions.avro.schemas.io.payloads.AvroPayloadSerializerProvider"))
{
+ // Use AvroPayloadSerializerProvider from extensions/avro by any
case.
+ providers.put(provider.identifier(), provider);
+ } else {
+ // Load Avro provider from "core" if it was not loaded from Avro
extension before.
+ if (!providers.containsKey(provider.identifier())) {
Review Comment:
Good catch, done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]