eolivelli opened a new issue #11274:
URL: https://github.com/apache/pulsar/issues/11274
**Describe the bug**
In current master (2.9.0-SNAPSHOT and probably in 2.8.0) it is not possible
to use `org.apache.avro.generic.GenericRecord ` class in order to manipulate
the returned object from `GenericRecord.getNativeRecord()`.
If I put the "avro" library inside the NAR file I see this error:
```
class org.apache.avro.generic.GenericData$Record cannot be cast to class
org.apache.avro.generic.GenericRecord
(org.apache.avro.generic.GenericData$Record is in unnamed module of loader
java.net.URLClassLoader @5451c3a8; org.apache.avro.generic.GenericRecord is in
unnamed module of loader org.apache.pulsar.common.nar.NarClassLoader @363f0ba0)
at
org.apache.pulsar.io.elasticsearch.ElasticSearchSink.extractJsonNode(ElasticSearchSink.java:284)
~[pulsar-io-elastic-search-2.9.0-SNAPSHOT.nar-unpacked/:?]
at
org.apache.pulsar.io.elasticsearch.ElasticSearchSink.stringifyValue(ElasticSearchSink.java:261)
~[pulsar-io-elastic-search-2.9.0-SNAPSHOT.nar-unpacked/:?]
at
org.apache.pulsar.io.elasticsearch.ElasticSearchSink.extractIdAndDocument(ElasticSearchSink.java:177)
~[pulsar-io-elastic-search-2.9.0-SNAPSHOT.nar-unpacked/:?]
at
org.apache.pulsar.io.elasticsearch.ElasticSearchSink.write(ElasticSearchSink.java:84)
~[pulsar-io-elastic-search-2.9.0-SNAPSHOT.nar-unpacked/:?]
at
org.apache.pulsar.functions.instance.JavaInstanceRunnable.sendOutputMessage(JavaInstanceRunnable.java:355)
[org.apache.pulsar-pulsar-functions-instance-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
at
org.apache.pulsar.functions.instance.JavaInstanceRunnable.handleResult(JavaInstanceRunnable.java:338)
[org.apache.pulsar-pulsar-functions-instance-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
at
org.apache.pulsar.functions.instance.JavaInstanceRunnable.run(JavaInstanceRunnable.java:283)
[org.apache.pulsar-pulsar-functions-instance-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
at java.lang.Thread.run(Thread.java:829) [?:?]
13:12:50.804
[public/default/test-sink-connector-elastic_search-PROCESS-name-fjpugexj-0]
INFO org.apache.pulsar.functions.instance.JavaInstanceRunnable
```
If I do not put the AVRO library inside the NAR I see a ClassNotFound error.
**To Reproduce**
I see this problem in integration tests of this PR regarding changes in
ElastichSearch Sink
https://github.com/apache/pulsar/pull/11263
**Expected behaviuor**
The Sink is able to manipulate AVRO native objects.
**Additional context**
Initially the ElasticSearch Sink patch was contributed before the 2.8.0
release, when we decided to change the contents of the class path for
Functions/Sinks.
At that time we had the full pulsar-client-original and its dependencies
(and thus AVRO) and it wasn't needed to add AVRO inside the NAR file.
As a system library probably it is better that it is in the classpath and
the implementation loaded by Pulsar takes the precedence over any other jar
file inside the nar file.
This is because the Sink must be able to access the results of
GenericRecord.getNativeObject(), that can be a Native CRO Record or a Jackson
JSON Node.
--
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]