Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Inability to specify custom namespace for `java-key-class` entries when using `@AvroNamespace` annotation in those classes

Open
#611 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend

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

avro pr-needed

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FasterXML/jackson-dataformats-binary

All issues in FasterXML/jackson-dataformats-binary

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.