Skip to content

Commit

Permalink
Update avro to 1.11.3
Browse files Browse the repository at this point in the history
Namespace for nested classes no longer ends with '$'. This is how avro library generates schema since version 1.9. See: AVRO-2143
Please note that resolution of nested classes without '$' was implemented long ago in c570549.

Fixes FasterXML#167
  • Loading branch information
rafalh committed Aug 21, 2024
1 parent 2fb7e1d commit 41ab6b3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstractions.
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.8.2</version>
<version>1.11.3</version>
</dependency>

<!-- and for testing we need logback -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected static String getNamespace(Class<?> cls) {
// NOTE: was reverted in 2.8.8, but is enabled for Jackson 2.9.
Class<?> enclosing = cls.getEnclosingClass();
if (enclosing != null) {
return enclosing.getName() + "$";
return enclosing.getName();
}
Package pkg = cls.getPackage();
return (pkg == null) ? "" : pkg.getName();
Expand Down Expand Up @@ -351,6 +351,7 @@ public static String getFullName(Schema schema) {
if (namespace == null) {
return name;
}
// Backward compatibility with schemas that use dollar sign for nested classes (Apache Avro before 1.9)
final int len = namespace.length();
if (namespace.charAt(len-1) == '$') {
return namespace + name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void class_without_AvroNamespace_test() throws Exception {

// THEN
assertThat(actualSchema.getNamespace())
.isEqualTo("com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespaceTest$");
.isEqualTo("com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespaceTest");
}

@Test
Expand Down Expand Up @@ -65,7 +65,7 @@ public void enum_without_AvroNamespace_test() throws Exception {

// THEN
assertThat(actualSchema.getNamespace())
.isEqualTo("com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespaceTest$");
.isEqualTo("com.fasterxml.jackson.dataformat.avro.annotation.AvroNamespaceTest");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class AvroAliasTest extends InteropTestBase {

@AvroAlias(alias = "Employee", space = "com.fasterxml.jackson.dataformat.avro.AvroTestBase$")
@AvroAlias(alias = "Employee", space = "com.fasterxml.jackson.dataformat.avro.AvroTestBase")
public static class NewEmployee {

public String name;
Expand All @@ -40,7 +40,7 @@ public static class AliasedNameEmployee {
public AliasedNameEmployee boss;
}

@AvroAlias(alias = "Size", space = "com.fasterxml.jackson.dataformat.avro.AvroTestBase$")
@AvroAlias(alias = "Size", space = "com.fasterxml.jackson.dataformat.avro.AvroTestBase")
public enum NewSize {
SMALL,
LARGE;
Expand Down

0 comments on commit 41ab6b3

Please sign in to comment.