Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support avro 1.11.4. #563

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading