Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#611 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

Inizia con AvroMapper e AvroSchemaGenerator, quindi traccia come viene generato il valore java-key-class per il campo Map<ExampleEnum, String> in ExampleClass.java. Confronta questa ricerca con l’annotazione @AvroNamespace in ExampleEnum.java, mantenendo il fallback esistente al nome del package quando non è disponibile alcuna annotazione. Il lavoro è completato quando il ExampleClass.avsc generato usa il namespace personalizzato dell’enum e ExampleEnum.avsc rimane corretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
348
Fork
159
Merge medio
1g 16h
PR unite (30g)
46

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FasterXML/jackson-dataformats-binary

Tutte le issue di FasterXML/jackson-dataformats-binary

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.