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

Unable to generate Java from multi avsc #239

Open
jgordijn opened this issue Jan 24, 2025 · 5 comments
Open

Unable to generate Java from multi avsc #239

jgordijn opened this issue Jan 24, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jgordijn
Copy link

I have a Jar with multiple AVSC files. These were generated from AVDL files. For example:

@namespace("com.example")
protocol MyProtocol {

  record Metadata {
    string sender;
  }

  record MyRecord {
    Metadata metadata;
    string name;
    int age;
  }

  record MyRecord2 {
    Metadata metadata;
    string country;
  }
  
}

This will generate 2 AVSC files, which both contain the definition for Metadata. When I try to compile it I get something like:

* MyRecord2.avsc: Can't redefine: com.example.Metadata

It seems that this issue is fixed in Avro, but I still get it: https://issues.apache.org/jira/browse/AVRO-3940

@jgordijn
Copy link
Author

I can fix it when I change bridge/src/main/java/com/github/sbt/avro/AvscFilesParser.java and put this parser = parserSupplier.get(); on line 47, thus not reusing the same parser for every file.

@RustedBones RustedBones added the bug Something isn't working label Jan 26, 2025
@RustedBones
Copy link
Collaborator

Thanks for the bug report, will have a look this week.
This use case should definitly be integrated in our test suite.

@RustedBones RustedBones self-assigned this Jan 26, 2025
@RustedBones
Copy link
Collaborator

RustedBones commented Jan 27, 2025

This looks to be a bug upstream. I commended on the ASF Jira ticket.
In the test suite, if I redeclare an enum, it's all fine as long as they are equal.
If I redeclare a records it does not work because equality check is dones on a non complete record, before fields are populated.

@RustedBones
Copy link
Collaborator

See apache/avro#3304

@jgordijn
Copy link
Author

Nice. Thanks for following up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants