Skip to content
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

deser primitive avro #700

Closed
raphaelauv opened this issue May 14, 2021 · 4 comments
Closed

deser primitive avro #700

raphaelauv opened this issue May 14, 2021 · 4 comments
Labels
bug Something isn't working topic data Kafka Topic data

Comments

@raphaelauv
Copy link
Contributor

raphaelauv commented May 14, 2021

with a primitive string avro schema for key

{"type": "string"}

how to reproduce :

  akhq:
    image: tchiotludo/akhq:0.17.0
    environment:
      AKHQ_CONFIGURATION: |
        akhq:
          connections:
            docker-kafka-server:
              properties:
                bootstrap.servers: "kafka-broker:29092"
              schema-registry:
                url: "http://schema-registry:8081"
    ports:
      - 9023:8080
      - 9024:8081

create a topic test_topic

produce a key schema for this topic with the schema-registry :

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"schema": "{\"type\": \"string\"}"}' \
  http://localhost:8081/subjects/test_topic-key/versions

Screenshot from 2021-05-14 19-15-39

produce an event in the topic with the key schema ( message value can be null )

Screenshot from 2021-05-14 19-16-36

there is a warning for message using the avro primitive schema ->

Screenshot from 2021-05-14 19-16-46

class java.lang.String cannot be cast to class org.apache.avro.generic.GenericRecord (java.lang.String is in module java.base of loader 'bootstrap'; org.apache.avro.generic.GenericRecord is in unnamed module of loader 'app')
@tchiotludo tchiotludo added bug Something isn't working topic data Kafka Topic data labels May 14, 2021
@raphaelauv
Copy link
Contributor Author

raphaelauv commented May 15, 2021

The visual problem of the key is only with google chrome !

Screenshot from 2021-05-15 17-48-15

not with firefox ->
Screenshot from 2021-05-15 17-49-14

the control-center of confluent have exactly the same problem with google chrome.

But there is still a warning with booth web browsers about the deser ->

Screenshot from 2021-05-15 17-12-21

@raphaelauv raphaelauv changed the title Produce a msg with an avro primitive schema key not supported Warning deser primitive avro string key May 15, 2021
@tchiotludo
Copy link
Owner

Can you provide the full stacktrace (if you have one) on the server logs ?

@raphaelauv raphaelauv changed the title Warning deser primitive avro string key Warning deser primitive avro string key since 0.17.0 May 16, 2021
@raphaelauv
Copy link
Contributor Author

raphaelauv commented May 16, 2021

if I set

image: tchiotludo/akhq:0.16.0

There is no more the WARN in the UI of booth web browsers, (but still the bug with google chrome on the print of the key)

So only since this 92d4ee8 commit the warning is visible in the UI

@raphaelauv
Copy link
Contributor Author

raphaelauv commented May 16, 2021

We need to manage the primitive cases that do not return a GenericRecord ->

GenericRecord record = (GenericRecord) kafkaAvroDeserializer.deserialize(topic, payload);

this work , but it's not elegant and not full coverage of all primitives listed there -> https://stackoverflow.com/a/34234039

Object toType = kafkaAvroDeserializer.deserialize(topic, payload);

if (!(toType instanceof GenericRecord)){
    return String.valueOf(toType);
}

GenericRecord record = (GenericRecord) toType;

@raphaelauv raphaelauv changed the title Warning deser primitive avro string key since 0.17.0 deser primitive avro record May 16, 2021
@raphaelauv raphaelauv changed the title deser primitive avro record deser primitive avro May 16, 2021
@tchiotludo tchiotludo moved this to Done in Backlog Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic data Kafka Topic data
Projects
Status: Done
Development

No branches or pull requests

2 participants