Inability to specify custom namespace for `java-key-class` entries when using `@AvroNamespace` annotation in those classes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with AvroMapper and AvroSchemaGenerator, then trace how the java-key-class value is generated for the Map<ExampleEnum, String> field in ExampleClass.java. Compare that lookup with the @AvroNamespace annotation on ExampleEnum.java, preserving the existing package-name fallback when no annotation is available. Done means the generated ExampleClass.avsc uses the enum's custom namespace while ExampleEnum.avsc remains correct.
Written by the indexing model from the issue text.
Description
Hey, so when generating a avro schema using the AvroMapper and AvroSchemaGenerator, thanks to #310 we can specify the custom namespace each class should have. Now, given a class
ExampleClass.java
package com.example.test
import com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespace;
import java.util.Map;
@AvroNamespace("com.github.test")
public class ExampleClass {
public Map<ExampleEnum, String> exampleMap;
}
and the enum
ExampleEnum.java
package com.example.test
import com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespace;
@AvroNamespace("com.github.test")
public enum ExampleEnum {
FOO, BAR
}
, generating the schema by calling both classes explicitely (since nested generation doesn't work here) will yield
ExampleClass.avsc
{
"type" : "record",
"name" : "ExampleClass",
"namespace" : "com.github.test",
"fields" : [ {
"name" : "exampleMap",
"type" : [ "null", {
"type" : "map",
"values" : "string",
"java-key-class" : "com.example.test"
} ]
} ]
}
and
ExampleEnum.avsc
{
"type" : "enum",
"name" : "ExampleEnum",
"namespace" : "com.github.test",
"symbols" : [ "FOO", "BAR" ]
}
Notice how the specified java-key-class has the wrong namespace defined, since it is simply resolving the package name of the existing Java object.
The likely correct way would be to fetch the contents of the @AvroNamespace annotation inside the enum class and resolve it that way when a java-key-class entry is generated, if possible, and otherwise resolve it the old way.
Because I'm not sure of that possiblity though, another suggestion would be to implement an @AvroKeyClass annotation to be able to manually override that package definition.
- Dominant language
- Java
- Stars
- 348
- Forks
- 159
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 44
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/jackson-dataformats-binary
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
FasterXML/jackson-dataformats-binary#790 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
FasterXML/jackson-dataformats-binary#789 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
FasterXML/jackson-dataformats-binary#788 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
FasterXML/jackson-dataformats-binary#766 ·
Maintainers usually reply within 1 day
-
protobuf
Difficulty 4/5 3-5 days Newbie friendliness 35/100
FasterXML/jackson-dataformats-binary#630 · 3 comments ·
Maintainers usually reply within 1 day
All issues in FasterXML/jackson-dataformats-binary
Similar issues
-
NullPointerException when a `DeserializationProblemHandler` returns `null` for `byte[]` (single value unwrapped) and `char[]` elementsPossibly taken @Marti2203 claimed this today. Open
Difficulty 2/5 Half a day Newbie friendliness 88/100
FasterXML/jackson-databind#6300 ·
Maintainers usually reply within 1 day
-
content good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
cpinitiative/usaco-guide#6699 ·
Maintainers usually reply within 1 day
-
BC remittance upload: a claim MSP refused (S03) is saved with a blank status instead of refused (F)Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
carlos-emr/carlos#4933 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/rocketmq-dashboard#6925 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Vakore/ZappierGames#147 ·