Skip to content

Commit

Permalink
Support avro 1.11.4.
Browse files Browse the repository at this point in the history
Co-authored-by: Jingjing Sun <[email protected]>
  • Loading branch information
leiykpt and Jnry committed Nov 15, 2024
1 parent 18f9cfa commit f963318
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 18 deletions.
2 changes: 1 addition & 1 deletion avro-builder/tests/codegen-111/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ compileJava.dependsOn runOwnCodegen
dependencies {
codegen project(":avro-builder:builder")

implementation ("org.apache.avro:avro:1.11.3") {
implementation ("org.apache.avro:avro:1.11.4") {
exclude group: "org.mortbay.jetty"
exclude group: "org.apache.velocity"
exclude group: "commons-lang"
Expand Down
4 changes: 2 additions & 2 deletions avro-builder/tests/tests-allavro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ dependencies {
exclude group: "org.slf4j"
}

avro111 ("org.apache.avro:avro:1.11.3") {
avro111 ("org.apache.avro:avro:1.11.4") {
exclude group: "org.slf4j"
}
avro111 ("org.apache.avro:avro-compiler:1.11.3") {
avro111 ("org.apache.avro:avro-compiler:1.11.4") {
exclude group: "org.slf4j"
}
}
Expand Down
17 changes: 14 additions & 3 deletions fastserde/avro-fastserde-tests111/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
testImplementation "org.apache.commons:commons-lang3:3.4"
testImplementation "com.sun.codemodel:codemodel:2.6"

testImplementation ("org.apache.avro:avro:1.11.3") {
testImplementation ("org.apache.avro:avro:1.11.4") {
exclude group: "org.slf4j"
}

Expand All @@ -44,8 +44,19 @@ dependencies {
testImplementation 'org.slf4j:slf4j-simple:1.7.14'

codegen project(":helper:helper")
codegen "org.apache.avro:avro-tools:1.11.3"
codegen "org.apache.avro:avro-compiler:1.11.3"

// trevni-avro and trevni-core no longer publish -test jars, but avro-tools still tries to pull in these test jars
// gradle does not support custom resolution strategy for classifier. The blocks below are to do a workaround by
// excluding trevni-avro and trevni-core first and then add them back without the test classifier
codegen ("org.apache.avro:avro-tools:1.11.4") {
exclude group: "org.apache.avro", module: "trevni-avro"
exclude group: "org.apache.avro", module: "trevni-core"
}
codegen ("org.apache.avro:trevni-avro:1.11.4") {
exclude group: "org.apache.avro", module: "trevni-core"
}
codegen "org.apache.avro:trevni-core:1.11.4"
codegen "org.apache.avro:avro-compiler:1.11.4"
}

test {
Expand Down
2 changes: 1 addition & 1 deletion helper/impls/helper-impl-111/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

dependencies {
implementation (project(":helper:helper-common"))
compileOnly ("org.apache.avro:avro:1.11.3")
compileOnly ("org.apache.avro:avro:1.11.4")
testImplementation project(":test-common")
testImplementation("org.mockito:mockito-inline:4.11.0")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
package com.linkedin.avroutil1.compatibility.avro111;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.specific.SpecificDatumReader;


/**
Expand All @@ -20,6 +22,8 @@ public class Avro111Utils {
private final static boolean IS_AT_LEAST_1_11_2;
private final static boolean IS_AT_LEAST_1_11_3;

private final static boolean IS_AT_LEAST_1_11_4;

static {
Class<?>[] inners = GenericDatumReader.class.getDeclaredClasses(); //never null
boolean found = false;
Expand Down Expand Up @@ -55,6 +59,19 @@ public class Avro111Utils {
//expected in avro < 1.11.3
}
IS_AT_LEAST_1_11_3 = found;

found = false;
//added in https://issues.apache.org/jira/browse/AVRO-3985
//see https://github.com/apache/avro/pull/2980/files#diff-95af304493048b22c3dda8fbfc7efb0e0c1c5e876f0234c2b8d0635bb2bcb494R151
Method[] methods = SpecificDatumReader.class.getDeclaredMethods();
for (Method method : methods) {
if ("getTrustedPackages".equals(method.getName())) {
found = true;
break;
}
}

IS_AT_LEAST_1_11_4 = found;
}

private Avro111Utils() {
Expand All @@ -72,4 +89,8 @@ public static boolean isAtLeast1112() {
public static boolean isAtLeast1113() {
return IS_AT_LEAST_1_11_3;
}

public static boolean isAtLeast1114() {
return IS_AT_LEAST_1_11_4;
}
}
16 changes: 13 additions & 3 deletions helper/tests/codegen-111/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,25 @@ compileJava.dependsOn runVanillaAvroCodegen, runCompatAvroCodegen, runCompatAvro
jar.dependsOn runResourceGeneration

dependencies {
codegen "org.apache.avro:avro-tools:1.11.3"
codegen "org.apache.avro:avro-compiler:1.11.3"
// trevni-avro and trevni-core no longer publish -test jars, but avro-tools still tries to pull in these test jars
// gradle does not support custom resolution strategy for classifier. The blocks below are to do a workaround by
// excluding trevni-avro and trevni-core first and then add them back without the test classifier
codegen ("org.apache.avro:avro-tools:1.11.4") {
exclude group: "org.apache.avro", module: "trevni-avro"
exclude group: "org.apache.avro", module: "trevni-core"
}
codegen ("org.apache.avro:trevni-avro:1.11.4") {
exclude group: "org.apache.avro", module: "trevni-core"
}
codegen "org.apache.avro:trevni-core:1.11.4"
codegen "org.apache.avro:avro-compiler:1.11.4"
codegen files('../codegenClasspath')
codegen project(":helper:tests:helper-tests-common")
codegen project(":helper:helper")

//required because generated code depends on the helper
implementation project(":helper:helper")
implementation "org.apache.avro:avro:1.11.3"
implementation "org.apache.avro:avro:1.11.4"

//this block required for resource generation code
implementation project(":helper:tests:helper-tests-common")
Expand Down
4 changes: 2 additions & 2 deletions helper/tests/helper-tests-111/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ dependencies {
exclude group: "org.apache.avro"
}

testImplementation "org.apache.avro:avro:1.11.3"
testImplementation "org.apache.avro:avro-compiler:1.11.3"
testImplementation "org.apache.avro:avro:1.11.4"
testImplementation "org.apache.avro:avro-compiler:1.11.4"
testImplementation "com.google.guava:guava:28.2-jre"
testImplementation "org.mockito:mockito-core:3.2.4"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ public class Avro111UtilsTest {

@Test
public void testAvro1111Detection() throws Exception {
//at time of writing we use 1.11.3
//at time of writing we use 1.11.4
Assert.assertTrue(Avro111Utils.isAtLeast1111());
}

@Test
public void testAvro1112Detection() throws Exception {
//at time of writing we use 1.11.3
//at time of writing we use 1.11.4
Assert.assertTrue(Avro111Utils.isAtLeast1112());
}

@Test
public void testAvro1113Detection() throws Exception {
//at time of writing we use 1.11.3
//at time of writing we use 1.11.4
Assert.assertTrue(Avro111Utils.isAtLeast1113());
}

@Test
public void testAvro1114Detection() throws Exception {
//at time of writing we use 1.11.4
Assert.assertTrue(Avro111Utils.isAtLeast1114());
}
}
6 changes: 3 additions & 3 deletions helper/tests/helper-tests-allavro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ dependencies {
exclude group: "org.slf4j"
}

avro111 ("org.apache.avro:avro:1.11.3") {
avro111 ("org.apache.avro:avro:1.11.4") {
exclude group: "org.slf4j"
}
avro111 ("org.apache.avro:avro-compiler:1.11.3") {
avro111 ("org.apache.avro:avro-compiler:1.11.4") {
exclude group: "org.slf4j"
}
avro111NoCompiler ("org.apache.avro:avro:1.11.3") {
avro111NoCompiler ("org.apache.avro:avro:1.11.4") {
exclude group: "org.slf4j"
}
}
Expand Down

0 comments on commit f963318

Please sign in to comment.